ci-pre-commit.yml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. name: Pre-commit checks
  2. on:
  3. pull_request:
  4. push:
  5. branches: [main]
  6. env:
  7. PYTHON_VERSION: "3.11"
  8. POETRY_VERSION: "1.4.2"
  9. jobs:
  10. pre-commit:
  11. runs-on: ubuntu-latest
  12. steps:
  13. - uses: actions/checkout@v3
  14. with:
  15. # Need to grab the history of the PR
  16. fetch-depth: 0
  17. - uses: actions-rs/toolchain@v1
  18. with:
  19. profile: default
  20. toolchain: 1.82.0
  21. - name: Install Rust versions
  22. run: |
  23. rustup install 1.73.0
  24. - name: Install protoc
  25. uses: arduino/setup-protoc@v3
  26. with:
  27. repo-token: ${{ secrets.GITHUB_TOKEN }}
  28. - uses: actions/checkout@v4
  29. - name: Install poetry
  30. run: pipx install poetry
  31. - name: Install g++ 12
  32. run: |
  33. sudo apt-get install g++-12
  34. echo "CXX=/usr/bin/g++-12" >> "${GITHUB_ENV}"
  35. - uses: actions/setup-python@v2
  36. with:
  37. python-version: ${{ env.PYTHON_VERSION }}
  38. id: setup_python
  39. - name: Cache Poetry cache
  40. uses: actions/cache@v3
  41. with:
  42. path: ~/.cache/pypoetry
  43. key: poetry-cache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.POETRY_VERSION }}
  44. - uses: pre-commit/action@v3.0.0
  45. if: ${{ github.event_name == 'pull_request' }}
  46. with:
  47. # Run only on files changed in the PR
  48. extra_args: --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}
  49. - uses: pre-commit/action@v3.0.0
  50. if: ${{ github.event_name != 'pull_request' }}