Fix platform test #352
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Integration Test | |
# yamllint disable-line rule:truthy | |
on: | |
push: | |
branches: ["main"] | |
paths: | |
- 'charts/**' | |
- '!charts/k8s-monitoring-v1/**' | |
pull_request: | |
paths: | |
- 'charts/**' | |
- '!charts/k8s-monitoring-v1/**' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
list-tests: | |
name: List tests | |
runs-on: ubuntu-latest | |
outputs: | |
tests: ${{ steps.list_tests.outputs.tests }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: List tests | |
id: list_tests | |
run: | | |
tests=$(ls charts/k8s-monitoring/tests/integration) | |
echo "Tests: ${tests}" | |
echo "tests=$(echo "${tests}" | jq --raw-input --slurp --compact-output 'split("\n") | map(select(. != ""))')" >> "${GITHUB_OUTPUT}" | |
run-tests: | |
name: Integration Test | |
needs: list-tests | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
test: ${{ fromJson(needs.list-tests.outputs.tests) }} | |
fail-fast: false | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Helm | |
uses: azure/setup-helm@v4 | |
- name: Check for cluster config | |
id: check-cluster-config | |
run: | | |
testManifest="charts/k8s-monitoring/tests/integration/${{ matrix.test }}/test-manifest.yaml" | |
clusterName="$(yq -r ".cluster.name // \"test-cluster\"" "${testManifest}")" | |
clusterConfig="$(yq -r ".cluster.config // \"\"" "${testManifest}")" | |
if [ -f "charts/k8s-monitoring/tests/integration/${{ matrix.test }}/${clusterConfig}" ]; then | |
echo "has-cluster-config=true" >> "${GITHUB_OUTPUT}" | |
echo "cluster-config=charts/k8s-monitoring/tests/integration/${{ matrix.test }}/${clusterConfig}" >> "${GITHUB_OUTPUT}" | |
else | |
echo "has-cluster-config=false" >> "${GITHUB_OUTPUT}" | |
fi | |
echo "cluster-name=${clusterName}" >> "${GITHUB_OUTPUT}" | |
- name: Create kind cluster | |
if: ${{ steps.check-cluster-config.outputs.has-cluster-config == 'false' }} | |
uses: helm/kind-action@v1 | |
with: | |
cluster_name: ${{ steps.check-cluster-config.outputs.cluster-name }} | |
ignore_failed_clean: true | |
- name: Create kind cluster with special config | |
if: ${{ steps.check-cluster-config.outputs.has-cluster-config == 'true' }} | |
uses: helm/kind-action@v1 | |
with: | |
cluster_name: ${{ steps.check-cluster-config.outputs.cluster-name }} | |
config: ${{ steps.check-cluster-config.outputs.cluster-config }} | |
ignore_failed_clean: true | |
- name: Run test | |
env: | |
HEADLESS: "true" | |
run: ./scripts/run-integration-test.sh "charts/k8s-monitoring/tests/integration/${{ matrix.test }}" |