diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7419bd5..c1303da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,10 +43,13 @@ jobs: env: RID: ${{ matrix.rid }} - # Trimming breaks only the native-AOT binary (#47), so read real releases and issues with it + # Trimming breaks only the native-AOT binary (#47), so read real releases and issues with it. The token is for + # the rate limit: anonymous requests count against the runner's address, which other jobs share. - run: ./build.sh smokeaot -s name: Run the native-AOT binary against GitHub shell: bash + env: + GITHUB_TOKEN: ${{ github.token }} # 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..8639a80 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. That costs about + // 15 requests. GitHub allows an address 60 anonymous requests an hour, and a hosted runner shares its address + // with other jobs, so the reads use GITHUB_TOKEN when it is set and are anonymous otherwise. | Smokeaot -> target [] { let rid = RuntimeInformation.RuntimeIdentifier let publishDirectory = Path.Combine(Paths.Output.FullName, "aot-smoke") @@ -126,19 +127,24 @@ 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) + let auth = + match Environment.GetEnvironmentVariable "GITHUB_TOKEN" with + | null + | "" -> [] + | token -> [ "--token"; token ] // 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 = text $"{binary} find-previous elastic apm-agent-dotnet --version 1.11.0 {auth}" 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 = text $"{binary} current-version elastic apm-agent-dotnet --query 1.11 --version 1.11.0 {auth}" 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 = text $"{binary} generate elastic apm-agent-dotnet --version 1.11.0 {auth}" check "generate" notes [ "- #1239 Add Cosmos DB support (issue: #1154)"; "- #1302 Prefer W3C traceparent" ] } app.RunAsync(argv).GetAwaiter().GetResult()