-
Notifications
You must be signed in to change notification settings - Fork 51
perf(ci): skip Go jobs for docs-only changes #727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| #!/usr/bin/env bash | ||
| # Detect whether a PR or push includes Go-related changes. | ||
| # Prints "true" or "false" to stdout. | ||
| # | ||
| # Requires: GH_TOKEN, GITHUB_REPOSITORY | ||
| # Arguments: <event_name> <pr_number|""> <before_sha|""> <head_sha|""> | ||
| set -euo pipefail | ||
|
|
||
| event_name=$1 | ||
| pr_number=${2:-} | ||
| before_sha=${3:-} | ||
| head_sha=${4:-} | ||
|
|
||
| if [ "$event_name" = "pull_request" ]; then | ||
| changed=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${pr_number}/files" \ | ||
| --paginate --jq '.[].filename') | ||
| else | ||
| if [ "$before_sha" = "0000000000000000000000000000000000000000" ]; then | ||
| echo true | ||
| exit 0 | ||
| fi | ||
| changed=$(gh api "repos/${GITHUB_REPOSITORY}/compare/${before_sha}...${head_sha}" \ | ||
| --jq '.files[].filename') | ||
| fi | ||
|
|
||
| if [ -z "$changed" ]; then | ||
| echo false | ||
| exit 0 | ||
| fi | ||
|
|
||
| # For push events, the compare API caps at 300 files. | ||
| if [ "$event_name" != "pull_request" ]; then | ||
| file_count=$(echo "$changed" | wc -l) | ||
| if [ "$file_count" -ge 300 ]; then | ||
| echo "::warning::Compare API file cap hit ($file_count files), assuming Go changes" | ||
| echo true | ||
| exit 0 | ||
| fi | ||
| fi | ||
|
|
||
| # Anything outside these paths is considered Go-related. | ||
| # Intentionally conservative: unknown paths trigger Go CI. | ||
| non_docs=$(echo "$changed" | grep -vE '^docs/|^images/|\.md$|^LICENSE|^\.github/workflows/pages\.yml$|^\.claude/' || true) | ||
| if [ -n "$non_docs" ]; then | ||
| echo true | ||
| else | ||
| echo false | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
always()condition allowssemantic-releaseto run even whentestandnix-buildare skipped (docs-only changes). Previously,semantic-releaserequired these jobs to succeed. While in practicedocs:-type commits won't trigger a release (the default@semantic-release/commit-analyzeronly releases forfeat,fix,perf), any mistakenly categorized commit (e.g.,feat: update docs) would publish a release without Go tests having run. Consider adding&& (needs.changes.outputs.go != 'true' || needs.test.result == 'success')to ensure that when Go changes are present, tests must pass before a release can happen.