mirror of
https://github.com/k8s-at-home/charts.git
synced 2025-01-23 15:39:02 +00:00
[CI] Add pre-commit check (#845)
* [CI] Add pre-commit check Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs <me@bjw-s.dev> * Add other folder for testing Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs <me@bjw-s.dev> * Simplify CI Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs <me@bjw-s.dev> * Update pre-commit Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs <me@bjw-s.dev> * Update job name Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs <me@bjw-s.dev> * Linter issues Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs <me@bjw-s.dev> * Fix conditionals Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs <me@bjw-s.dev> * Separate chart linting and pre-commit Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs <me@bjw-s.dev> * Change workflow name Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs <me@bjw-s.dev> * Allow running against all files Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs <me@bjw-s.dev>
This commit is contained in:
parent
f5e0e308b9
commit
8394533292
34
.github/workflows/charts-lint-test.yaml
vendored
34
.github/workflows/charts-lint-test.yaml
vendored
@ -85,10 +85,7 @@ jobs:
|
|||||||
lint:
|
lint:
|
||||||
needs:
|
needs:
|
||||||
- changes-lint
|
- changes-lint
|
||||||
if: |
|
if: "!contains(github.event.head_commit.message, '[ci-skip]') && needs.changes-lint.outputs.detected == 'true'"
|
||||||
!contains(github.event.head_commit.message, '[ci-skip]')
|
|
||||||
&&
|
|
||||||
needs.changes-lint.outputs.detected == 'true'
|
|
||||||
name: Lint charts
|
name: Lint charts
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
@ -113,24 +110,10 @@ jobs:
|
|||||||
id: lint
|
id: lint
|
||||||
run: ct lint --config .github/ct-lint.yaml
|
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:
|
unittest:
|
||||||
needs:
|
needs:
|
||||||
- lint_success
|
- lint
|
||||||
if: |
|
if: "!contains(github.event.head_commit.message, '[ci-skip]')"
|
||||||
!contains(github.event.head_commit.message, '[ci-skip]')
|
|
||||||
name: Run unit tests
|
name: Run unit tests
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
@ -165,11 +148,8 @@ jobs:
|
|||||||
install:
|
install:
|
||||||
needs:
|
needs:
|
||||||
- changes-install
|
- changes-install
|
||||||
- lint_success
|
- lint
|
||||||
if: |
|
if: "!contains(github.event.head_commit.message, '[ci-skip]') && needs.changes-install.outputs.detected == 'true'"
|
||||||
!contains(github.event.head_commit.message, '[ci-skip]')
|
|
||||||
&&
|
|
||||||
needs.changes-install.outputs.detected == 'true'
|
|
||||||
name: Install charts
|
name: Install charts
|
||||||
strategy:
|
strategy:
|
||||||
matrix: ${{ fromJson(needs.changes-install.outputs.matrix) }}
|
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
|
# Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7
|
||||||
install_success:
|
install_success:
|
||||||
needs:
|
needs:
|
||||||
- changes-install
|
- changes-install
|
||||||
- install
|
- install
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
|
38
.github/workflows/pre-commit-check.yaml
vendored
Normal file
38
.github/workflows/pre-commit-check.yaml
vendored
Normal file
@ -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
|
@ -7,15 +7,11 @@ repos:
|
|||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
- id: fix-byte-order-marker
|
- id: fix-byte-order-marker
|
||||||
- id: mixed-line-ending
|
- 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:
|
hooks:
|
||||||
- id: ct-lint
|
- id: remove-crlf
|
||||||
name: "Chart Test: Lint"
|
- id: remove-tabs
|
||||||
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
|
|
||||||
|
Loading…
Reference in New Issue
Block a user