Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sesheffield committed Jul 25, 2024
1 parent 43507bb commit c9d1087
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions .github/workflows/ci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,35 @@ jobs:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
run: |
# Fetch the full history to ensure we can compare commits
git fetch --prune --unshallow
# List changed files in the last commit
changed_files=$(git diff --name-only HEAD^ HEAD | grep '\.go$')
echo "Changed Go files:"
echo "$changed_files"
# Set the changed files as an output
echo "changed_go_files=$changed_files" >> $GITHUB_ENV
echo "::set-output name=changed_go_files::$changed_files"
- name: List all changed files
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
for file in ${{ env.changed_go_files }}; do
echo "$file was changed"
done
- name: Prepare Lint Args
id: prepare-lint-args
run: |
# Extract changed Go files and format them for golangci-lint
changed_files="${{ steps.changed-files.outputs.all_changed_files }}"
changed_files="${{ env.changed_go_files }}"
if [ -z "$changed_files" ]; then
echo "No Go files changed, skipping golangci-lint."
exit 0
fi
echo "Changed Go files:"
echo "$changed_files"
# Prepare arguments for golangci-lint
# Filter only Go files
go_files=$(echo "$changed_files" | grep '\.go$' | tr '\n' ' ')
echo "go_files=$go_files" >> $GITHUB_ENV
lint_args=$(echo "$changed_files" | tr '\n' ' ')
echo "lint_args=$lint_args" >> $GITHUB_ENV
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
Expand All @@ -48,7 +55,7 @@ jobs:
args: --timeout 30m --verbose --allow-parallel-runners --max-same-issues 0 --max-issues-per-linter 0 ${{ env.lint_args }}
working-directory: ${{ github.workspace }}
if: |
contains(steps.changed-files.outputs.all_changed_files, '.go')
contains(env.changed_go_files, '.go')
# - name: Load Version
# id: load-version
Expand Down

0 comments on commit c9d1087

Please sign in to comment.