From 5e69c1735933dcef1d33638f4fe918a475ce03ac Mon Sep 17 00:00:00 2001 From: Onno Broekmans Date: Wed, 20 Mar 2024 13:40:55 +0100 Subject: [PATCH 1/2] Add reusable workflow for pre-commit In Ultimaker/marvin-service#147, it looks like we lost the workflow for running pre-commit as part of the CI pipeline for PRs. In order to be able to re-introduce this step, and also introduce this for other repos, recover this workflow definition as a re-usable one in *embedded-workflows*. --- .github/workflows/precommit.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/precommit.yml diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml new file mode 100644 index 0000000..92c0871 --- /dev/null +++ b/.github/workflows/precommit.yml @@ -0,0 +1,31 @@ +on: + workflow_call: + +jobs: + run_pre-commit: + runs-on: ubuntu-20.04 + + permissions: + contents: 'read' + id-token: 'write' + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python 3.7 + uses: actions/setup-python@v4 + with: + python-version: "3.7" + + - name: Install dependencies + run: | + python -m pip install pre-commit + # From: https://github.com/pre-commit/action/blob/main/action.yml + - name: Cache pre-commit env + uses: actions/cache@v3 + with: + path: ~/.cache/pre-commit + key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} + + - name: Run pre-commit + run: pre-commit run --all-files --show-diff-on-failure From d45d08d2fe9a21bdb09d04bbcd389a322df1d33b Mon Sep 17 00:00:00 2001 From: Onno Broekmans Date: Wed, 20 Mar 2024 14:33:33 +0100 Subject: [PATCH 2/2] Use Python 3.8 for pre-commit Unfortunately, pre-commit no longer supports Python 3.7, so run it on Python 3.8. This is not ideal, but should be mostly fine. --- .github/workflows/precommit.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index 92c0871..65e649d 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -12,10 +12,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python 3.7 + - name: Set up Python 3.8 uses: actions/setup-python@v4 with: - python-version: "3.7" + python-version: "3.8" - name: Install dependencies run: |