Skip to content

Commit 7c0ee71

Browse files
mclasmeierMoritz ClasmeierporridgeAlexVulaj
authored
Run e2e tests in CI (#116)
Co-authored-by: Moritz Clasmeier <mclasmeier@redhat.com> Co-authored-by: Marcin Owsiany <porridge@redhat.com> Co-authored-by: Alex Vulaj <ajvulaj@gmail.com>
1 parent 6805019 commit 7c0ee71

14 files changed

Lines changed: 643 additions & 436 deletions
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Build Roxie Image
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
image:
7+
description: "Built image with tag"
8+
value: ${{ jobs.build-roxie-image.outputs.image }}
9+
10+
env:
11+
REGISTRY: quay.io
12+
IMAGE_NAME: rhacs-eng/roxie
13+
14+
jobs:
15+
build-roxie-image:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
outputs:
21+
image: ${{ steps.meta.outputs.tags }}
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v6
25+
with:
26+
fetch-depth: 0
27+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
28+
29+
- name: Set up Go
30+
uses: actions/setup-go@v6
31+
with:
32+
go-version-file: go.mod
33+
cache: true
34+
35+
- name: Set up Docker Buildx
36+
uses: docker/setup-buildx-action@v3
37+
38+
- name: Log in to Quay.io
39+
uses: docker/login-action@v3
40+
with:
41+
registry: ${{ env.REGISTRY }}
42+
username: ${{ secrets.REGISTRY_USERNAME }}
43+
password: ${{ secrets.REGISTRY_TOKEN }}
44+
45+
- name: Get build metadata
46+
id: build-meta
47+
run: |
48+
echo "version=$(make version)" >> $GITHUB_OUTPUT
49+
echo "build_date=$(make get-build-date)" >> $GITHUB_OUTPUT
50+
51+
- name: Extract metadata (tags, labels) for Docker
52+
id: meta
53+
uses: docker/metadata-action@v5
54+
with:
55+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
56+
tags: type=raw,value=${{ steps.build-meta.outputs.version }}
57+
58+
- name: Build and push Docker image
59+
uses: docker/build-push-action@v6
60+
with:
61+
context: .
62+
platforms: linux/amd64
63+
push: true
64+
tags: ${{ steps.meta.outputs.tags }}
65+
labels: ${{ steps.meta.outputs.labels }}
66+
build-args: |
67+
ROXIE_VERSION=${{ steps.build-meta.outputs.version }}
68+
BUILD_DATE=${{ steps.build-meta.outputs.build_date }}
69+
cache-from: |
70+
type=gha
71+
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
72+
cache-to: type=gha,mode=max
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Create Dev Cluster
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
cluster-name:
7+
required: true
8+
type: string
9+
outputs:
10+
cluster-name:
11+
description: "Name of the created cluster"
12+
value: ${{ jobs.create-dev-cluster.outputs.cluster-name }}
13+
14+
jobs:
15+
create-dev-cluster:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
cluster-name: ${{ inputs.cluster-name }}
19+
steps:
20+
- uses: stackrox/actions/infra/create-cluster@v1
21+
with:
22+
flavor: gke-default
23+
name: ${{ inputs.cluster-name }}
24+
args: machine-type=e2-standard-4,nodes=3,gcp-image-type=ubuntu_containerd
25+
lifespan: "2h"
26+
wait: true
27+
token: ${{ secrets.INFRA_CI_TOKEN }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Delete Dev Cluster
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
cluster-name:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
delete-dev-cluster:
12+
runs-on: ubuntu-latest
13+
env:
14+
INFRA_TOKEN: ${{ secrets.INFRA_CI_TOKEN }}
15+
steps:
16+
- name: Install infractl
17+
uses: stackrox/actions/infra/install-infractl@v1
18+
19+
- name: Delete cluster
20+
run: |
21+
"$HOME/.local/bin/infractl" delete "${{ inputs.cluster-name }}"

.github/workflows/e2e-tests.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: E2E Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
cluster-name:
7+
required: true
8+
type: string
9+
image:
10+
required: true
11+
type: string
12+
env:
13+
REGISTRY: quay.io
14+
IMAGE_NAME: rhacs-eng/roxie
15+
16+
jobs:
17+
e2e-tests:
18+
runs-on: ubuntu-latest
19+
container:
20+
image: quay.io/stackrox-io/apollo-ci:stackrox-test-0.5.11
21+
env:
22+
CLUSTER_NAME: ${{ inputs.cluster-name }}
23+
KUBECONFIG: /github/home/artifacts/kubeconfig
24+
INFRA_TOKEN: ${{ secrets.INFRA_CI_TOKEN }}
25+
INFRACTL: bin/infractl -k -e localhost:8443
26+
USE_GKE_GCLOUD_AUTH_PLUGIN: "True"
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v6
30+
with:
31+
fetch-depth: 0
32+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
33+
34+
- name: Fix repository ownership
35+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
36+
37+
- name: Log in to Quay.io
38+
uses: docker/login-action@v3
39+
with:
40+
registry: ${{ env.REGISTRY }}
41+
username: ${{ secrets.REGISTRY_USERNAME }}
42+
password: ${{ secrets.REGISTRY_TOKEN }}
43+
44+
- name: Extract roxie binary from image
45+
run: |
46+
docker create --name roxie-extract "${{ inputs.image }}"
47+
docker cp roxie-extract:/usr/local/bin/roxie "$GITHUB_WORKSPACE/roxie"
48+
docker rm roxie-extract
49+
50+
- name: Install roxie binary
51+
run: |
52+
cp "${GITHUB_WORKSPACE}/roxie" /usr/local/bin/roxie
53+
chmod +x /usr/local/bin/roxie
54+
roxie version
55+
56+
- name: Install roxctl
57+
env:
58+
ROXCTL_VERSION: "4.10.0"
59+
ROXCTL_SHA256: "5db647b14569465866c0162522e83393ebf02f671f4556b1b3ed551b9f8433bc"
60+
run: |
61+
curl -fsSLo /usr/local/bin/roxctl \
62+
"https://mirror.openshift.com/pub/rhacs/assets/${ROXCTL_VERSION}/bin/Linux/roxctl"
63+
echo "${ROXCTL_SHA256} /usr/local/bin/roxctl" | sha256sum -c -
64+
chmod +x /usr/local/bin/roxctl
65+
roxctl version
66+
67+
- name: Authenticate to GCloud
68+
uses: google-github-actions/auth@v3
69+
with:
70+
credentials_json: ${{ secrets.ROXIE_CI_AUTOMATION_GCP_SA }}
71+
72+
- name: Set up Cloud SDK
73+
uses: "google-github-actions/setup-gcloud@v3"
74+
with:
75+
install_components: "gke-gcloud-auth-plugin"
76+
77+
- name: Download production infractl
78+
uses: stackrox/actions/infra/install-infractl@v1
79+
80+
- name: Download artifacts
81+
run: |
82+
/github/home/.local/bin/infractl artifacts "$CLUSTER_NAME" -d /github/home/artifacts >> "$GITHUB_STEP_SUMMARY"
83+
84+
- name: Testing cluster connection
85+
run: |
86+
kubectl get namespaces
87+
88+
- name: Run e2e tests
89+
env:
90+
REGISTRY_USERNAME: ${{ secrets.QUAY_RHACS_ENG_RO_USERNAME }}
91+
REGISTRY_PASSWORD: ${{ secrets.QUAY_RHACS_ENG_RO_PASSWORD }}
92+
SKIP_OLM_TESTS: "true"
93+
run: |
94+
make run-test-e2e
95+
96+
- name: Run integration tests
97+
env:
98+
REGISTRY_USERNAME: ${{ secrets.QUAY_RHACS_ENG_RO_USERNAME }}
99+
REGISTRY_PASSWORD: ${{ secrets.QUAY_RHACS_ENG_RO_PASSWORD }}
100+
run: |
101+
make test-integration

.github/workflows/main-push.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
unit-tests:
13+
uses: ./.github/workflows/unit-tests.yml
14+
15+
create-dev-cluster:
16+
uses: ./.github/workflows/create-dev-cluster.yml
17+
with:
18+
cluster-name: infra-roxie-main-${{ github.run_number }}
19+
secrets: inherit
20+
21+
build-roxie-image:
22+
uses: ./.github/workflows/build-roxie-image.yml
23+
permissions:
24+
contents: read
25+
packages: write
26+
secrets: inherit
27+
28+
e2e-tests:
29+
needs: [ create-dev-cluster, build-roxie-image ]
30+
uses: ./.github/workflows/e2e-tests.yml
31+
with:
32+
cluster-name: ${{ needs.create-dev-cluster.outputs.cluster-name }}
33+
image: ${{ needs.build-roxie-image.outputs.image }}
34+
secrets: inherit
35+
36+
delete-dev-cluster:
37+
if: ${{ always() && needs.create-dev-cluster.result == 'success' }}
38+
needs: [ create-dev-cluster, e2e-tests ]
39+
uses: ./.github/workflows/delete-dev-cluster.yml
40+
with:
41+
cluster-name: ${{ needs.create-dev-cluster.outputs.cluster-name }}
42+
secrets: inherit

.github/workflows/pr.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: PR
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
unit-tests:
13+
uses: ./.github/workflows/unit-tests.yml
14+
15+
create-dev-cluster:
16+
uses: ./.github/workflows/create-dev-cluster.yml
17+
with:
18+
cluster-name: infra-roxie-pr-${{ github.event.pull_request.number }}
19+
secrets: inherit
20+
21+
build-roxie-image:
22+
uses: ./.github/workflows/build-roxie-image.yml
23+
permissions:
24+
contents: read
25+
packages: write
26+
secrets: inherit
27+
28+
e2e-tests:
29+
needs: [ create-dev-cluster, build-roxie-image ]
30+
uses: ./.github/workflows/e2e-tests.yml
31+
with:
32+
cluster-name: ${{ needs.create-dev-cluster.outputs.cluster-name }}
33+
image: ${{ needs.build-roxie-image.outputs.image }}
34+
secrets: inherit
35+
36+
delete-dev-cluster:
37+
if: ${{ always() && needs.create-dev-cluster.result == 'success' }}
38+
needs: [ create-dev-cluster, e2e-tests ]
39+
uses: ./.github/workflows/delete-dev-cluster.yml
40+
with:
41+
cluster-name: ${{ needs.create-dev-cluster.outputs.cluster-name }}
42+
secrets: inherit

.github/workflows/test.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/unit-tests.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Unit Tests
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
unit-tests:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v6
12+
13+
- name: Set up Go
14+
uses: actions/setup-go@v6
15+
with:
16+
go-version-file: go.mod
17+
cache: true
18+
19+
- name: Check go.mod tidiness
20+
run: |
21+
go mod tidy
22+
if ! git diff --exit-code go.mod go.sum; then
23+
echo "::error::go.mod or go.sum are not tidy. Please run 'go mod tidy' and commit the changes."
24+
exit 1
25+
fi
26+
27+
- name: Run unit tests
28+
run: make test

0 commit comments

Comments
 (0)