Skip to content

Commit

Permalink
fix(github-actions): changed files output for editorcondig-checker (#…
Browse files Browse the repository at this point in the history
…1180)

* fix(github-actions): changed files output for editorcondig-checker

Seems that ci.yml includes a dead dependency action just to get list of
changed files for the PR / push. This seems weird as the repo is all
about git. Propose removing this extra dep with straightforward
implemenation. Also: github runners do have `jq` preinstalled.

* feat(ci): print changed files to log in lint job
  • Loading branch information
oikarinen authored Nov 26, 2024
1 parent 6520331 commit 0989b77
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,34 @@ jobs:
lint:
runs-on: 'ubuntu-latest'
steps:
- name: 'Get Changed Files'
id: 'files'
uses: 'masesgroup/retrieve-changed-files@v3'
with:
format: 'json'
# a force push will cause the action above to fail. Don't do force push when people are
# reviewing!
- name: Check out code.
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 'Get Changed Files'
id: 'files'
run: |
CHANGED_FILES=$(git diff --name-only "${BASE_SHA:-$BEFORE_SHA}...${HEAD_SHA:-GITHUB_REF}")
echo "::notice::Changed files: $CHANGED_FILES"
{
echo "added_modified<<EOF"
echo "$CHANGED_FILES"
echo "EOF"
} >> "$GITHUB_OUTPUT"
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
BEFORE_SHA: "${{ github.event.before }}"
- uses: 'actions/setup-go@v5'
with:
go-version: '1.20'
- name: 'Install EditorConfig Lint'
run: go install 'github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@latest'
- name: 'Check EditorConfig Lint'
run: |
sudo apt install -y jq
go install 'github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@latest'
readarray -t changed_files <<<"$(jq -r '.[]' <<<'${{ steps.files.outputs.added_modified }}')"
~/go/bin/editorconfig-checker ${changed_files[@]}
run: echo "$FILES" | xargs ~/go/bin/editorconfig-checker
env:
# NOTE: use env to pass the output in order to avoid possible injection attacks
FILES: "${{ steps.files.outputs.added_modified }}"

typo:
runs-on: ubuntu-latest
Expand Down

0 comments on commit 0989b77

Please sign in to comment.