Skip to content

Commit b3e67f3

Browse files
committed
CI: Generate e2e artifacts and upload
Signed-off-by: Joaquim Moreno Prusi <joaquim@redhat.com>
1 parent 70abdf0 commit b3e67f3

File tree

2 files changed

+41
-37
lines changed

2 files changed

+41
-37
lines changed

.github/workflows/e2e.yaml

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,38 @@ on:
66
merge_group:
77
push:
88
branches:
9-
- main
9+
- main
1010

1111
jobs:
1212
e2e-kind:
1313
runs-on: ubuntu-latest
1414
steps:
15+
- uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
1518

16-
- uses: actions/checkout@v3
17-
with:
18-
fetch-depth: 0
19+
- uses: actions/setup-go@v4
20+
with:
21+
go-version-file: go.mod
1922

20-
- uses: actions/setup-go@v4
21-
with:
22-
go-version-file: go.mod
23+
- name: Run e2e tests
24+
run: |
25+
# By default make stops building on first non-zero exit code which
26+
# in case of E2E tests will mean that code coverage will only be
27+
# collected on successful runs. We want to collect coverage even
28+
# after failing tests.
29+
# With -k flag make will continue the build, but will return non-zero
30+
# exit code in case of any errors.
31+
ARTIFACT_PATH=/tmp/artifacts make -k e2e
2332
24-
- name: Run e2e tests
25-
run: |
26-
# By default make stops building on first non-zero exit code which
27-
# in case of E2E tests will mean that code coverage will only be
28-
# collected on successful runs. We want to collect coverage even
29-
# after failing tests.
30-
# With -k flag make will continue the build, but will return non-zero
31-
# exit code in case of any errors.
32-
make -k e2e
33+
- uses: cytopia/upload-artifact-retry-action@v0.1.7
34+
if: failure()
35+
with:
36+
name: e2e-artifacts
37+
path: /tmp/artifacts/
3338

34-
- uses: codecov/codecov-action@v3
35-
with:
36-
files: e2e-cover.out
37-
flags: e2e
38-
functionalities: fixes
39+
- uses: codecov/codecov-action@v3
40+
with:
41+
files: e2e-cover.out
42+
flags: e2e
43+
functionalities: fixes

