Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, `ct lint` uses it instead of the default `lintconf.yaml` (default: none)

### Example Workflow

Expand Down
15 changes: 15 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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, ct lint uses it instead of the default lintconf.yaml."
required: false
default: ''
runs:
using: composite
steps:
Expand All @@ -40,3 +44,14 @@ runs:
--yamllint-version ${{ inputs.yamllint_version }} \
--yamale-version ${{ inputs.yamale_version }}
shell: bash
- if: inputs.lint_config != ''
env:
LINT_CONFIG: ${{ inputs.lint_config }}
run: |
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
8 changes: 8 additions & 0 deletions testdata/custom-lintconf.yaml
Original file line number Diff line number Diff line change
@@ -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