From 852ec87862c5e900dbef2aeaad8dc023340292dc Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Sat, 7 Jan 2023 10:31:37 -0500 Subject: [PATCH 1/2] Add buildkite logger --- src/BinaryBuilder.jl | 2 ++ src/Logging.jl | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/BinaryBuilder.jl b/src/BinaryBuilder.jl index a9ba95662..6a880def1 100644 --- a/src/BinaryBuilder.jl +++ b/src/BinaryBuilder.jl @@ -47,6 +47,8 @@ function __init__() # If we're running on Azure, enable azure logging: if !isempty(get(ENV, "AZP_TOKEN", "")) enable_azure_logging() + elseif parse(Bool, get(ENV, "BUILDKITE", "false")) + enable_buildkite_logging() end end diff --git a/src/Logging.jl b/src/Logging.jl index 5d19a9372..8713610ff 100644 --- a/src/Logging.jl +++ b/src/Logging.jl @@ -38,3 +38,40 @@ function enable_azure_logging() AzureSinkLogger(), )) end + +struct BuildkiteLogger <: Logging.AbstractLogger +end + +function annotate(annotation; context="default", style="info", append=true) + @assert style in ("success", "info", "warning", "error") + append = append ? `--append` : `` + cmd = `buildkite-agent annotate --style $(style) --context $(context) $(append)` + open(cmd, stdout, write=true) do io + write(io, annotation) + end +end + +function Logging.handle_message(logger::BuildkiteLogger, args...; kwargs...) + #Make it a named tuple for easier working + log = LoggingExtras.handle_message_args(args...) + + # Buildkite calls it `style` not level`, and `warning` not `warn`: + log[:level] + stylemap = Dict(Logging.Error => "error", Logging.Warn => "warning") + style = stylemap[log[:level]] + + # TODO pretty rendering of properties + annotate(log.message; context="BinaryBuilder", style) + return nothing +end +Logging.shouldlog(::BuildkiteLogger, arg...) = true +Logging.min_enabled_level(::BuildkiteLogger) = Logging.Warn +Logging.catch_exceptions(::BuildkiteLogger) = true + +function enable_buildkite_logging() + # Tee-in BuildkiteLogger so that `@warn` and `@error` are printed out nicely + global_logger(TeeLogger( + global_logger(), + BuildkiteLogger(), + )) +end From 0dea451f940c02bd3221297fb14a61144ab9a0cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Tue, 17 Jan 2023 21:49:43 +0000 Subject: [PATCH 2/2] [AutoBuild] Update environment variable to get HEAD of Yggdrasil (#1257) --- src/AutoBuild.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AutoBuild.jl b/src/AutoBuild.jl index 3f7dafc78..004bbfe10 100644 --- a/src/AutoBuild.jl +++ b/src/AutoBuild.jl @@ -541,8 +541,8 @@ function _package_is_registered(registry_url::AbstractString, end is_yggdrasil() = get(ENV, "YGGDRASIL", "false") == "true" -# Use an Azure Pipelines environment variable to get the current commit hash -yggdrasil_head() = get(ENV, "BUILD_SOURCEVERSION", "") +# Use a Buildkite environment variable to get the current commit hash +yggdrasil_head() = get(ENV, "BUILDKITE_COMMIT", "") function register_jll(name, build_version, dependencies, julia_compat; deploy_repo="JuliaBinaryWrappers/$(name)_jll.jl",