diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7419bd5..ae27767 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,6 +47,8 @@ jobs: - run: ./build.sh smokeaot -s name: Run the native-AOT binary against GitHub shell: bash + env: + GITHUB_TOKEN: ${{ github.token }} # read-only; hosted runners share IPs, so the anonymous limit runs out # Container image, linux-x64 only for now — the platform every GitHub-hosted Linux runner # already matches. No --push here and no registry login on this leg, so this only proves the diff --git a/build/scripts/Program.fs b/build/scripts/Program.fs index d4972d1..ae72e1e 100644 --- a/build/scripts/Program.fs +++ b/build/scripts/Program.fs @@ -117,8 +117,9 @@ let main argv = // The framework-dependent build cannot catch what trimming breaks: #47 broke only the native-AOT binary, where // Octokit's reflection-based JSON returned nothing or threw. So this publishes that binary and reads releases - // and issues that no longer change: elastic/apm-agent-dotnet's 1.11.0 and the line around it. It runs - // anonymously, as the issue's reproduction did, which costs about 15 of the 60 requests an hour GitHub allows. + // and issues that no longer change: elastic/apm-agent-dotnet's 1.11.0 and the line around it. It costs about 15 + // requests. Locally it runs anonymously (60 an hour); in CI the job's read-only GITHUB_TOKEN is passed, because + // hosted runners share IPs and the anonymous limit ran out mid-run on macOS. | Smokeaot -> target [] { let rid = RuntimeInformation.RuntimeIdentifier let publishDirectory = Path.Combine(Paths.Output.FullName, "aot-smoke") @@ -126,19 +127,25 @@ let main argv = sh $"dotnet publish {toolProject} -c Release -f net10.0 -r {rid} -o {publish}" let executable = if OperatingSystem.IsWindows() then $"{Paths.ToolName}.exe" else Paths.ToolName let binary = Paths.RootRelative <| Path.Combine(publishDirectory, executable) + // Make.Fs quotes each interpolated hole as one argument, so --token stays in the command text + let token = Environment.GetEnvironmentVariable "GITHUB_TOKEN" + let run (args: string list) = + match token with + | null | "" -> text $"{binary} {args}" + | t -> text $"{binary} {args} --token {t}" // checked one command at a time and stopping at the first failure, so a broken binary spends few requests let check (command: string) (result: string) (expected: string list) = printfn "%s %s:\n%s" Paths.ToolName command result for line in expected do if not (result.Contains line) then failwithf "the native-AOT binary's %s did not print '%s'" command line // the latest release, then every page of releases: one object, then lists - let! previous = text $"{binary} find-previous elastic apm-agent-dotnet --version 1.11.0" + let! previous = run [ "find-previous"; "elastic"; "apm-agent-dotnet"; "--version"; "1.11.0" ] check "find-previous" previous [ "1.10.0" ] // every page of releases again, then one release by its tag - let! current = text $"{binary} current-version elastic apm-agent-dotnet --query 1.11 --version 1.11.0" + let! current = run [ "current-version"; "elastic"; "apm-agent-dotnet"; "--query"; "1.11"; "--version"; "1.11.0" ] check "current-version" current [ "1.11.1"; "1.11.2" ] // issues and pull requests, with their labels and pull request links - let! notes = text $"{binary} generate elastic apm-agent-dotnet --version 1.11.0" + let! notes = run [ "generate"; "elastic"; "apm-agent-dotnet"; "--version"; "1.11.0" ] check "generate" notes [ "- #1239 Add Cosmos DB support (issue: #1154)"; "- #1302 Prefer W3C traceparent" ] } app.RunAsync(argv).GetAwaiter().GetResult()