Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ concurrency:
permissions:
contents: read

env:
# True only for a Release PR opened by release-please and last pushed by it. Keying on the
# branch name alone would let any PR, a fork's included, name its branch release-please--x
# and skip every required check, which branch protection then counts as satisfied. The
# github.actor clause is the pusher rather than the PR author, so a human commit pushed
# onto the Release PR is tested like any other instead of riding the skip into main.
RELEASE_PR: >-
${{ github.actor == 'github-actions[bot]'
&& github.event.pull_request.user.login == 'github-actions[bot]'
&& github.event.pull_request.head.repo.full_name == github.repository
&& startsWith(github.head_ref, 'release-please--') }}

# The guard sits on the steps here rather than on the job, unlike the other five SDKs. main
# requires the six matrix legs of test-build by name, and a job-level `if:` is evaluated
# before the matrix expands, which is why the matrix context is not available there. A
# skipped job would produce one check run instead of six, so those required contexts would
# never appear and the Release PR would sit blocked forever. Guarding the steps keeps every
# leg reporting while the 20-minute integration leg is the part that goes away.
jobs:
test-build:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main requires six contexts by name, and they are the matrix legs of this job: ci / 馃懛 Test & Build 1.19 & Integration, ... 1.20 through ... 1.24 (plus 馃懏 Conventional PR title), with strict: true.

The change rests on a job-level if: still producing one skipped check run per matrix leg. If it does not, those six contexts are never created and the Release PR sits on six permanently-pending required checks, which is worse than the ~20 minutes saved. Worth confirming on one real Release PR before merging this one. The other five repos do not have this exposure (java requires one non-matrix context, php/net/ruby/py require none).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed, and it does not work. matrix is not available in jobs.<job_id>.if:

context "matrix" is not allowed here. available contexts are "github", "inputs", "needs", "vars"

The job if: is therefore evaluated before the matrix expands, so a skipped job produces one check run, not six. Those six required contexts would never be created and the Release PR would sit permanently blocked, which is worse than the time saved.

Moved the guard to the steps instead. All six legs still run checkout and setup-go and report, and the integration step plus the Codecov upload are what skip. This repo is now the only one of the six guarded at step level, and the comment above jobs: says why.

name: 馃懛 Test & Build ${{ matrix.goVer }}${{ matrix.label }}
Expand All @@ -39,15 +57,15 @@ jobs:
go-version: ${{ matrix.goVer }}

- name: Unit tests via ${{ matrix.goVer }}
if: matrix.goVer != '1.19'
if: matrix.goVer != '1.19' && env.RELEASE_PR != 'true'
env:
STREAM_BASE_URL: ${{ vars.STREAM_BASE_URL }}
STREAM_API_KEY: ${{ vars.STREAM_API_KEY }}
STREAM_API_SECRET: ${{ secrets.STREAM_API_SECRET }}
run: go test -short -v -race ./...

- name: Integration tests via ${{ matrix.goVer }}
if: matrix.goVer == '1.19'
if: matrix.goVer == '1.19' && env.RELEASE_PR != 'true'
env:
STREAM_BASE_URL: ${{ vars.STREAM_BASE_URL }}
STREAM_API_KEY: ${{ vars.STREAM_API_KEY }}
Expand All @@ -57,7 +75,7 @@ jobs:
go tool cover -func=cover.out

- name: Upload coverage to Codecov
if: matrix.goVer == '1.19'
if: matrix.goVer == '1.19' && env.RELEASE_PR != 'true'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
Loading