Skip to content

Commit 345bd1f

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

File tree

2 files changed

+30
-26
lines changed

2 files changed

+30
-26
lines changed

.github/workflows/e2e.yaml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,26 @@ on:
55
pull_request:
66
push:
77
branches:
8-
- main
8+
- main
99

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

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

19-
- uses: actions/setup-go@v4
20-
with:
21-
go-version-file: go.mod
22+
- name: Run e2e tests
23+
run: |
24+
ARTIFACT_PATH=/tmp/artifacts make e2e
2225
23-
- name: Run e2e tests
24-
run: |
25-
make e2e
26+
- uses: cytopia/upload-artifact-retry-action@v0.1.7
27+
if: failure()
28+
with:
29+
name: e2e-artifacts
30+
path: /tmp/artifacts/

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() {
@@ -240,7 +239,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
240239
GinkgoWriter.Printf("Failed to marshal operator %w", err)
241240
continue
242241
}
243-
if err := os.WriteFile(filepath.Join(artifactPath, operator.Name+"-operator.yaml"), operatorYaml, 0644); err != nil {
242+
if err := os.WriteFile(filepath.Join(artifactPath, operator.Name+"-operator.yaml"), operatorYaml, 0600); err != nil {
244243
GinkgoWriter.Printf("Failed to write operator to file %w", err)
245244
}
246245
}
@@ -257,7 +256,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
257256
GinkgoWriter.Printf("Failed to marshal catalogsource %w", err)
258257
continue
259258
}
260-
if err := os.WriteFile(filepath.Join(artifactPath, catalogsource.Name+"-catalogsource.yaml"), catalogsourceYaml, 0644); err != nil {
259+
if err := os.WriteFile(filepath.Join(artifactPath, catalogsource.Name+"-catalogsource.yaml"), catalogsourceYaml, 0600); err != nil {
261260
GinkgoWriter.Printf("Failed to write catalogsource to file %w", err)
262261
}
263262
}
@@ -274,7 +273,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
274273
GinkgoWriter.Printf("Failed to marshal bundle %w", err)
275274
continue
276275
}
277-
if err := os.WriteFile(filepath.Join(artifactPath, bundle.Name+"-bundle.yaml"), bundleYaml, 0644); err != nil {
276+
if err := os.WriteFile(filepath.Join(artifactPath, bundle.Name+"-bundle.yaml"), bundleYaml, 0600); err != nil {
278277
GinkgoWriter.Printf("Failed to write bundle to file %w", err)
279278
}
280279
}
@@ -291,7 +290,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
291290
GinkgoWriter.Printf("Failed to marshal bundleDeployment %w", err)
292291
continue
293292
}
294-
if err := os.WriteFile(filepath.Join(artifactPath, bundleDeployment.Name+"-bundleDeployment.yaml"), bundleDeploymentYaml, 0644); err != nil {
293+
if err := os.WriteFile(filepath.Join(artifactPath, bundleDeployment.Name+"-bundleDeployment.yaml"), bundleDeploymentYaml, 0600); err != nil {
295294
GinkgoWriter.Printf("Failed to write bundleDeployment to file %w", err)
296295
}
297296
}
@@ -322,7 +321,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
322321
GinkgoWriter.Printf("Failed to marshal deployment %w", err)
323322
continue
324323
}
325-
if err := os.WriteFile(filepath.Join(namespacedArtifactPath, deployment.Name+"-deployment.yaml"), deploymentYaml, 0644); err != nil {
324+
if err := os.WriteFile(filepath.Join(namespacedArtifactPath, deployment.Name+"-deployment.yaml"), deploymentYaml, 0600); err != nil {
326325
GinkgoWriter.Printf("Failed to write deployment to file %w", err)
327326
}
328327
}
@@ -333,11 +332,11 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
333332
GinkgoWriter.Printf("Failed to list pods %w in namespace: %q", err, namespace.Name)
334333
}
335334
for _, pod := range pods.Items {
336-
if pod.Status.Phase != v1.PodRunning && pod.Status.Phase != v1.PodSucceeded && pod.Status.Phase != v1.PodFailed {
335+
if pod.Status.Phase != corev1.PodRunning && pod.Status.Phase != corev1.PodSucceeded && pod.Status.Phase != corev1.PodFailed {
337336
continue
338337
}
339338
for _, container := range pod.Spec.Containers {
340-
logs, err := kubeClient.CoreV1().Pods(namespace.Name).GetLogs(pod.Name, &v1.PodLogOptions{Container: container.Name}).Stream(ctx)
339+
logs, err := kubeClient.CoreV1().Pods(namespace.Name).GetLogs(pod.Name, &corev1.PodLogOptions{Container: container.Name}).Stream(ctx)
341340
if err != nil {
342341
GinkgoWriter.Printf("Failed to get logs for pod %q in namespace %q: %w", pod.Name, namespace.Name, err)
343342
continue

0 commit comments

Comments
 (0)