Skip to content

Commit

Permalink
add e2e to github workflow
Browse files Browse the repository at this point in the history
+ adds e2e make target for running e2es
+ updates return err to include output for
better debugging experience
+ add workflow for checking e2e on PRs to main

Signed-off-by: Michelle Dhanani <[email protected]>
  • Loading branch information
michelleN committed Mar 8, 2024
1 parent 6af8461 commit a221754
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: e2e

on:
pull_request:
branches: [main]

jobs:
e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.22.x"
cache: true
- name: run e2e
run: go test ./e2e -v
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,7 @@ $(ENVTEST): $(LOCALBIN)
helmify: $(HELMIFY) ## Download helmify locally if necessary.
$(HELMIFY): $(LOCALBIN)
@test -s $(LOCALBIN)/helmify || GOBIN=$(LOCALBIN) go install github.com/arttor/helmify/cmd/helmify@$(HELMIFY_VESRION)

.PHONY: e2e
e2e: ## Run e2e tests
go test -v ./e2e/...
18 changes: 12 additions & 6 deletions e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package e2e

import (
"context"
"fmt"
"os"
"testing"
"time"
Expand All @@ -14,6 +15,8 @@ import (
"sigs.k8s.io/e2e-framework/support/utils"
)

const ErrFormat = "%v: %v\n"

var (
testEnv env.Environment
testNamespace string
Expand Down Expand Up @@ -44,11 +47,12 @@ func TestMain(m *testing.M) {
// build and load spin operator image into cluster
func(ctx context.Context, _ *envconf.Config) (context.Context, error) {
if p := utils.RunCommand(`bash -c "cd .. && IMG=ghcr.io/spinkube/spin-operator:dev make docker-build"`); p.Err() != nil {
return ctx, p.Err()

return ctx, fmt.Errorf(ErrFormat, p.Err(), p.Out())
}

if p := utils.RunCommand(("k3d image import -c " + cluster.name + " ghcr.io/spinkube/spin-operator:dev")); p.Err() != nil {
return ctx, p.Err()
return ctx, fmt.Errorf(ErrFormat, p.Err(), p.Out())
}
return ctx, nil
},
Expand All @@ -57,20 +61,22 @@ func TestMain(m *testing.M) {
func(ctx context.Context, _ *envconf.Config) (context.Context, error) {
// install crds
if p := utils.RunCommand(`bash -c "cd .. && make install"`); p.Err() != nil {
return ctx, p.Err()

return ctx, fmt.Errorf(ErrFormat, p.Err(), p.Out())

}

// install cert-manager
if p := utils.RunCommand("kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.14.2/cert-manager.yaml"); p.Err() != nil {
return ctx, p.Err()
return ctx, fmt.Errorf(ErrFormat, p.Err(), p.Out())
}
// wait for cert-manager to be ready
if p := utils.RunCommand("kubectl wait --for=condition=Available --timeout=300s deployment/cert-manager-webhook -n cert-manager"); p.Err() != nil {
return ctx, p.Err()
return ctx, fmt.Errorf(ErrFormat, p.Err(), p.Out())
}

if p := utils.RunCommand(`bash -c "cd .. && IMG=ghcr.io/spinkube/spin-operator:dev make deploy"`); p.Err() != nil {
return ctx, p.Err()
return ctx, fmt.Errorf(ErrFormat, p.Err(), p.Out())
}

// wait for the controller deployment to be ready
Expand Down

0 comments on commit a221754

Please sign in to comment.