Files
ess-helm/.github/workflows/build-test.yml
T

102 lines
3.3 KiB
YAML

# Copyright 2024 New Vector Ltd
#
# SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
name: Helm Chart Building tests
on:
pull_request_target:
push:
branches:
- main
workflow_dispatch:
jobs:
# We build from source and commit all generated file changes so that we can see the impact in PRs
# We want to ensure that the commit of built changes does happen, so fail if building creates changes
# If this gets problematic we change to not committing the built schemas/values to git
no-changes-after-building:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: matrix-org/setup-python-poetry@gaelg/poetry-venv
with:
python-version: "3.x"
poetry-version: "1.8.5"
- name: Load poetry path
run: |
echo "$(poetry env info -p)/bin" >> "${GITHUB_PATH}"
- name: Build and check for changes
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
# Ensure all JSON files are consistently formatted
for file in $(git ls-files | grep json); do yq -iP --indent 2 -o json '.' $file; done
# Rebuild the charts & test values files with from the current source
scripts/assemble_ci_values_files_from_fragments.sh
version=$(yq '.version' charts/matrix-stack/Chart.yaml)
scripts/assemble_helm_charts_from_fragments.sh
scripts/set_chart_version.sh "$version"
git diff --exit-code
helm-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up chart-testing
uses: helm/[email protected]
- name: Run chart-testing (lint)
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
bash scripts/ct-lint.sh --config ct.yaml
- name: Ensure we don't use the helm $ root token in .tpl files
shell: bash
run: |
find . -type f -name '*.tpl' -exec grep -E '\{\{[^}]*\$[^a-zA-Z0-9_][^}]*\}\}' {} + && {
echo 'Error: $ is used in a .tpl files, but helm passes the local context to the special variable $ in included templates.'; exit 1
} || echo "OK."
- uses: matrix-org/setup-python-poetry@gaelg/poetry-venv
with:
poetry-version: "1.8.5"
python-version: "3.x"
- name: Load poetry path
run: |
echo "$(poetry env info -p)/bin" >> "${GITHUB_PATH}"
- name: Set up Kubeconform
uses: bmuschko/setup-kubeconform@v1
- name: Run kubeconform
run: |
for values in charts/matrix-stack/ci/*values.yaml; do
echo "Testing matrix-stack with $values";
helm template -f "$values" charts/matrix-stack | kubeconform -summary
done
- name: Run checkov
run: |
checkov --version
export HELM_NAMESPACE=ess
for checkov_values in charts/matrix-stack/ci/*checkov*values.yaml; do
echo "Testing matrix-stack with $checkov_values";
checkov -d "charts/matrix-stack" --framework helm --var-file "$checkov_values" --quiet
done
- name: Run our manifest tests
run: poetry run pytest -vv tests/manifests