From 90518a33394b6a72a0cb544a8ab90be523011b19 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 29 May 2026 20:37:02 +0100 Subject: [PATCH] Upload coverage to GitHub - Surface `brew tests --coverage` results in GitHub pull requests. - Reuse the existing Cobertura report uploaded to Codecov. - Allow `code-quality` until actionlint recognises the new scope. - Stop `github_spec` depending on live GitHub search results. --- .github/actionlint.yaml | 4 ++++ .github/workflows/tests.yml | 10 ++++++++++ Library/Homebrew/test/utils/github_spec.rb | 23 ++++++++++++++-------- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml index 4922a83d66b56..0bf03fab837a0 100644 --- a/.github/actionlint.yaml +++ b/.github/actionlint.yaml @@ -6,3 +6,7 @@ self-hosted-runner: # Empty array means no configuration variable is allowed. config-variables: - BREW_COMMIT_APP_ID +paths: + "**/.github/workflows/tests.yml": + ignore: + - unknown permission scope "code-quality" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 40cf6181f8681..fac0f6f0936ce 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -212,6 +212,10 @@ jobs: needs: syntax runs-on: ${{ matrix.runs-on }} timeout-minutes: 30 + permissions: + contents: read + code-quality: write + pull-requests: read strategy: fail-fast: false matrix: @@ -321,6 +325,12 @@ jobs: disable_search: true token: ${{ secrets.CODECOV_TOKEN }} + - uses: actions/upload-code-coverage@abb5995db9e0199b0e2bb9dbd136fce4cb1ec4d3 # v1 + with: + file: ${{ steps.set-up-homebrew.outputs.repository-path }}/Library/Homebrew/test/coverage/coverage.xml + language: Ruby + label: code-coverage/simplecov + test-bot: name: ${{ matrix.name }} needs: syntax diff --git a/Library/Homebrew/test/utils/github_spec.rb b/Library/Homebrew/test/utils/github_spec.rb index 096388300820c..9831d25420c4f 100644 --- a/Library/Homebrew/test/utils/github_spec.rb +++ b/Library/Homebrew/test/utils/github_spec.rb @@ -23,15 +23,22 @@ end end - describe "::search_issues", :needs_network do + describe "::search_issues" do it "queries GitHub issues with the passed parameters" do - results = klass.search_issues("brew search", - repo: "Homebrew/legacy-homebrew", - author: "MikeMcQuaid", - is: "issue", - no: "milestone") - expect(results).not_to be_empty - expect(results.first["title"]).to eq("Shall we move more things to taps?") + issue = { "title" => "Shall we move more things to taps?" } + + expect(GitHub::API).to receive(:open_rest) do |uri| + expect(uri.to_s).to eq("https://api.github.com/search/issues?" \ + "q=brew+search+repo%3AHomebrew%2Flegacy-homebrew+" \ + "author%3AMikeMcQuaid+type%3Aissue+no%3Amilestone&per_page=100") + { "items" => [issue] } + end + + expect(klass.search_issues("brew search", + repo: "Homebrew/legacy-homebrew", + author: "MikeMcQuaid", + type: "issue", + no: "milestone")).to eq([issue]) end end