diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 93353ed..6c14dcd 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,3 +6,8 @@ updates: schedule: interval: "daily" open-pull-requests-limit: 10 + groups: + actions: + update-types: + - "minor" + - "patch" diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index d29fbed..c4bf023 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -9,7 +9,7 @@ jobs: name: Install chart-testing and test presence in path steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Install chart-testing uses: ./ - name: Check install! @@ -17,8 +17,8 @@ jobs: ct version CT_VERSION_OUTPUT=$(ct version 2>&1 /dev/null) ACTUAL_VERSION=$(echo "$CT_VERSION_OUTPUT" | grep Version | rev | cut -d ' ' -f1 | rev) - if [[ $ACTUAL_VERSION != 'v3.10.0' ]]; then - echo 'should be v3.10.0' + if [[ $ACTUAL_VERSION != 'v3.12.0' ]]; then + echo 'should be v3.12.0' exit 1 else exit 0 @@ -38,7 +38,7 @@ jobs: name: Install Custom chart-testing and test presence in path steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Install chart-testing uses: ./ with: @@ -66,12 +66,60 @@ jobs: exit 0 fi + test_ct_action_with_helm: + runs-on: ubuntu-latest + + name: run action to test a helm chart + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0 + with: + version: v3.17.0 + + - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 + with: + python-version: '3.x' + check-latest: true + + - name: Install chart-testing + uses: ./ + + - run: | + sed -i "s/version: .*/version: 2.0.0/" testdata/simple-deployment/Chart.yaml + cat testdata/simple-deployment/Chart.yaml + + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(ct list-changed --chart-dirs=testdata --target-branch ${{ github.event.repository.default_branch }}) + 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=testdata --target-branch ${{ github.event.repository.default_branch }} + + - 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=testdata --target-branch ${{ github.event.repository.default_branch }} + test_ct_action_noverify: runs-on: ubuntu-latest name: Install chart-testing without verifiing blob and test presence in path steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 - name: Install chart-testing uses: ./ with: @@ -95,4 +143,4 @@ jobs: exit 1 else exit 0 - fi + fi \ No newline at end of file diff --git a/README.md b/README.md index 55d92f9..1272521 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ A GitHub Action for installing the [helm/chart-testing](https://github.com/helm/ For more information on inputs, see the [API Documentation](https://developer.github.com/v3/repos/releases/#input) -- `version`: The chart-testing version to install (default: `3.9.0`) -- `yamllint_version`: The chart-testing version to install (default: `1.27.1`) -- `yamale_version`: The chart-testing version to install (default: `3.0.4`) +- `version`: The chart-testing version to install (default: `3.12.0`) +- `yamllint_version`: The `yamllint` version to install (default: `1.33.0`) +- `yamale_version`: The `yamale` version to install (default: `4.0.4`) ### Example Workflow @@ -42,17 +42,17 @@ jobs: fetch-depth: 0 - name: Set up Helm - uses: azure/setup-helm@v3 + uses: azure/setup-helm@v4.2.0 with: - version: v3.12.1 + version: v3.17.0 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5.3.0 with: - python-version: '3.10' + python-version: '3.x' check-latest: true - name: Set up chart-testing - uses: helm/chart-testing-action@v2.6.0 + uses: helm/chart-testing-action@v2.7.0 - name: Run chart-testing (list-changed) id: list-changed @@ -68,7 +68,7 @@ jobs: - name: Create kind cluster if: steps.list-changed.outputs.changed == 'true' - uses: helm/kind-action@v1.8.0 + uses: helm/kind-action@v1.12.0 - name: Run chart-testing (install) if: steps.list-changed.outputs.changed == 'true' diff --git a/action.yml b/action.yml index 6ef951f..228721f 100644 --- a/action.yml +++ b/action.yml @@ -10,21 +10,21 @@ inputs: required: false default: 'true' version: - description: "The chart-testing version to install (default: 3.10.0)" + description: "The chart-testing version to install (default: 3.12.0)" required: false - default: '3.10.0' + default: '3.12.0' yamllint_version: description: "The yamllint version to install (default: 1.27.1)" required: false - default: '1.27.1' + default: '1.33.0' yamale_version: - description: "The yamale version to install (default: 3.0.4)" + description: "The yamale version to install (default: 4.0.4)" required: false - default: '3.0.4' + default: '4.0.4' runs: using: composite steps: - - uses: sigstore/cosign-installer@11086d25041f77fe8fe7b9ea4e48e3b9192b8f19 # v3.1.2 + - uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0 if: ${{ inputs.verify_blob != 'false' }} - run: | cd $GITHUB_ACTION_PATH \ diff --git a/ct.sh b/ct.sh index d186b92..f69a155 100755 --- a/ct.sh +++ b/ct.sh @@ -4,10 +4,10 @@ set -o errexit set -o nounset set -o pipefail -DEFAULT_CHART_TESTING_VERSION=3.10.0 +DEFAULT_CHART_TESTING_VERSION=3.12.0 DEFAULT_VERIFY_BLOB=true -DEFAULT_YAMLLINT_VERSION=1.27.1 -DEFAULT_YAMALE_VERSION=3.0.4 +DEFAULT_YAMLLINT_VERSION=1.33.0 +DEFAULT_YAMALE_VERSION=4.0.4 show_help() { cat << EOF diff --git a/testdata/simple-deployment/Chart.yaml b/testdata/simple-deployment/Chart.yaml new file mode 100644 index 0000000..8ac9244 --- /dev/null +++ b/testdata/simple-deployment/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: nginx +version: 0.1.0 +maintainers: + - name: cpanato + - name: davidkarlsen diff --git a/testdata/simple-deployment/README.md b/testdata/simple-deployment/README.md new file mode 100644 index 0000000..280f67f --- /dev/null +++ b/testdata/simple-deployment/README.md @@ -0,0 +1,4 @@ +Simple chart with a Deployment. + +The integration test will install first simple-deployment and then try to upgrade +to simple-deployment-different-selector failing as expected diff --git a/testdata/simple-deployment/templates/_helpers.tpl b/testdata/simple-deployment/templates/_helpers.tpl new file mode 100644 index 0000000..165d01e --- /dev/null +++ b/testdata/simple-deployment/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "nginx.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "nginx.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "nginx.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/testdata/simple-deployment/templates/deployment.yaml b/testdata/simple-deployment/templates/deployment.yaml new file mode 100644 index 0000000..ac64e0d --- /dev/null +++ b/testdata/simple-deployment/templates/deployment.yaml @@ -0,0 +1,29 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "nginx.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "nginx.name" . }} + helm.sh/chart: {{ include "nginx.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/name: {{ include "nginx.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "nginx.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP diff --git a/testdata/simple-deployment/values.yaml b/testdata/simple-deployment/values.yaml new file mode 100644 index 0000000..cefd3a0 --- /dev/null +++ b/testdata/simple-deployment/values.yaml @@ -0,0 +1,11 @@ +# Default values for nginx. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +image: + repository: nginx + tag: stable + pullPolicy: IfNotPresent + +nameOverride: "" +fullnameOverride: ""