From ea528a80ceab446674df1470cc0b703f1c44aa78 Mon Sep 17 00:00:00 2001 From: Bisman-Singh Date: Sat, 25 Apr 2026 17:47:57 +0530 Subject: [PATCH 1/3] feat: add lint_config input for custom yamllint rules Fixes #176 Signed-off-by: Bisman-Singh --- README.md | 1 + action.yml | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index adf1de2..6bdb24f 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ For more information on inputs, see the [API Documentation](https://developer.gi - `version`: The chart-testing version to install (default: `3.14.0`) - `yamllint_version`: The `yamllint` version to install (default: `1.33.0`) - `yamale_version`: The `yamale` version to install (default: `6.0.0`) +- `lint_config`: Path to a custom yamllint config file. If set, it replaces the default `lintconf.yaml` used by `ct lint` (default: none) ### Example Workflow diff --git a/action.yml b/action.yml index 9c003d2..706e956 100644 --- a/action.yml +++ b/action.yml @@ -25,6 +25,10 @@ inputs: description: "GitHub token for authenticating with the GitHub API (default: github.token)" required: false default: ${{ github.token }} + lint_config: + description: "Path to a custom yamllint config file. If set, it replaces the default lintconf.yaml used by ct lint." + required: false + default: '' runs: using: composite steps: @@ -40,3 +44,8 @@ runs: --yamllint-version ${{ inputs.yamllint_version }} \ --yamale-version ${{ inputs.yamale_version }} shell: bash + - if: inputs.lint_config != '' + run: | + cp "${{ inputs.lint_config }}" "${CT_CONFIG_DIR}/lintconf.yaml" + echo "Custom yamllint config applied to ${CT_CONFIG_DIR}/lintconf.yaml" + shell: bash From c581b55c72dbf25ee4fda884bc2f1a64be166a3c Mon Sep 17 00:00:00 2001 From: Bisman-Singh Date: Thu, 17 Sep 2026 21:15:48 +0530 Subject: [PATCH 2/3] fix: pass lint_config through CT_LINT_CONF instead of the tool cache Signed-off-by: Bisman-Singh --- README.md | 2 +- action.yml | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6bdb24f..ec0156f 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ For more information on inputs, see the [API Documentation](https://developer.gi - `version`: The chart-testing version to install (default: `3.14.0`) - `yamllint_version`: The `yamllint` version to install (default: `1.33.0`) - `yamale_version`: The `yamale` version to install (default: `6.0.0`) -- `lint_config`: Path to a custom yamllint config file. If set, it replaces the default `lintconf.yaml` used by `ct lint` (default: none) +- `lint_config`: Path to a custom yamllint config file. If set, `ct lint` uses it instead of the default `lintconf.yaml` (default: none) ### Example Workflow diff --git a/action.yml b/action.yml index 706e956..e0ae5d6 100644 --- a/action.yml +++ b/action.yml @@ -26,7 +26,7 @@ inputs: required: false default: ${{ github.token }} lint_config: - description: "Path to a custom yamllint config file. If set, it replaces the default lintconf.yaml used by ct lint." + description: "Path to a custom yamllint config file. If set, ct lint uses it instead of the default lintconf.yaml." required: false default: '' runs: @@ -45,7 +45,13 @@ runs: --yamale-version ${{ inputs.yamale_version }} shell: bash - if: inputs.lint_config != '' + env: + LINT_CONFIG: ${{ inputs.lint_config }} run: | - cp "${{ inputs.lint_config }}" "${CT_CONFIG_DIR}/lintconf.yaml" - echo "Custom yamllint config applied to ${CT_CONFIG_DIR}/lintconf.yaml" + if [[ ! -f "${LINT_CONFIG}" ]]; then + echo "::error::lint_config file not found: ${LINT_CONFIG}" + exit 1 + fi + echo "CT_LINT_CONF=$(realpath "${LINT_CONFIG}")" >> "${GITHUB_ENV}" + echo "Using custom yamllint config: ${LINT_CONFIG}" shell: bash From 133d247c19f85f4fd25aef0f50f62cfbd5544761 Mon Sep 17 00:00:00 2001 From: Bisman-Singh Date: Thu, 17 Sep 2026 22:16:19 +0530 Subject: [PATCH 3/3] test: add a CI job for the lint_config input Signed-off-by: Bisman-Singh --- .github/workflows/test-action.yml | 62 +++++++++++++++++++++++++++++++ testdata/custom-lintconf.yaml | 8 ++++ 2 files changed, 70 insertions(+) create mode 100644 testdata/custom-lintconf.yaml diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index 623653b..1e1c554 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -111,3 +111,65 @@ jobs: - name: Run chart-testing (install) if: steps.list-changed.outputs.changed == 'true' run: ct install --chart-dirs=testdata --target-branch ${{ github.event.repository.default_branch }} + + test_ct_action_with_lint_config: + runs-on: ubuntu-latest + + name: run action with a custom yamllint config + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Set up Helm + uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1 + with: + version: v3.17.0 + + - name: Install chart-testing + uses: ./ + + - name: Run chart-testing (lint) with the default config + run: ct lint --charts testdata/simple-deployment --check-version-increment=false --validate-maintainers=false + + - name: Install chart-testing with lint_config + uses: ./ + with: + lint_config: testdata/custom-lintconf.yaml + + - name: Check CT_LINT_CONF + run: | + if [[ "${CT_LINT_CONF}" != "$(realpath testdata/custom-lintconf.yaml)" ]]; then + echo "CT_LINT_CONF should point to testdata/custom-lintconf.yaml, got '${CT_LINT_CONF}'" + exit 1 + fi + shell: bash + + - name: Run chart-testing (lint) with the custom config + run: | + log="${RUNNER_TEMP}/ct-lint.log" + if ct lint --charts testdata/simple-deployment --check-version-increment=false --validate-maintainers=false > "${log}" 2>&1; then + cat "${log}" + echo 'ct lint should fail on the document-start rule from lint_config' + exit 1 + fi + if ! grep -q 'missing document start' "${log}"; then + cat "${log}" + echo 'ct lint failed, but not because of lint_config' + exit 1 + fi + echo 'ct lint failed on the document-start rule from lint_config, as expected' + shell: bash + + - name: Install chart-testing with a missing lint_config + id: missing_lint_config + continue-on-error: true + uses: ./ + with: + lint_config: testdata/does-not-exist.yaml + + - name: Check the missing lint_config failed + run: | + if [[ '${{ steps.missing_lint_config.outcome }}' != 'failure' ]]; then + echo 'a missing lint_config should fail the action' + exit 1 + fi + shell: bash diff --git a/testdata/custom-lintconf.yaml b/testdata/custom-lintconf.yaml new file mode 100644 index 0000000..d91e227 --- /dev/null +++ b/testdata/custom-lintconf.yaml @@ -0,0 +1,8 @@ +--- +# Used by the lint_config test in .github/workflows/test-action.yml. +# The default ct config disables document-start, and +# simple-deployment/Chart.yaml has no "---", so ct lint only fails +# when this file is the one in use. +rules: + document-start: + present: true