From 38d3f4a7bf7ad546f547051db021bcb54d3e25d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=E1=B4=87=CA=80=C9=B4=E1=B4=85=20S=E1=B4=84=CA=9C?= =?UTF-8?q?=E1=B4=8F=CA=80=C9=A2=E1=B4=87=CA=80s?= Date: Tue, 26 Jul 2022 22:14:09 +0200 Subject: [PATCH] =?UTF-8?q?ci:=20=F0=9F=A7=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .ci/pre-commit/config.yaml | 17 +++++++++++++++++ .github/workflows/charts-lint.yaml | 2 +- .github/workflows/pr-metadata.yaml | 4 ++-- .github/workflows/pre-commit-check.yaml | 21 +++++++++++++++++++++ .taskfiles/precommit.yaml | 23 +++++++++++++++++++++++ Taskfile.yaml | 1 + 6 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 .ci/pre-commit/config.yaml create mode 100644 .github/workflows/pre-commit-check.yaml create mode 100644 .taskfiles/precommit.yaml diff --git a/.ci/pre-commit/config.yaml b/.ci/pre-commit/config.yaml new file mode 100644 index 00000000..3dfa5739 --- /dev/null +++ b/.ci/pre-commit/config.yaml @@ -0,0 +1,17 @@ +# See https://pre-commit.com for more information +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: fix-byte-order-marker + - id: mixed-line-ending + - id: check-merge-conflict + - id: check-case-conflict + +- repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.1.10 + hooks: + - id: remove-crlf + - id: remove-tabs diff --git a/.github/workflows/charts-lint.yaml b/.github/workflows/charts-lint.yaml index ee207700..98f91cce 100644 --- a/.github/workflows/charts-lint.yaml +++ b/.github/workflows/charts-lint.yaml @@ -13,7 +13,7 @@ on: jobs: lint: name: Lint charts - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/pr-metadata.yaml b/.github/workflows/pr-metadata.yaml index 0496a185..d1d02bbd 100644 --- a/.github/workflows/pr-metadata.yaml +++ b/.github/workflows/pr-metadata.yaml @@ -22,7 +22,7 @@ on: jobs: pr-metadata: name: Collect PR metadata - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 outputs: isRenovatePR: ${{ startsWith(steps.branch-name.outputs.current_branch, 'renovate/') }} isFork: ${{ github.event.pull_request.head.repo.full_name != github.repository }} @@ -46,7 +46,7 @@ jobs: pr-changes: name: Collect PR changes - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 outputs: addedOrModified: ${{ steps.collect-changes.outputs.changesDetected }} addedOrModifiedFiles: ${{ steps.collect-changes.outputs.addedOrModifiedFiles }} diff --git a/.github/workflows/pre-commit-check.yaml b/.github/workflows/pre-commit-check.yaml new file mode 100644 index 00000000..3a0b1498 --- /dev/null +++ b/.github/workflows/pre-commit-check.yaml @@ -0,0 +1,21 @@ +name: "Pre-commit consistency check" + +on: + workflow_call: + inputs: + modifiedFiles: + required: true + type: string + +jobs: + pre-commit-check: + name: Run pre-commit checks + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Run against changes + uses: pre-commit/action@v3.0.0 + with: + extra_args: --files ${{ inputs.modifiedFiles }} --config .ci/pre-commit/config.yaml diff --git a/.taskfiles/precommit.yaml b/.taskfiles/precommit.yaml new file mode 100644 index 00000000..b591861f --- /dev/null +++ b/.taskfiles/precommit.yaml @@ -0,0 +1,23 @@ +--- +version: "3" + +tasks: + init: + desc: Install pre-commit hooks + cmds: + - pre-commit install --install-hooks --config .ci/pre-commit/config.yaml + + update: + desc: Update pre-commit hooks + cmds: + - pre-commit autoupdate --config .ci/pre-commit/config.yaml + + run: + desc: Run pre-commit + cmds: + - pre-commit run --config .ci/pre-commit/config.yaml + + run-all: + desc: Run pre-commit on all files + cmds: + - pre-commit run --all-files --config .ci/pre-commit/config.yaml diff --git a/Taskfile.yaml b/Taskfile.yaml index 214e993a..fb79f7a5 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -7,6 +7,7 @@ vars: includes: charts: .taskfiles/charts.yaml + precommit: .taskfiles/precommit.yaml tasks: default: