From 56c865303b5337934953bbb26723e78b76788ebd Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Sun, 18 Feb 2024 14:44:37 +0000 Subject: [PATCH] CI: minify pre-commit config --- .github/workflows/test.yml | 49 ++++++++------------------------------ .pre-commit-config.yaml | 1 + 2 files changed, 11 insertions(+), 39 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 21f1595..d60e9fd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,40 +4,16 @@ on: pull_request: schedule: [{cron: '30 23 * * 6'}] # M H d m w (Sat at 23:30) jobs: - check: + clang-format: if: github.event_name != 'pull_request' || !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - name: set PYSHA - run: echo "PYSHA=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV - - uses: actions/cache@v4 - with: - path: ~/.cache/pre-commit - key: pre-commit|${{ env.PYSHA }}|${{ hashFiles('.pre-commit-config.yaml') }} - - name: dependencies - run: | - pip install -U pre-commit - sudo apt-get install -yqq clang-format - - uses: reviewdog/action-setup@v1 - - if: github.event_name == 'push' || github.event_name == 'pull_request' - name: comment - run: | - if [[ $EVENT == pull_request ]]; then - REPORTER=github-pr-review - else - REPORTER=github-check - fi - pre-commit run -a todo | reviewdog -efm="%f:%l: %m" -name=TODO -tee -reporter=$REPORTER -filter-mode nofilter - pre-commit run -a flake8 | reviewdog -f=pep8 -name=flake8 -tee -reporter=$REPORTER -filter-mode nofilter - pre-commit run -a mypy | reviewdog -efm="%f:%l: %m" -name=mypy -tee -reporter=$REPORTER -filter-mode nofilter - env: - REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} - EVENT: ${{ github.event_name }} - - run: pre-commit run -a --show-diff-on-failure + with: {python-version: '3.x'} + - run: sudo apt-get install -yqq clang-format + - uses: pre-commit/action@v3.0.1 + with: {extra_args: --all-files clang-format} test: if: github.event_name != 'pull_request' || !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association) name: py${{ matrix.python }} @@ -47,8 +23,7 @@ jobs: python: [3.7, 3.11] steps: - uses: actions/checkout@v4 - with: - fetch-depth: 0 + with: {fetch-depth: 0} - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} @@ -67,8 +42,7 @@ jobs: python: [3.7, 3.11] steps: - uses: actions/checkout@v4 - with: - fetch-depth: 0 + with: {fetch-depth: 0} - name: Run setup-python run: setup-python -p${{ matrix.python }} 'cuda-version<12' 'cupy<13' - name: pip install -U -e .[dev] @@ -81,12 +55,10 @@ jobs: run: setup-python -p${{ matrix.python }} -Dr if: ${{ always() }} deploy: - needs: [check, test, cuda] + needs: [clang-format, test, cuda] name: PyPI Deploy environment: pypi - permissions: - contents: write - id-token: write + permissions: {contents: write, id-token: write} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -94,8 +66,7 @@ jobs: fetch-depth: 0 token: ${{ secrets.GH_TOKEN || github.token }} - uses: actions/setup-python@v5 - with: - python-version: '3.x' + with: {python-version: '3.x'} - id: dist uses: casperdcl/deploy-pypi@v2 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c20f38f..5ba422f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,4 @@ +ci: {skip: [clang-format]} default_language_version: python: python3 repos: