diff --git a/.github/workflows/charts-lint-test.yaml b/.github/workflows/charts-lint-test.yaml index 1d92715f..e26a8ddd 100644 --- a/.github/workflows/charts-lint-test.yaml +++ b/.github/workflows/charts-lint-test.yaml @@ -85,10 +85,7 @@ jobs: lint: needs: - changes-lint - if: | - !contains(github.event.head_commit.message, '[ci-skip]') - && - needs.changes-lint.outputs.detected == 'true' + if: "!contains(github.event.head_commit.message, '[ci-skip]') && needs.changes-lint.outputs.detected == 'true'" name: Lint charts runs-on: ubuntu-20.04 steps: @@ -113,24 +110,10 @@ jobs: id: lint run: ct lint --config .github/ct-lint.yaml - # Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7 - lint_success: - needs: - - changes-lint - - lint - if: ${{ always() }} - name: Lint successful - runs-on: ubuntu-20.04 - steps: - - name: Check lint matrix status - if: ${{ !contains(github.event.head_commit.message, '[ci-skip]') && needs.changes-lint.outputs.detected == 'true' && needs.lint.result != 'success' }} - run: exit 1 - unittest: - needs: - - lint_success - if: | - !contains(github.event.head_commit.message, '[ci-skip]') + needs: + - lint + if: "!contains(github.event.head_commit.message, '[ci-skip]')" name: Run unit tests runs-on: ubuntu-20.04 steps: @@ -165,11 +148,8 @@ jobs: install: needs: - changes-install - - lint_success - if: | - !contains(github.event.head_commit.message, '[ci-skip]') - && - needs.changes-install.outputs.detected == 'true' + - lint + if: "!contains(github.event.head_commit.message, '[ci-skip]') && needs.changes-install.outputs.detected == 'true'" name: Install charts strategy: matrix: ${{ fromJson(needs.changes-install.outputs.matrix) }} @@ -208,7 +188,7 @@ jobs: # Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7 install_success: - needs: + needs: - changes-install - install if: ${{ always() }} diff --git a/.github/workflows/pre-commit-check.yaml b/.github/workflows/pre-commit-check.yaml new file mode 100644 index 00000000..01a265de --- /dev/null +++ b/.github/workflows/pre-commit-check.yaml @@ -0,0 +1,38 @@ +name: "Pre-commit consistency check" + +on: + workflow_dispatch: + pull_request: + +jobs: + pre-commit-check: + if: "!contains(github.event.head_commit.message, '[ci-skip]')" + name: Run pre-commit checks + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - uses: dorny/paths-filter@v2 + id: filter + with: + list-files: shell + filters: | + addedOrModified: + - added|modified: '**' + + # run only if changed files were detected + - name: Run against changes + uses: pre-commit/action@v2.0.2 + if: steps.filter.outputs.addedOrModified == 'true' + with: + extra_args: --files ${{ steps.filter.outputs.addedOrModified_files }} + + # run if no changed files were detected (e.g. workflow_dispatch on master branch) + - name: Run against all files + uses: pre-commit/action@v2.0.2 + if: steps.filter.outputs.addedOrModified != 'true' + with: + extra_args: --all-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bec56f1c..80e92c36 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,15 +7,11 @@ repos: - id: end-of-file-fixer - id: fix-byte-order-marker - id: mixed-line-ending + - id: check-merge-conflict + - id: check-case-conflict -- repo: local +- repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.1.10 hooks: - - id: ct-lint - name: "Chart Test: Lint" - language: docker_image - pass_filenames: false - types: ['file'] - files: '^charts/.*(\.ya?ml|\.tpl|\.helmignore|NOTES.txt)' - entry: -u 0 quay.io/helmpack/chart-testing:v3.0.0 ct - args: - - lint + - id: remove-crlf + - id: remove-tabs