Skip to content

Test

Test #1

Workflow file for this run

name: Test
on:
workflow_dispatch:
inputs:
run_lint:
description: Run helm lint
type: boolean
required: true
default: true
run_validate:
description: Run validate manifests
type: boolean
required: true
default: true
run_test:
description: Run integration/ test
type: boolean
required: true
default: true
run_ct:
description: Run chart testing
required: true
default: true
workflow_call:
inputs:
ref:
type: string
required: true
run_lint:
type: boolean
required: true
run_validate:
type: boolean
required: true
run_test:
type: boolean
required: true
run_ct:
type: boolean
required: true
helm_args:
type: string
required: false
load_artifact:
type: boolean
required: false
secrets:
VAULT_URL:
description: Vault URL
required: false
VAULT_ROLE:
description: Vault role
required: false
jobs:
check:
name: Get git reference
runs-on: ubuntu-latest
outputs:
ref: ${{ steps.get_git_ref.outputs.ref }}
steps:
- id: get_git_ref
run: |
if [ -n "${{ inputs.ref }}" ]; then
echo "ref=${{ inputs.ref }}" >> $GITHUB_OUTPUT
else
echo "ref=${{ github.ref_name }}" >> $GITHUB_OUTPUT
fi
lint:
name: Helm lint
if: ${{ inputs.run_lint }}
runs-on: ubuntu-latest
needs: check
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.check.outputs.ref }}
- name: Helm lint
run: |
helm version
helm lint helm/. --debug
validate:
name: Validate manifests
if: ${{ inputs.run_validate }}
env:
KUBEVAL_SCHEMA_LOCATION: 'https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/'
needs: check
runs-on: ubuntu-latest
strategy:
matrix:
kubeVersion:
- 1.19.16
- 1.20.15
- 1.21.14
- 1.22.13
- 1.23.9
- 1.24.4
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.check.outputs.ref }}
- name: Helm template
run: helm template helm/. > result-${{ matrix.kubeVersion }}.yaml --kube-version ${{ matrix.kubeVersion }} --debug
- name: Kubeval
uses: instrumenta/kubeval-action@master
with:
files: result-${{ matrix.kubeVersion }}.yaml
version: ${{ matrix.kubeVersion }}
ignore_missing_schemas: false
test:
name: Integration test
runs-on: ${{ matrix.RUNNER }}
if: ${{ inputs.run_test }}
needs: check
strategy:
matrix:
kubeVersion:
- 1.19.16
- 1.20.15
- 1.21.14
- 1.22.15
- 1.23.13
- 1.24.7
- 1.25.3
PLATFORM: [ amd64 ]
RUNNER: [ self-hosted-amd64-1cpu ]
include:
- { kubeVersion: 1.19.16, PLATFORM: aarch64, RUNNER: self-hosted-arm64-1cpu }
- { kubeVersion: 1.25.3, PLATFORM: aarch64, RUNNER: self-hosted-arm64-1cpu }
steps:
- name: Import secrets
uses: hashicorp/vault-action@130d1f5f4fe645bb6c83e4225c04d64cfb62de6e # v2.5.0
id: secrets
with:
exportEnv: true
url: ${{ secrets.VAULT_URL }}
role: ${{ secrets.VAULT_ROLE }}
method: kubernetes
path: kubernetes-ci
secrets: kv-gitlab-ci/data/github/sidecar api_token
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.check.outputs.ref }}
- name: Create cluster
run: |
kind create cluster \
--config ${GITHUB_WORKSPACE}/helm/test/kind/kind.yaml \
--image kindest/node:v${{ matrix.kubeVersion }} \
--name kind \
--wait 240s
kubectl cluster-info
kubectl wait --for=condition=Ready pods --all --timeout=180s -n kube-system
echo "current-context:" $(kubectl config current-context)
- name: Restore artifact
if: ${{ inputs.load_artifact }}
uses: actions/download-artifact@v3
with:
name: docker-artifact
path: artifacts
- name: Load image
if: ${{ inputs.load_artifact }}
run: kind load image-archive artifacts/docker-image-${{ matrix.PLATFORM }}.tar
- name: Install Helm chart
run: |
unset KUBERNETES_SERVICE_HOST
helm install wallarm-sidecar ./helm -f helm/values.test.yaml \
--set config.wallarm.api.token=${API_TOKEN} \
--debug \
--timeout 5m0s \
--wait ${{ inputs.helm_args }}
kubectl wait --for=condition=Ready pods --all --timeout=5m0s
kubectl describe pod -l app.kubernetes.io/component=postanalytics
kubectl describe pod -l app.kubernetes.io/component=controller
- name: Deploy pytest
run: |
unset KUBERNETES_SERVICE_HOST
kubectl apply -f kind/docker/manifests/init/pytest.yaml
while [[ -z $(kubectl -n pytest get pods -o name) ]]; do
sleep 1
done
kubectl -n pytest wait pods --all --for=condition=Ready --timeout=60s
- name: Run test
run: |
unset KUBERNETES_SERVICE_HOST
POD_NAME=$(kubectl get pods -n pytest -o name | cut -d '/' -f 2)
kubectl -n pytest exec -t ${POD_NAME} -- pytest -n 6 helm/test
chart-testing:
name: Chart testing - install
runs-on: self-hosted-amd64-1cpu
needs: check
steps:
- name: Import secrets
uses: hashicorp/vault-action@130d1f5f4fe645bb6c83e4225c04d64cfb62de6e # v2.5.0
id: secrets
with:
exportEnv: true
url: ${{ secrets.VAULT_URL }}
role: ${{ secrets.VAULT_ROLE }}
method: kubernetes
path: kubernetes-ci
secrets: kv-gitlab-ci/data/github/sidecar api_token | WALLARM_API_TOKEN
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.check.outputs.ref }}
- name: Create cluster
run: |
kind create cluster --image kindest/node:v1.25.3
kubectl wait --for=condition=Ready pods --all --timeout=180s -n kube-system
- name: Restore artifact
if: ${{ inputs.load_artifact }}
uses: actions/download-artifact@v3
with:
name: docker-artifact
path: artifacts
- name: Load image
if: ${{ inputs.load_artifact }}
run: kind load image-archive artifacts/docker-image-amd64.tar
- name: Run test
env:
HELM_ARGS: ${{ inputs.helm_args }}
run: make ct-install