ci: TEST #22
This file contains 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: Format check | |
on: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- '**.py' | |
jobs: | |
generate: | |
runs-on: ubuntu-latest | |
outputs: | |
added: ${{ steps.git-diff-filter.outputs.added }} | |
changed: ${{ steps.git-diff-filter.outputs.changed }} | |
name: Detect added and changed files | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: GrantBirki/git-diff-action@v2 | |
id: git-diff-action | |
with: | |
base_branch: origin/main | |
search_path: '**.py' | |
git_options: '--no-color --full-index --unified=0' | |
json_diff_file_output: diff.json | |
# do not print any diff output to the console (safety first) | |
file_output_only: true | |
- name: Filter json diff | |
id: git-diff-filter | |
env: | |
JSON_DIFF: ${{ steps.git-diff-action.outputs.json-diff-path }} | |
run: | | |
# Filter files that only have deletions | |
added=$(cat $JSON_DIFF | jq -c -r '.files | map(select(.type == "AddedFile"))') | |
echo "added=$added" >> $GITHUB_OUTPUT | |
changed=$(cat $JSON_DIFF | jq -c -r '.files | map(select(.type == "ChangedFile")) | map(select(.chunks[].changes[].type == "AddedLine"))') | |
echo "changed=$changed" >> $GITHUB_OUTPUT | |
check-added: | |
needs: generate | |
if: ${{ needs.generate.outputs.added != '[]' }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
added: ${{ fromJSON(needs.generate.outputs.added) }} | |
name: Format check (${{ matrix.added.path }}) | |
steps: | |
- uses: astral-sh/ruff-action@v1 | |
with: | |
args: "format --check --diff" | |
# check-changed: | |
# needs: generate | |
# runs-on: ubuntu-latest | |
# strategy: | |
# matrix: ${{ fromJSON(needs.generate.outputs.matrix) }} | |
# name: Print diff (${{ matrix.path }}) | |
# steps: | |
# - name: Print json diff | |
# run: | | |
# echo "${{ matrix.path }}" |