diff --git a/.github/configs/ct.yaml b/.github/configs/ct.yaml new file mode 100644 index 00000000..ae7173a4 --- /dev/null +++ b/.github/configs/ct.yaml @@ -0,0 +1,2 @@ +check-version-increment: false +validate-maintainers: false diff --git a/.github/configs/lintconf.yaml b/.github/configs/lintconf.yaml new file mode 100644 index 00000000..7bde3b9a --- /dev/null +++ b/.github/configs/lintconf.yaml @@ -0,0 +1,26 @@ +--- +rules: + braces: + level: error + brackets: + level: error + colons: + level: error + commas: + level: error + comments: + level: error + document-end: disable + document-start: disable # No --- to start a file + hyphens: + level: warning + indentation: + level: warning + key-duplicates: enable + line-length: disable # Lines can be any length + new-line-at-end-of-file: enable + new-lines: + type: unix + trailing-spaces: enable + truthy: + level: warning diff --git a/.github/workflows/helm-lint.yaml b/.github/workflows/helm-lint.yaml new file mode 100644 index 00000000..e2a95bed --- /dev/null +++ b/.github/workflows/helm-lint.yaml @@ -0,0 +1,60 @@ +name: Lint and Test Charts + +on: + workflow_call: + inputs: + chartDirs: + description: "The root dir or dirs (separated with commas)" + type: string + required: false + default: "." + +jobs: + lint-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Checkout Shared Workflows repository + uses: actions/checkout@v4 + with: + repository: MapColonies/shared-workflows + path: shared-workflows + token: ${{ secrets.GH_PAT }} + + - name: Set up Helm + uses: azure/setup-helm@v4.2.0 + with: + version: v3.16.3 + + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + check-latest: true + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.6.1 + + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(ct list-changed --chart-dirs ${{ inputs.chartDirs }} --target-branch ${{ github.event.repository.default_branch }} --config shared-workflows/.github/configs/ct.yaml) + echo "changed=$changed" + if [[ -n "$changed" ]]; then + echo "changed=true" >> "$GITHUB_OUTPUT" + fi + + - name: Run chart-testing (lint) + if: steps.list-changed.outputs.changed == 'true' + run: ct lint --chart-dirs ${{ inputs.chartDirs }} --target-branch ${{ github.event.repository.default_branch }} --config shared-workflows/.github/configs/ct.yaml --lint-conf shared-workflows/.github/configs/lintconf.yaml + + - name: Create kind cluster + if: steps.list-changed.outputs.changed == 'true' + uses: helm/kind-action@v1.10.0 + + - name: Run chart-testing (install) + if: steps.list-changed.outputs.changed == 'true' + run: ct install --chart-dirs ${{ inputs.chartDirs }} --target-branch ${{ github.event.repository.default_branch }} --config shared-workflows/.github/configs/ct.yaml diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 601bc361..049c0fcf 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -18,8 +18,25 @@ on: type: boolean required: false default: false + enableHelmLint: + description: "Flag to enable helm lint" + type: boolean + required: false + default: true + chartDirs: + description: "The root dir or dirs (separated with commas)" + type: string + required: false + default: "." jobs: + helm-lint: + if: ${{ inputs.enableHelmLint == true }} + uses: MapColonies/shared-workflows/.github/workflows/helm-lint.yaml@master + secrets: inherit + with: + chartDirs: ${{ inputs.chartDirs }} + eslint: name: Run eslint runs-on: ubuntu-latest