go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/luciexe/build/doc.go (about) 1 // Copyright 2020 The LUCI Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Package build implements a minimal, safe, easy-to-use, hard-to-use-wrong, 16 // 'luciexe binary' implementation in Go. 17 // 18 // See `Start` for the entrypoint to this API. 19 // 20 // Features: 21 // - Can be used in library code which is used in both luciexe and non-luciexe 22 // contexts. You won't need "two versions" of your library just to give it 23 // the appearance of steps in a LUCI build context, or to have it read or 24 // write build properties. 25 // - Goroutine-safe API. 26 // - Handles all interactions with the log sink (e.g. LogDog), and 27 // automatically reroutes the logging library if a log sink is configured 28 // (so all log messages will be preserved in a build context). 29 // - Handles coalescing all build mutations from multiple goroutines. 30 // Efficient throttling for outgoing updates. 31 // - Automatically upholds all luciexe protocol invariants; Avoids invalid 32 // Build states by construction. 33 // - Automatically maps errors and panics to their obvious visual 34 // representation in the build (and allows manual control in case you want 35 // something else). 36 // - Fully decoupled from LUCI service implementation; You can use this API 37 // with no external services (e.g. for a CLI application), backed with the 38 // real LUCI implementation (e.g. when running under BuildBucket), and in 39 // tests (you can observe all outputs from this API without any live 40 // services or heavy mocks). 41 // 42 // # No-Op Mode 43 // 44 // When no Build is in use in the context, the library behaves in 'no-op' mode. 45 // This should enable libraries to add `build` features which gracefully degrade 46 // into pure terminal output via logging. 47 // 48 // - MakePropertyReader functions will return empty messages. Well-behaved 49 // libraries should handle having no configuration in the context if this is 50 // possible. 51 // - There will be no *State object, because there is no Start call. 52 // - StartStep/ScheduleStep will return a *Step which is detached. Step 53 // namespacing will still work in context (but name deduplication will not). 54 // - The result of State.Modify/Step.Modify (and Set) calls will be 55 // logged at DEBUG. 56 // - Step scheduled/started/ended messages will be logged at INFO. 57 // Ended log messages will include the final summary markdown as well. 58 // - Text logs will be logged line-by-line at INFO with fields set indicating 59 // which step and log they were emitted from. Debug text logs (those whose 60 // log names start with "$") will be logged at DEBUG level. 61 // - Non-text logs will be dropped with a WARNING indicating that they're 62 // being dropped. 63 // - MakePropertyReader property readers will return empty message objects. 64 // - MakePropertyModifier property manipulators will log their emitted 65 // properties at INFO. 66 package build 67 68 // BUG(iannucci): When OptLogsink is used and `logging` output is redirected to 69 // a Step log entitled "log", the current log format is reset to 70 // `gologger.StdFormat` instead of preserving the current log format from the 71 // context.