Skip to content

Commit

Permalink
ci: run release tests on all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
Freax13 committed Sep 6, 2024
1 parent eecdb63 commit eb4fbc8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
28 changes: 22 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,28 @@ 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
packages: read
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 }}
Expand All @@ -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 <<EOF > 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
Expand Down
19 changes: 12 additions & 7 deletions e2e/release/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import (
"crypto/tls"
"crypto/x509"
"flag"
"fmt"
"io"
"net"
"net/http"
"os"
"os/exec"
"path"
"path/filepath"
"strings"
"testing"
"time"

Expand All @@ -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
Expand All @@ -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}
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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")

Expand Down

0 comments on commit eb4fbc8

Please sign in to comment.