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 1/3] =?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: From 4fad7de228097b3e7ec81aa68fd0d71c98f26f22 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: Wed, 27 Jul 2022 08:08:04 +0200 Subject: [PATCH 2/3] =?UTF-8?q?ci:=20=F0=9F=A7=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/collect-changes/action.yaml | 44 +++++++++++++-------- .github/workflows/pr-validate.yaml | 30 +++++++------- 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/.github/actions/collect-changes/action.yaml b/.github/actions/collect-changes/action.yaml index 7f53c79d..f04dd38b 100644 --- a/.github/actions/collect-changes/action.yaml +++ b/.github/actions/collect-changes/action.yaml @@ -10,7 +10,7 @@ outputs: value: ${{ steps.filter.outputs.addedOrModified_files }} addedOrModifiedCharts: description: "A list of the charts changed" - value: ${{ steps.filter-charts.outputs.addedOrModified }} + value: ${{ steps.filter-charts.outputs.addedOrModifiedCharts }} runs: using: "composite" @@ -24,22 +24,34 @@ runs: addedOrModified: - added|modified: 'charts/*/**' + # - name: Collect changed charts + # if: | + # steps.filter.outputs.addedOrModified == 'true' + # id: filter-charts + # shell: bash + # run: | + # CHARTS=() + # PATHS=(${{ steps.filter.outputs.addedOrModified_files }}) + # # Get only the chart paths + # for CHARTPATH in "${PATHS[@]}" + # do + # IFS='/' read -r -a path_parts <<< "${CHARTPATH}" + # CHARTS+=("${path_parts[1]}/${path_parts[2]}") + # done + + # # Remove duplicates + # CHARTS=( `printf "%s\n" "${CHARTS[@]}" | sort -u` ) + # # Set output to changed charts + # printf "::set-output name=addedOrModifiedCharts::%s\n" "${CHARTS[*]}" + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.2.1 + - name: Collect changed charts - if: | - steps.filter.outputs.addedOrModified == 'true' - id: filter-charts + id: changed-charts shell: bash run: | - CHARTS=() - PATHS=(${{ steps.filter.outputs.addedOrModified_files }}) - # Get only the chart paths - for CHARTPATH in "${PATHS[@]}" - do - IFS='/' read -r -a path_parts <<< "${CHARTPATH}" - CHARTS+=("${path_parts[1]}/${path_parts[2]}") - done - - # Remove duplicates - CHARTS=( `printf "%s\n" "${CHARTS[@]}" | sort -u` ) + CHARTS=$(ct list-changed --config .ci/ct/ct-lint.yaml) + echo "Charts: ${CHARTS}" # Set output to changed charts - printf "::set-output name=addedOrModified::%s\n" "${CHARTS[*]}" + printf "::set-output name=addedOrModifiedCharts::%s\n" "${CHARTS[*]}" diff --git a/.github/workflows/pr-validate.yaml b/.github/workflows/pr-validate.yaml index cf2a8270..5d9fa91e 100644 --- a/.github/workflows/pr-validate.yaml +++ b/.github/workflows/pr-validate.yaml @@ -18,14 +18,14 @@ concurrency: jobs: pr-metadata: - uses: bjw-s/helm-charts/.github/workflows/pr-metadata.yaml@main + uses: bjw-s/helm-charts/.github/workflows/pr-metadata.yaml@${{ github.event.pull_request.base.ref }} - pre-commit-check: - uses: bjw-s/helm-charts/.github/workflows/pre-commit-check.yaml@main - needs: - - pr-metadata - with: - modifiedFiles: ${{ needs.pr-metadata.outputs.addedOrModifiedFiles }} + # pre-commit-check: + # uses: bjw-s/helm-charts/.github/workflows/pre-commit-check.yaml@main + # needs: + # - pr-metadata + # with: + # modifiedFiles: ${{ needs.pr-metadata.outputs.addedOrModifiedFiles }} # charts-changelog: # uses: bjw-s/helm-charts/.github/workflows/charts-changelog.yaml@main @@ -36,14 +36,14 @@ jobs: # isRenovatePR: ${{ needs.pr-metadata.outputs.isRenovatePR }} # modifiedCharts: ${{ needs.pr-metadata.outputs.addedOrModifiedCharts }} - charts-lint: - uses: bjw-s/helm-charts/.github/workflows/charts-lint.yaml@main - needs: - - pr-metadata - - charts-changelog - with: - checkoutCommit: ${{ needs.charts-changelog.outputs.commitHash }} - chartChangesDetected: ${{ needs.pr-metadata.outputs.addedOrModified }} + # charts-lint: + # uses: bjw-s/helm-charts/.github/workflows/charts-lint.yaml@main + # needs: + # - pr-metadata + # - charts-changelog + # with: + # checkoutCommit: ${{ needs.charts-changelog.outputs.commitHash }} + # chartChangesDetected: ${{ needs.pr-metadata.outputs.addedOrModified }} # charts-test: # uses: bjw-s/helm-charts/.github/workflows/charts-test.yaml@main From cc8be59bb949d53566ff84864b935ae020862483 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: Wed, 27 Jul 2022 08:09:37 +0200 Subject: [PATCH 3/3] =?UTF-8?q?ci:=20=F0=9F=A7=A0=20(#5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ci: ðŸ§