From ff715fc60ec4b0fb574f109f41d434d55c8b6f20 Mon Sep 17 00:00:00 2001 From: Tom Dohrmann Date: Fri, 6 Sep 2024 10:49:46 +0200 Subject: [PATCH] ci: run release tests on all platforms --- .github/workflows/release.yml | 28 ++++++++++++++++++++++------ e2e/release/release_test.go | 19 ++++++++++++------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 431b5b041e..8bcccb11c6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -349,7 +349,19 @@ jobs: commit: true test: - runs-on: ubuntu-22.04 + strategy: + matrix: + platform: + - name: AKS-CLH-SNP + runner: ubuntu-22.04 + self-hosted: false + - name: K3s-QEMU-SNP + runner: SNP + self-hosted: true + - name: K3s-QEMU-TDX + runner: TDX + self-hosted: true + runs-on: ${{ matrix.platform.name }} permissions: # Job needs content:write to see draft releases. contents: write @@ -357,7 +369,8 @@ jobs: needs: release steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - uses: ./.github/actions/setup_nix + - if: ${{ !matrix.platform.self-hosted }} + uses: ./.github/actions/setup_nix with: githubToken: ${{ secrets.GITHUB_TOKEN }} cachixToken: ${{ secrets.CACHIX_AUTH_TOKEN }} @@ -367,25 +380,28 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Login to Azure + - if: ${{ !matrix.platform.self-hosted }} + name: Login to Azure uses: azure/login@6c251865b4e6290e7b78be643ea2d005bc51f69a # v2.1.1 with: creds: ${{ secrets.CONTRAST_CI_INFRA_AZURE }} - - uses: nicknovitski/nix-develop@a2060d116a50b36dfab02280af558e73ab52427d # v1.1.0 + - if: ${{ !matrix.platform.self-hosted }} + uses: nicknovitski/nix-develop@a2060d116a50b36dfab02280af558e73ab52427d # v1.1.0 - name: Create justfile.env run: | cat < justfile.env container_registry=${{ env.container_registry }} azure_resource_group=${{ env.azure_resource_group }} EOF - - name: Get credentials for CI cluster + - if: ${{ !matrix.platform.self-hosted }} + name: Get credentials for CI cluster run: | just get-credentials - name: E2E Test env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - nix shell -L .#contrast.e2e --command release.test -test.v --tag ${{ inputs.version }} + nix shell -L .#contrast.e2e --command release.test -test.v --tag ${{ inputs.version }} --platform ${{ matrix.platform.name }} create-github-stuff: name: Create backport label and milestone diff --git a/e2e/release/release_test.go b/e2e/release/release_test.go index 48bbc762f3..cf73fb3fe4 100644 --- a/e2e/release/release_test.go +++ b/e2e/release/release_test.go @@ -10,6 +10,7 @@ import ( "crypto/tls" "crypto/x509" "flag" + "fmt" "io" "net" "net/http" @@ -17,6 +18,7 @@ import ( "os/exec" "path" "path/filepath" + "strings" "testing" "time" @@ -33,10 +35,11 @@ const ( ) var ( - owner = flag.String("owner", "edgelesssys", "Github repository owner") - repo = flag.String("repo", "contrast", "Github repository") - tag = flag.String("tag", "", "tag name of the release to download") - keep = flag.Bool("keep", false, "don't delete test resources and deployment") + owner = flag.String("owner", "edgelesssys", "Github repository owner") + repo = flag.String("repo", "contrast", "Github repository") + tag = flag.String("tag", "", "tag name of the release to download") + keep = flag.Bool("keep", false, "don't delete test resources and deployment") + platformStr = flag.String("platform", "", "Deployment platform") ) // TestRelease downloads a release from Github, sets up the coordinator, installs the demo @@ -45,6 +48,8 @@ func TestRelease(t *testing.T) { ctx := context.Background() k := kubeclient.NewForTest(t) + lowerPlatformStr := strings.ToLower(*platformStr) + dir := fetchRelease(ctx, t) contrast := &contrast{dir} @@ -90,7 +95,7 @@ func TestRelease(t *testing.T) { ctx, cancel := context.WithTimeout(ctx, 5*time.Minute) defer cancel() - yaml, err := os.ReadFile(path.Join(dir, "runtime-aks-clh-snp.yml")) + yaml, err := os.ReadFile(path.Join(dir, fmt.Sprintf("runtime-%s.yml", lowerPlatformStr))) require.NoError(err) resources, err := kubeapi.UnmarshalUnstructuredK8SResource(yaml) require.NoError(err) @@ -105,7 +110,7 @@ func TestRelease(t *testing.T) { ctx, cancel := context.WithTimeout(ctx, 5*time.Minute) defer cancel() - yaml, err := os.ReadFile(path.Join(dir, "coordinator-aks-clh-snp.yml")) + yaml, err := os.ReadFile(path.Join(dir, fmt.Sprintf("coordinator-%s.yml", lowerPlatformStr))) require.NoError(err) resources, err := kubeapi.UnmarshalUnstructuredK8SResource(yaml) require.NoError(err) @@ -138,7 +143,7 @@ func TestRelease(t *testing.T) { } }), "unpacking needs to succeed for subsequent tests to run") - contrast.Run(ctx, t, 2*time.Minute, "generate", "--reference-values", "aks-clh-snp", "deployment/") + contrast.Run(ctx, t, 2*time.Minute, "generate", "--reference-values", *platformStr, "deployment/") contrast.Run(ctx, t, 1*time.Minute, "set", "-c", coordinatorIP+":1313", "deployment/") contrast.Run(ctx, t, 1*time.Minute, "verify", "-c", coordinatorIP+":1313")