Add pre-commit checks #1
Workflow file for this run
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
| name: ️✅ Validate | |
| on: [push, pull_request, merge_group] | |
| jobs: | |
| static-checks: | |
| name: Code style and file formatting | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout project | |
| uses: actions/checkout@v4.1.1 | |
| - name: Install APT dependencies | |
| uses: awalsh128/cache-apt-pkgs-action@v1.4.3 | |
| with: | |
| packages: libxml2-utils | |
| - name: Get changed files | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git config diff.wsErrorHighlight all | |
| if [ "${{ github.event_name }}" == "pull_request" -o "${{ github.event.forced }}" == "true" -o "${{ github.event.created }}" == "true" ]; then | |
| files=$(git diff-tree --no-commit-id --name-only -r HEAD^1..HEAD 2> /dev/null || true) | |
| elif [ "${{ github.event_name }}" == "push" -a "${{ github.event.created }}" == "false" ]; then | |
| files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }}..${{ github.event.after }} 2> /dev/null || true) | |
| fi | |
| echo "$files" >> changed.txt | |
| cat changed.txt | |
| files=$(echo "$files" | xargs -I {} sh -c 'echo "\"./{}\""' | tr '\n' ' ') | |
| echo "CHANGED_FILES=$files" >> $GITHUB_ENV | |
| - name: Style checks via pre-commit | |
| uses: pre-commit/action@v3.0.1 | |
| with: | |
| extra_args: --files ${{ env.CHANGED_FILES }} |