Skip to content

Test

Test #3

Workflow file for this run

name: Test
on:
workflow_dispatch:
inputs:
run_smoke:
description: Run smoke tests
type: boolean
required: true
default: true
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
run_smoke:
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.17
- 1.23.9
- 1.24.9
- 1.25.16
- 1.26.15
- 1.27.13
- 1.28.9
- 1.29.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: Installation test
runs-on: self-hosted-amd64-1cpu
if: ${{ inputs.run_test }}
needs: check
env:
ARCH: amd64
strategy:
matrix:
kubeVersion:
- 1.19.16
- 1.20.15
- 1.21.14
- 1.22.17
- 1.23.17
- 1.24.17
- 1.25.16
- 1.26.14
- 1.27.11
- 1.28.7
- 1.29.2
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: Load cache
if: ${{ inputs.load_artifact }}
uses: actions/download-artifact@v4
with:
name: sidecar-${{ env.ARCH }}.tar
- name: Load image
if: ${{ inputs.load_artifact }}
run: kind load image-archive sidecar-${{ env.ARCH }}.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 && exit 1)
- 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.28.7
kubectl wait --for=condition=Ready pods --all --timeout=180s -n kube-system
- name: Load cache
if: ${{ inputs.load_artifact }}
uses: actions/download-artifact@v4
with:
name: sidecar-amd64.tar
- name: Load image
if: ${{ inputs.load_artifact }}
run: kind load image-archive sidecar-amd64.tar
- name: Run test
env:
HELM_ARGS: ${{ inputs.helm_args }}
run: make ct-install
smoke-test:
name: Smoke
runs-on: ${{ matrix.RUNNER }}
if: ${{ inputs.run_smoke }}
needs: build

Check failure on line 264 in .github/workflows/test.yaml

View workflow run for this annotation

GitHub Actions / Test

Invalid workflow file

The workflow is not valid. .github/workflows/test.yaml (Line: 264, Col: 12): Job 'smoke-test' depends on unknown job 'build'.
strategy:
fail-fast: false
matrix:
k8s: [ 1.28.7 ]
ARCH: [ amd64, arm64 ]
INJECTION_STRATEGY: [ single, split ]
include:
- ARCH: amd64
RUNNER: self-hosted-amd64-2cpu
- ARCH: arm64
RUNNER: self-hosted-arm64-2cpu
env:
## US preset
env_code: ingress-us1
CLIENT_ID: 7119
## EU preset
# env_code: ingress
# CLIENT_ID: 5
KIND_CLUSTER_NAME: kind-${{ matrix.k8s }}
KUBECONFIG: $HOME/.kube/kind-config-${{ matrix.k8s }}
steps:
- name: Import secrets
uses: hashicorp/vault-action@d1720f055e0635fd932a1d2a48f87a666a57906c # v3.0.0
id: secrets
with:
exportEnv: false
url: ${{ secrets.VAULT_URL }}
role: ${{ secrets.VAULT_ROLE }}
method: kubernetes
path: kubernetes-ci
secrets: |
kv-gitlab-ci/data/github/${{ env.env_code }} api_token ;
kv-gitlab-ci/data/github/${{ env.env_code }} api_host ;
kv-gitlab-ci/data/github/${{ env.env_code }} api_preset ;
kv-gitlab-ci/data/github/${{ env.env_code }} user_token ;
kv-gitlab-ci/data/github/${{ env.env_code }} webhook_uuid ;
kv-gitlab-ci/data/github/${{ env.env_code }} webhook_api_key ;
kv-gitlab-ci/data/github/${{ env.env_code }} allure_server_token ;
kv-gitlab-ci/data/github/shared/smoke-tests-registry-creds token_name ;
kv-gitlab-ci/data/github/shared/smoke-tests-registry-creds token_secret ;
- name: Checkout
uses: actions/checkout@v4
- name: Load cache
uses: actions/download-artifact@v4
with:
name: sidecar-${{ matrix.ARCH }}.tar
- name: Load images
run: docker load -i sidecar-${{ matrix.ARCH }}.tar
- name: Create cluster
run: kind create cluster --image=kindest/node:v${{ matrix.k8s }}
- name: Run smoke tests
env:
SKIP_CLUSTER_CREATION: true
SKIP_IMAGE_CREATION: true
WALLARM_API_TOKEN: ${{ steps.secrets.outputs.api_token }}
WALLARM_API_HOST: ${{ steps.secrets.outputs.api_host }}
WALLARM_API_PRESET: ${{ steps.secrets.outputs.api_preset }}
USER_TOKEN: ${{ steps.secrets.outputs.user_token }}
SMOKE_REGISTRY_TOKEN: ${{ steps.secrets.outputs.token_name }}
SMOKE_REGISTRY_SECRET: ${{ steps.secrets.outputs.token_secret }}
WEBHOOK_API_KEY: ${{ steps.secrets.outputs.webhook_api_key }}
WEBHOOK_UUID: ${{ steps.secrets.outputs.webhook_uuid }}
ALLURE_UPLOAD_REPORT: true
ALLURE_GENERATE_REPORT: true
ALLURE_TOKEN: ${{ steps.secrets.outputs.allure_server_token }}
ALLURE_ENVIRONMENT_K8S: ${{ matrix.k8s }}
ALLURE_ENVIRONMENT_ARCH: ${{ matrix.ARCH }}
run: |
make kind-smoke-test TAG=${GITHUB_SHA}