test/e2e/install_test.go

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ import (
77
"os"
88
"path/filepath"
99
"strings"
10+
"time"
11+
12+
operatorv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
1013

1114
. "github.com/onsi/ginkgo/v2"
1215
. "github.com/onsi/gomega"
13-
catalogd "github.com/operator-framework/catalogd/pkg/apis/core/v1beta1"
14-
operatorv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
15-
rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1"
1616
"gopkg.in/yaml.v2"
1717
appsv1 "k8s.io/api/apps/v1"
1818
corev1 "k8s.io/api/core/v1"
19-
v1 "k8s.io/api/core/v1"
2019
"k8s.io/apimachinery/pkg/api/errors"
2120
apimeta "k8s.io/apimachinery/pkg/api/meta"
2221
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -28,13 +27,13 @@ import (
2827

2928
catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1"
3029
rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1"
30+
)
3131

3232
const (
33-
defaultTimeout = 30 * time.Second
34-
defaultPoll = 1 * time.Second
35-
testCatalogRef = "localhost/testdata/catalogs/test-catalog:e2e"
36-
testCatalogName = "test-catalog"
37-
artifactName = "operator-controller-e2e"
33+
defaultTimeout = 30 * time.Second
34+
defaultPoll = 1 * time.Second
35+
testCatalogRef = "localhost/testdata/catalogs/test-catalog:e2e"
36+
artifactName = "operator-controller-e2e"
3837
)
3938

4039
var _ = Describe("Operator Install", func() {
@@ -285,7 +284,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
285284
GinkgoWriter.Printf("Failed to marshal operator %w", err)
286285
continue
287286
}
288-
if err := os.WriteFile(filepath.Join(artifactPath, operator.Name+"-operator.yaml"), operatorYaml, 0644); err != nil {
287+
if err := os.WriteFile(filepath.Join(artifactPath, operator.Name+"-operator.yaml"), operatorYaml, 0600); err != nil {
289288
GinkgoWriter.Printf("Failed to write operator to file %w", err)
290289
}
291290
}
@@ -302,7 +301,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
302301
GinkgoWriter.Printf("Failed to marshal catalogsource %w", err)
303302
continue
304303
}
305-
if err := os.WriteFile(filepath.Join(artifactPath, catalogsource.Name+"-catalogsource.yaml"), catalogsourceYaml, 0644); err != nil {
304+
if err := os.WriteFile(filepath.Join(artifactPath, catalogsource.Name+"-catalogsource.yaml"), catalogsourceYaml, 0600); err != nil {
306305
GinkgoWriter.Printf("Failed to write catalogsource to file %w", err)
307306
}
308307
}
@@ -319,7 +318,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
319318
GinkgoWriter.Printf("Failed to marshal bundle %w", err)
320319
continue
321320
}
322-
if err := os.WriteFile(filepath.Join(artifactPath, bundle.Name+"-bundle.yaml"), bundleYaml, 0644); err != nil {
321+
if err := os.WriteFile(filepath.Join(artifactPath, bundle.Name+"-bundle.yaml"), bundleYaml, 0600); err != nil {
323322
GinkgoWriter.Printf("Failed to write bundle to file %w", err)
324323
}
325324
}
@@ -336,7 +335,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
336335
GinkgoWriter.Printf("Failed to marshal bundleDeployment %w", err)
337336
continue
338337
}
339-
if err := os.WriteFile(filepath.Join(artifactPath, bundleDeployment.Name+"-bundleDeployment.yaml"), bundleDeploymentYaml, 0644); err != nil {
338+
if err := os.WriteFile(filepath.Join(artifactPath, bundleDeployment.Name+"-bundleDeployment.yaml"), bundleDeploymentYaml, 0600); err != nil {
340339
GinkgoWriter.Printf("Failed to write bundleDeployment to file %w", err)
341340
}
342341
}
@@ -367,7 +366,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
367366
GinkgoWriter.Printf("Failed to marshal deployment %w", err)
368367
continue
369368
}
370-
if err := os.WriteFile(filepath.Join(namespacedArtifactPath, deployment.Name+"-deployment.yaml"), deploymentYaml, 0644); err != nil {
369+
if err := os.WriteFile(filepath.Join(namespacedArtifactPath, deployment.Name+"-deployment.yaml"), deploymentYaml, 0600); err != nil {
371370
GinkgoWriter.Printf("Failed to write deployment to file %w", err)
372371
}
373372
}
@@ -378,11 +377,11 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
378377
GinkgoWriter.Printf("Failed to list pods %w in namespace: %q", err, namespace.Name)
379378
}
380379
for _, pod := range pods.Items {
381-
if pod.Status.Phase != v1.PodRunning && pod.Status.Phase != v1.PodSucceeded && pod.Status.Phase != v1.PodFailed {
380+
if pod.Status.Phase != corev1.PodRunning && pod.Status.Phase != corev1.PodSucceeded && pod.Status.Phase != corev1.PodFailed {
382381
continue
383382
}
384383
for _, container := range pod.Spec.Containers {
385-
logs, err := kubeClient.CoreV1().Pods(namespace.Name).GetLogs(pod.Name, &v1.PodLogOptions{Container: container.Name}).Stream(ctx)
384+
logs, err := kubeClient.CoreV1().Pods(namespace.Name).GetLogs(pod.Name, &corev1.PodLogOptions{Container: container.Name}).Stream(ctx)
386385
if err != nil {
387386
GinkgoWriter.Printf("Failed to get logs for pod %q in namespace %q: %w", pod.Name, namespace.Name, err)
388387
continue

0 commit comments

Comments
 (0)