Skip to content

Commit

Permalink
CI: Generate e2e artifacts and upload
Browse files Browse the repository at this point in the history
Signed-off-by: Joaquim Moreno Prusi <[email protected]>
  • Loading branch information
jmprusi committed Aug 21, 2023
1 parent 70abdf0 commit b3e67f3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 37 deletions.
47 changes: 26 additions & 21 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,38 @@ on:
merge_group:
push:
branches:
- main
- main

jobs:
e2e-kind:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version-file: go.mod

- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Run e2e tests
run: |
# By default make stops building on first non-zero exit code which
# in case of E2E tests will mean that code coverage will only be
# collected on successful runs. We want to collect coverage even
# after failing tests.
# With -k flag make will continue the build, but will return non-zero
# exit code in case of any errors.
ARTIFACT_PATH=/tmp/artifacts make -k e2e
- name: Run e2e tests
run: |
# By default make stops building on first non-zero exit code which
# in case of E2E tests will mean that code coverage will only be
# collected on successful runs. We want to collect coverage even
# after failing tests.
# With -k flag make will continue the build, but will return non-zero
# exit code in case of any errors.
make -k e2e
- uses: cytopia/[email protected]
if: failure()
with:
name: e2e-artifacts
path: /tmp/artifacts/

- uses: codecov/codecov-action@v3
with:
files: e2e-cover.out
flags: e2e
functionalities: fixes
- uses: codecov/codecov-action@v3
with:
files: e2e-cover.out
flags: e2e
functionalities: fixes
31 changes: 15 additions & 16 deletions test/e2e/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ import (
"os"
"path/filepath"
"strings"
"time"

operatorv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
catalogd "github.com/operator-framework/catalogd/pkg/apis/core/v1beta1"
operatorv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1"
"gopkg.in/yaml.v2"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
apimeta "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -28,13 +27,13 @@ import (

catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1"
rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1"
)

const (
defaultTimeout = 30 * time.Second
defaultPoll = 1 * time.Second
testCatalogRef = "localhost/testdata/catalogs/test-catalog:e2e"
testCatalogName = "test-catalog"
artifactName = "operator-controller-e2e"
defaultTimeout = 30 * time.Second
defaultPoll = 1 * time.Second
testCatalogRef = "localhost/testdata/catalogs/test-catalog:e2e"
artifactName = "operator-controller-e2e"
)

var _ = Describe("Operator Install", func() {
Expand Down Expand Up @@ -285,7 +284,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
GinkgoWriter.Printf("Failed to marshal operator %w", err)
continue
}
if err := os.WriteFile(filepath.Join(artifactPath, operator.Name+"-operator.yaml"), operatorYaml, 0644); err != nil {
if err := os.WriteFile(filepath.Join(artifactPath, operator.Name+"-operator.yaml"), operatorYaml, 0600); err != nil {
GinkgoWriter.Printf("Failed to write operator to file %w", err)
}
}
Expand All @@ -302,7 +301,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
GinkgoWriter.Printf("Failed to marshal catalogsource %w", err)
continue
}
if err := os.WriteFile(filepath.Join(artifactPath, catalogsource.Name+"-catalogsource.yaml"), catalogsourceYaml, 0644); err != nil {
if err := os.WriteFile(filepath.Join(artifactPath, catalogsource.Name+"-catalogsource.yaml"), catalogsourceYaml, 0600); err != nil {
GinkgoWriter.Printf("Failed to write catalogsource to file %w", err)
}
}
Expand All @@ -319,7 +318,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
GinkgoWriter.Printf("Failed to marshal bundle %w", err)
continue
}
if err := os.WriteFile(filepath.Join(artifactPath, bundle.Name+"-bundle.yaml"), bundleYaml, 0644); err != nil {
if err := os.WriteFile(filepath.Join(artifactPath, bundle.Name+"-bundle.yaml"), bundleYaml, 0600); err != nil {
GinkgoWriter.Printf("Failed to write bundle to file %w", err)
}
}
Expand All @@ -336,7 +335,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
GinkgoWriter.Printf("Failed to marshal bundleDeployment %w", err)
continue
}
if err := os.WriteFile(filepath.Join(artifactPath, bundleDeployment.Name+"-bundleDeployment.yaml"), bundleDeploymentYaml, 0644); err != nil {
if err := os.WriteFile(filepath.Join(artifactPath, bundleDeployment.Name+"-bundleDeployment.yaml"), bundleDeploymentYaml, 0600); err != nil {
GinkgoWriter.Printf("Failed to write bundleDeployment to file %w", err)
}
}
Expand Down Expand Up @@ -367,7 +366,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
GinkgoWriter.Printf("Failed to marshal deployment %w", err)
continue
}
if err := os.WriteFile(filepath.Join(namespacedArtifactPath, deployment.Name+"-deployment.yaml"), deploymentYaml, 0644); err != nil {
if err := os.WriteFile(filepath.Join(namespacedArtifactPath, deployment.Name+"-deployment.yaml"), deploymentYaml, 0600); err != nil {
GinkgoWriter.Printf("Failed to write deployment to file %w", err)
}
}
Expand All @@ -378,11 +377,11 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
GinkgoWriter.Printf("Failed to list pods %w in namespace: %q", err, namespace.Name)
}
for _, pod := range pods.Items {
if pod.Status.Phase != v1.PodRunning && pod.Status.Phase != v1.PodSucceeded && pod.Status.Phase != v1.PodFailed {
if pod.Status.Phase != corev1.PodRunning && pod.Status.Phase != corev1.PodSucceeded && pod.Status.Phase != corev1.PodFailed {
continue
}
for _, container := range pod.Spec.Containers {
logs, err := kubeClient.CoreV1().Pods(namespace.Name).GetLogs(pod.Name, &v1.PodLogOptions{Container: container.Name}).Stream(ctx)
logs, err := kubeClient.CoreV1().Pods(namespace.Name).GetLogs(pod.Name, &corev1.PodLogOptions{Container: container.Name}).Stream(ctx)
if err != nil {
GinkgoWriter.Printf("Failed to get logs for pod %q in namespace %q: %w", pod.Name, namespace.Name, err)
continue
Expand Down

0 comments on commit b3e67f3

Please sign in to comment.