ci-pre-commit.yml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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: minimal
  20. toolchain: nightly-2023-03-01
  21. components: rustfmt, clippy
  22. - uses: actions-rs/toolchain@v1
  23. with:
  24. profile: minimal
  25. toolchain: nightly-2023-07-23
  26. components: rustfmt, clippy
  27. - uses: actions/checkout@v4
  28. - name: Install poetry
  29. run: pipx install poetry
  30. - uses: actions/setup-python@v2
  31. with:
  32. python-version: ${{ env.PYTHON_VERSION }}
  33. id: setup_python
  34. - name: Cache Poetry cache
  35. uses: actions/cache@v3
  36. with:
  37. path: ~/.cache/pypoetry
  38. key: poetry-cache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.POETRY_VERSION }}
  39. - name: Install poetry dependencies
  40. run: poetry -C express_relay/sdk/python/express_relay install
  41. shell: sh
  42. - uses: pre-commit/action@v3.0.0
  43. if: ${{ github.event_name == 'pull_request' }}
  44. with:
  45. # Run only on files changed in the PR
  46. extra_args: --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}
  47. - uses: pre-commit/action@v3.0.0
  48. if: ${{ github.event_name != 'pull_request' }}