-
Notifications
You must be signed in to change notification settings - Fork 97
fix: add linter for PR-only changes in samples-go #198
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -17,39 +17,80 @@ concurrency: | |||
| group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} | ||||
| cancel-in-progress: true | ||||
|
|
||||
|
|
||||
| jobs: | ||||
| detect-go-projects: | ||||
| name: project-changes | ||||
| runs-on: ubuntu-latest | ||||
| outputs: | ||||
| matrix: ${{ steps.set-matrix.outputs.matrix }} | ||||
|
|
||||
| steps: | ||||
| # Checkout full history so git diff works correctly | ||||
| - uses: actions/checkout@v4 | ||||
| with: | ||||
| fetch-depth: 0 | ||||
|
|
||||
| - name: Build matrix of changed Go projects | ||||
| id: set-matrix | ||||
| run: | | ||||
| # Ensure base branch is available locally for diff | ||||
| echo "Step 0: prepare diff base" | ||||
| if [ "${{ github.event_name }}" = "pull_request" ]; then | ||||
| git fetch origin ${{ github.base_ref }} | ||||
| diff_base="origin/${{ github.base_ref }}" | ||||
| else | ||||
| diff_base="HEAD~1" | ||||
| fi | ||||
|
|
||||
| echo "Step 1: get changed files" | ||||
| files=$(git diff --name-only "$diff_base"...HEAD) | ||||
|
|
||||
| # echo "Step 1: get changed files" | ||||
| # files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD) | ||||
|
||||
|
|
||||
| echo "Step 2: get top-level directories" | ||||
| dirs=$(echo "$files" | cut -d/ -f1 | sort -u) | ||||
|
Comment on lines
+52
to
+56
|
||||
|
|
||||
| echo "Step 3: filter go projects" | ||||
| projects=() | ||||
| for dir in $dirs; do | ||||
| if [ -f "$dir/go.mod" ]; then | ||||
| # projects+=("\"$dir\"") | ||||
|
||||
| # projects+=("\"$dir\"") |
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.
fixed
Copilot
AI
Jan 18, 2026
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.
Remove commented-out code. This line appears to be an alternative implementation using jq and should be deleted if it's no longer needed.
| # matrix=$(printf '%s\n' "${projects[@]}" | jq -R . | jq -cs .) |
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.
fixed
Copilot
AI
Jan 18, 2026
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 script does not handle the case where git diff might fail or produce unexpected output. Add error handling with set -e at the beginning of the script to exit on errors, or add explicit error checks after critical commands to ensure the workflow fails gracefully if something goes wrong.
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.
github workflow by default use the bash -e {0}, so set -e is active
here the doc link - https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#defaultsrunshell

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.
Using HEAD
1 for push events may fail on the initial commit or when the repository has shallow clones from other workflows. Consider using a more robust approach, such as comparing against the specific commit SHA from the before field in the push event payload using github.event.before, or handle the case where HEAD1 doesn't exist.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.
fixed this edge case