From 172fcf032f6c434b6859170fc31b6150f017875e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Wed, 7 Aug 2024 14:53:31 +0200 Subject: [PATCH] Add pre-commit in the project CI --- .../.github/workflows/main.yaml | 15 +++++++++++++++ .../{{cookiecutter.project}}/ci/requirements.txt | 1 + 2 files changed, 16 insertions(+) diff --git a/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/.github/workflows/main.yaml b/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/.github/workflows/main.yaml index 8c73ae09ee..b966c5ce4a 100644 --- a/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/.github/workflows/main.yaml +++ b/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/.github/workflows/main.yaml @@ -29,6 +29,21 @@ jobs: - run: echo "${HOME}/.local/bin" >> ${GITHUB_PATH} - run: python3 -m pip install --user --requirement=ci/requirements.txt + - uses: actions/cache@v4 + with: + path: ~/.cache/pre-commit + key: pre-commit-${{'{{'}} hashFiles('.pre-commit-config.yaml') }} + restore-keys: "pre-commit-${{'{{'}} hashFiles('.pre-commit-config.yaml') }}\npre-commit-" + - run: pre-commit run --all-files + - run: git diff --exit-code --patch > /tmp/pre-commit.patch || true + if: failure() + - uses: actions/upload-artifact@v4 + with: + name: Apply pre-commit fix.patch + path: /tmp/pre-commit.patch + retention-days: 1 + if: failure() + # Can be used to have some secrets (with mask) # - run: make secrets # - run: cat env.secrets |grep '^[# A-Z0-9_]\+='|sed -e 's/^[# A-Z0-9_]\+=\(.*\)/::add-mask::\1/g' diff --git a/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/ci/requirements.txt b/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/ci/requirements.txt index 8993699257..c943f5a1cb 100644 --- a/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/ci/requirements.txt +++ b/geoportal/c2cgeoportal_geoportal/scaffolds/create/{{cookiecutter.project}}/ci/requirements.txt @@ -1 +1,2 @@ c2cciutils[checks,publish]==1.6.22 +pre-commit==3.8.0