From a4e91c6ba8ab1040900c6fcdde1da5569ceb739e Mon Sep 17 00:00:00 2001 From: kfox1111 Date: Tue, 20 Feb 2024 08:16:16 -0800 Subject: [PATCH] Add support for integration tests in the tests/integration dir (#253) * Add support for integration tests in the tests/integration dir Signed-off-by: Kevin Fox * Fix split issue and typo Signed-off-by: Kevin Fox --------- Signed-off-by: Kevin Fox --- .github/workflows/helm-chart-ci-ignore.yaml | 31 ++++++++++- .github/workflows/helm-chart-ci.yaml | 59 ++++++++++++++++++++- 2 files changed, 86 insertions(+), 4 deletions(-) diff --git a/.github/workflows/helm-chart-ci-ignore.yaml b/.github/workflows/helm-chart-ci-ignore.yaml index 2a098e3..1ba17fd 100644 --- a/.github/workflows/helm-chart-ci-ignore.yaml +++ b/.github/workflows/helm-chart-ci-ignore.yaml @@ -45,7 +45,7 @@ jobs: - name: Checkout uses: actions/checkout@v4.1.1 - - id: set-matrix + - id: set-matrix-example name: Collect all examples run: | examples="$(find examples -maxdepth 2 -type f -name run-tests.sh | xargs -I % dirname %)" @@ -53,8 +53,17 @@ jobs: echo "${examples_json}" echo "examples=$examples_json" >>"$GITHUB_OUTPUT" + - id: set-matrix-integration + name: Collect all integration tests + run: | + integrationtests="$(find tests/integration -maxdepth 2 -type f -name run-tests.sh | xargs -I % dirname %)" + integrationtests_json="$(echo "$integrationtests" | jq -c --slurp --raw-input 'split("\n") | map(select(. != ""))')" + echo "${integrationtests_json}" + echo "integrationtests=$integrationtests_json" >>"$GITHUB_OUTPUT" + outputs: - examples: ${{ steps.set-matrix.outputs.examples }} + examples: ${{ steps.set-matrix-example.outputs.examples }} + integrationtests: ${{ steps.set-matrix-integration.outputs.integrationtests }} example-test: runs-on: ubuntu-22.04 @@ -74,6 +83,24 @@ jobs: steps: - run: 'echo "Skipping example-test"' + integration-test: + runs-on: ubuntu-22.04 + + needs: + - build-matrix + + strategy: + matrix: + k8s: + - v1.28.0 + - v1.27.3 + - v1.26.6 + example: + - ${{ fromJson(needs.build-matrix.outputs.integrationtests) }} + + steps: + - run: 'echo "Skipping integration-test"' + upgrade-test: runs-on: ubuntu-22.04 diff --git a/.github/workflows/helm-chart-ci.yaml b/.github/workflows/helm-chart-ci.yaml index 6865ce2..c8f900f 100644 --- a/.github/workflows/helm-chart-ci.yaml +++ b/.github/workflows/helm-chart-ci.yaml @@ -187,7 +187,7 @@ jobs: - name: Checkout uses: actions/checkout@v4.1.1 - - id: set-matrix + - id: set-matrix-example name: Collect all examples run: | examples="$(find examples -maxdepth 2 -type f -name run-tests.sh | xargs -I % dirname %)" @@ -195,8 +195,17 @@ jobs: echo "${examples_json}" echo "examples=$examples_json" >>"$GITHUB_OUTPUT" + - id: set-matrix-integration + name: Collect all integration tests + run: | + integrationtests="$(find tests/integration -maxdepth 2 -type f -name run-tests.sh | xargs -I % dirname %)" + integrationtests_json="$(echo "$integrationtests" | jq -c --slurp --raw-input 'split("\n") | map(select(. != ""))')" + echo "${integrationtests_json}" + echo "integrationtests=$integrationtests_json" >>"$GITHUB_OUTPUT" + outputs: - examples: ${{ steps.set-matrix.outputs.examples }} + examples: ${{ steps.set-matrix-example.outputs.examples }} + integrationtests: ${{ steps.set-matrix-integration.outputs.integrationtests }} example-test: runs-on: ubuntu-22.04 @@ -249,6 +258,52 @@ jobs: fi ${{ matrix.example }}/run-tests.sh + integration-test: + runs-on: ubuntu-22.04 + + needs: + - lint-chart + - build-matrix + + strategy: + fail-fast: false + matrix: + k8s: + - v1.28.0 + - v1.27.3 + - v1.26.6 + integrationtest: + - ${{ fromJson(needs.build-matrix.outputs.integrationtests) }} + + steps: + - name: Checkout + uses: actions/checkout@v4.1.1 + + - name: Set up Helm + uses: azure/setup-helm@v3.5 + with: + version: ${{ env.HELM_VERSION }} + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Create kind cluster + uses: helm/kind-action@v1.8.0 + # Only build a kind cluster if there are chart changes to test. + with: + version: ${{ env.KIND_VERSION }} + node_image: kindest/node:v1.26.4 + config: .github/kind/conf/kind-config.yaml + verbosity: 1 + + - name: Install and test integration + run: | + kubectl create namespace spire-server + helm install -n spire-server spire-crds charts/spire-crds + ${{ matrix.integrationtest }}/run-tests.sh + upgrade-test: runs-on: ubuntu-22.04