diff options
author | Thaddeus Crews <repiteo@outlook.com> | 2024-06-24 12:20:55 -0500 |
---|---|---|
committer | Thaddeus Crews <repiteo@outlook.com> | 2024-06-24 15:43:55 -0500 |
commit | e0d363aad8e2204fe8ca4b6937ef2ad74a7b293b (patch) | |
tree | c8300e4864984e9157ba8502ee019c4cd7226128 /.github/workflows | |
parent | c414c2b37d0563456a2fe194b16f8c4aa442e865 (diff) | |
download | redot-cpp-e0d363aad8e2204fe8ca4b6937ef2ad74a7b293b.tar.gz |
Integrate `.pre-commit-config.yaml`
Diffstat (limited to '.github/workflows')
-rw-r--r-- | .github/workflows/static_checks.yml | 63 |
1 files changed, 21 insertions, 42 deletions
diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml index f3c588a..6899248 100644 --- a/.github/workflows/static_checks.yml +++ b/.github/workflows/static_checks.yml @@ -7,48 +7,27 @@ concurrency: jobs: static-checks: - name: Format (clang-format, black format, file format) - runs-on: ubuntu-20.04 + name: Format (clang-format, ruff format, file format) + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v4 - - # Azure repositories are not reliable, we need to prevent Azure giving us packages. - - name: Make apt sources.list use the default Ubuntu repositories - run: | - sudo rm -f /etc/apt/sources.list.d/* - sudo cp -f misc/ci/sources.list /etc/apt/sources.list - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo apt-add-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main" - sudo apt-get update - - - name: Install dependencies - run: | - sudo apt-get install -qq dos2unix recode clang-format-15 libxml2-utils python3-pip moreutils - sudo update-alternatives --remove-all clang-format || true - sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-15 100 - sudo pip3 install black==22.3.0 pygments pytest==7.1.2 mypy==0.971 - - - name: File formatting checks (file_format.sh) - run: | - bash ./misc/scripts/file_format.sh - - - name: Header guards formatting checks (header_guards.sh) - run: | - bash ./misc/scripts/header_guards.sh - - - name: Python style checks via black (black_format.sh) - run: | - bash ./misc/scripts/black_format.sh - - - name: Python scripts static analysis (mypy_check.sh) - run: | - bash ./misc/scripts/mypy_check.sh - - - name: Bindings generation checks (ensures get_file_list returns all generated files) - run: | - python ./misc/scripts/check_get_file_list.py - - - name: Style checks via clang-format (clang_format.sh) - run: | - bash ./misc/scripts/clang_format.sh + with: + fetch-depth: 2 + + - name: Get changed files + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if [ "${{ github.event_name }}" == "pull_request" ]; 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.forced }}" == "false" -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 + files=$(echo "$files" | grep -v 'thirdparty' | 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: --verbose --hook-stage manual --files ${{ env.CHANGED_FILES }} |