From 3e6a81931bdbfbf4042ebf387b24ee16f6ba5ba5 Mon Sep 17 00:00:00 2001 From: Samuel Larkin Date: Thu, 27 Jun 2024 11:41:04 -0400 Subject: [PATCH] feat: added pre-commit.ci --- .github/workflows/pre-commit.yml | 42 ++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 30 +++++++++++------------ 2 files changed, 57 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/pre-commit.yml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 00000000..62f976ae --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,42 @@ +# [install the GitHub Application on the relevant repositories](https://github.com/apps/pre-commit-ci-lite/installations/new) +name: Run pre-commit.ci lite + +on: + pull_request: + push: + branches: [main] + +jobs: + main: + # note: the step must have either the default name or contain the text + # pre-commit-ci-lite. the application uses this to find the right workflow. + # [pre-commit.ci lite](https://pre-commit.ci/lite.html) + name: pre-commit-ci-lite + runs-on: ubuntu-latest + steps: + - name: Checkout repository and submodules + uses: actions/checkout@v4 + with: + token: ${{ secrets.SGILE_PAT }} + submodules: recursive + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Install dependencies and package + run: | + pip install -r requirements.dev.txt + pip install pydantic + - name: File changes + uses: trilom/file-changes-action@v1.2.4 + id: file_changes + with: + prNumber: ${{ github.event.number }} + output: " " + - name: pre-commit + uses: pre-commit/action@v3.0.1 + with: + extra_args: --files ${{ steps.file_changes.outputs.files }} + - name: Pre commit lite + uses: pre-commit-ci/lite-action@v1.0.2 + if: always() diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7c2442bd..ff6983c0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,37 +1,37 @@ repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 hooks: - - id: check-yaml - - id: end-of-file-fixer - - id: trailing-whitespace + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace exclude: \.svg$ -- repo: local + - repo: local # Using local repos because these won't work for me from remote repo -EJ # They're also more convenient because we install them via requirements.dev.txt # and they are then available on the command line as well as in pre-commit. hooks: - - id: isort + - id: isort name: isort entry: isort language: system types: [python] stages: [commit] - - id: black + - id: black name: black entry: black language: system types: [python] stages: [commit] -# We do flake8 last since black fixes a lot of the stuff it complains about -- repo: https://github.com/pycqa/flake8 - rev: 3.8.3 + # We do flake8 last since black fixes a lot of the stuff it complains about + - repo: https://github.com/pycqa/flake8 + rev: 7.1.0 hooks: - - id: flake8 -# We do mypy last because it's the slowest of them all -- repo: local + - id: flake8 + # We do mypy last because it's the slowest of them all + - repo: local hooks: - - id: mypy + - id: mypy name: mypy entry: mypy language: system