Skip to content

Commit 7257792

Browse files
authored
feat: Build and run e2e after PR is added to merge queue. (#190)
# Description This PR enhances the CI/CD pipeline by integrating end-to-end (E2E) tests on Azure Kubernetes Service (AKS) after a PR has been reviewed and initially approved. This update allows PRs from forks to undergo E2E testing after receiving initial approval. The updated workflow is as follows: For a successful E2E run: 1. Open PR 2. Unit tests, build, and lints are executed 3. A maintainer approves the PR 4. The PR is added to the merge queue 5. E2E tests are run 6. If E2E tests pass, the PR is merged into the main branch For a failing E2E run: 1. Open PR 2. Unit tests, build, and lints are executed 3. A maintainer approves the PR 4. The PR is added to the merge queue 5. E2E tests are run 6. If E2E tests fail, the PR is removed from the queue 7. The developer is notified of the failure and can fix the issue ![image](https://github.com/microsoft/retina/assets/2801007/afbd7053-3e42-40e7-9f51-2a93c109444a) Testing. - Successful merge: [Merge queue test by jimassa · Pull Request #188 · microsoft/retina (github.com)](#188) Mergequue Run : [Build images and run E2E tests. · 49ed7df (github.com)](https://github.com/microsoft/retina/actions/runs/8480556009) - Unsuccessful merge: [Merge queue test fail by jimassa · Pull Request #189 · microsoft/retina (github.com)](#189) ## Related Issue If this pull request is related to any issue, please mention it here. Additionally, make sure that the issue is assigned to you before submitting this pull request. ## Checklist - [x] I have read the [contributing documantation](https://retina.sh/docs/contributing). - [x] I signed and signed-off the commits (`git commit -S -s ...`) - [x] I have correctly attributed the author(s) of the code. - [x] I have tested the changes locally. - [x] I have followed the project's style guidelines. - [x] I have updated the documentation, if necessary. - [x] I have added tests, if applicable. ## Screenshots (if applicable) Please add any relevant screenshots or GIFs to showcase the changes made. ## Additional Notes Add any additional notes or context about the pull request here. --- Please refer to the [CONTRIBUTING.md](../CONTRIBUTING.md) file for more information on how to contribute to this project. --------- Signed-off-by: Jacques Massa <[email protected]>
1 parent 9ccb6e5 commit 7257792

8 files changed

+141
-194
lines changed

.github/workflows/codeql.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
name: "CodeQL"
22
on:
3+
merge_group:
34
workflow_dispatch:
45
push:
56
branches: [ main ]
67
pull_request:
78
branches: [ main ]
89
jobs:
910
analyze:
11+
if: ${{ github.event_name != 'merge_group' }}
1012
name: Analyze
1113
strategy:
1214
fail-fast: false

.github/workflows/commit-message.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: commit-message
22
on:
3+
merge_group:
34
pull_request:
45
branches: [ main ]
56
types:
@@ -9,6 +10,7 @@ on:
910
- reopened
1011
jobs:
1112
commit-message:
13+
if: ${{ github.event_name != 'merge_group' }}
1214
runs-on: ubuntu-20.04
1315
steps:
1416
- name: verify_commit_message

.github/workflows/docs.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches: ["main"]
66
workflow_dispatch:
7+
merge_group:
78
permissions:
89
contents: read
910
pages: write
@@ -13,6 +14,7 @@ concurrency:
1314
cancel-in-progress: false
1415
jobs:
1516
deploy:
17+
if: ${{ github.event_name != 'merge_group' }}
1618
environment:
1719
name: retina.sh
1820
url: ${{ steps.deployment.outputs.page_url }}

.github/workflows/golangci-lint.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
name: golangci-lint
22
on:
3+
merge_group:
34
workflow_dispatch:
45
push:
56
branches: [main]
67
pull_request:
78
branches: [main]
89
jobs:
910
golangci:
11+
if: ${{ github.event_name != 'merge_group' }}
1012
strategy:
1113
fail-fast: false
1214
matrix:

.github/workflows/images.yaml

+129-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
name: Build Retina Container Images
1+
name: Build images and run E2E tests.
22

33
on:
44
pull_request:
55
branches: [main]
6+
merge_group:
7+
types: [checks_requested]
8+
workflow_dispatch:
69

710
permissions:
811
contents: read
@@ -29,14 +32,32 @@ jobs:
2932
- name: Set up QEMU
3033
uses: docker/setup-qemu-action@v3
3134

35+
- name: Az CLI login
36+
uses: azure/login@v1
37+
if: ${{ github.event_name == 'merge_group' }}
38+
with:
39+
creds: ${{ secrets.AZURE_CREDENTIALS }}
40+
3241
- name: Build Images
3342
shell: bash
3443
run: |
3544
set -euo pipefail
3645
echo "TAG=$(make version)" >> $GITHUB_ENV
37-
make retina-image \
38-
IMAGE_NAMESPACE=${{ github.repository }} \
39-
PLATFORM=${{ matrix.platform }}/${{ matrix.arch }}
46+
if [ "$IS_MERGE_GROUP" == "true" ]; then
47+
az acr login -n ${{ vars.ACR_NAME }}
48+
make retina-image \
49+
IMAGE_NAMESPACE=${{ github.repository }} \
50+
PLATFORM=${{ matrix.platform }}/${{ matrix.arch }} \
51+
IMAGE_REGISTRY=${{ vars.ACR_NAME }} \
52+
BUILDX_ACTION=--push
53+
else
54+
make retina-image \
55+
IMAGE_NAMESPACE=${{ github.repository }} \
56+
PLATFORM=${{ matrix.platform }}/${{ matrix.arch }}
57+
fi
58+
env:
59+
IS_MERGE_GROUP: ${{ github.event_name == 'merge_group' }}
60+
4061

4162
retina-win-images:
4263
name: Build Agent Windows Images
@@ -58,15 +79,32 @@ jobs:
5879

5980
- name: Set up QEMU
6081
uses: docker/setup-qemu-action@v3
61-
82+
83+
- name: Az CLI login
84+
uses: azure/login@v1
85+
if: ${{ github.event_name == 'merge_group' }}
86+
with:
87+
creds: ${{ secrets.AZURE_CREDENTIALS }}
88+
6289
- name: Build Images
6390
shell: bash
6491
run: |
6592
set -euo pipefail
6693
echo "TAG=$(make version)" >> $GITHUB_ENV
67-
make retina-image-win \
68-
IMAGE_NAMESPACE=${{ github.repository }} \
69-
PLATFORM=${{ matrix.platform }}/${{ matrix.arch }}
94+
if [ "$IS_MERGE_GROUP" == "true" ]; then
95+
az acr login -n ${{ vars.ACR_NAME }}
96+
make retina-image-win \
97+
IMAGE_NAMESPACE=${{ github.repository }} \
98+
PLATFORM=${{ matrix.platform }}/${{ matrix.arch }} \
99+
IMAGE_REGISTRY=${{ vars.ACR_NAME }} \
100+
BUILDX_ACTION=--push
101+
else
102+
make retina-image-win \
103+
IMAGE_NAMESPACE=${{ github.repository }} \
104+
PLATFORM=${{ matrix.platform }}/${{ matrix.arch }}
105+
fi
106+
env:
107+
IS_MERGE_GROUP: ${{ github.event_name == 'merge_group' }}
70108

71109
operator-images:
72110
name: Build Operator Images
@@ -89,11 +127,91 @@ jobs:
89127
- name: Set up QEMU
90128
uses: docker/setup-qemu-action@v3
91129

130+
- name: Az CLI login
131+
uses: azure/login@v1
132+
if: ${{ github.event_name == 'merge_group' }}
133+
with:
134+
creds: ${{ secrets.AZURE_CREDENTIALS }}
135+
92136
- name: Build Images
93137
shell: bash
94138
run: |
95139
set -euo pipefail
96140
echo "TAG=$(make version)" >> $GITHUB_ENV
97-
make retina-operator-image \
98-
IMAGE_NAMESPACE=${{ github.repository }} \
99-
PLATFORM=${{ matrix.platform }}/${{ matrix.arch }}
141+
if [ "$IS_MERGE_GROUP" == "true" ]; then
142+
az acr login -n ${{ vars.ACR_NAME }}
143+
make retina-operator-image \
144+
IMAGE_NAMESPACE=${{ github.repository }} \
145+
PLATFORM=${{ matrix.platform }}/${{ matrix.arch }} \
146+
IMAGE_REGISTRY=${{ vars.ACR_NAME }} \
147+
BUILDX_ACTION=--push
148+
else
149+
make retina-operator-image \
150+
IMAGE_NAMESPACE=${{ github.repository }} \
151+
PLATFORM=${{ matrix.platform }}/${{ matrix.arch }}
152+
fi
153+
env:
154+
IS_MERGE_GROUP: ${{ github.event_name == 'merge_group' }}
155+
156+
manifests:
157+
if: ${{ github.event_name == 'merge_group' }}
158+
name: Generate Manifests
159+
runs-on: ubuntu-latest
160+
needs: [retina-images, retina-win-images, operator-images]
161+
162+
strategy:
163+
matrix:
164+
components: ["retina", "operator"]
165+
166+
steps:
167+
- name: Checkout code
168+
uses: actions/checkout@v4
169+
170+
- name: Setup QEMU
171+
uses: docker/setup-qemu-action@v3
172+
173+
- name: Azure CLI login
174+
uses: azure/login@v1
175+
with:
176+
creds: ${{ secrets.AZURE_CREDENTIALS }}
177+
178+
- name: Generate Manifests
179+
shell: bash
180+
run: |
181+
set -euo pipefail
182+
az acr login -n ${{ vars.ACR_NAME }}
183+
make manifest COMPONENT=${{ matrix.components }} \
184+
IMAGE_REGISTRY=${{ vars.ACR_NAME }} \
185+
186+
e2e:
187+
if: ${{ github.event_name == 'merge_group' }}
188+
name: Run E2E Tests
189+
runs-on: ubuntu-latest
190+
needs: [manifests]
191+
192+
permissions:
193+
id-token: write
194+
contents: read
195+
196+
steps:
197+
- name: Checkout code
198+
uses: actions/checkout@v4
199+
200+
- name: Setup go
201+
uses: actions/setup-go@v4
202+
with:
203+
go-version: ">=1.21.0"
204+
- run: go version
205+
206+
- name: Az CLI login
207+
uses: azure/login@v1
208+
if: ${{ github.event_name == 'merge_group' }}
209+
with:
210+
creds: ${{ secrets.AZURE_CREDENTIALS }}
211+
212+
- name: Run E2E Tests
213+
shell: bash
214+
run: |
215+
set -euo pipefail
216+
export AZURE_SUBSCRIPTION_ID=${{ secrets.AZURE_SUBSCRIPTION }}
217+
go test -v ./test/e2e/scenarios/retina/*.go -timeout 30m -tags=e2e -count=1 -args -image-tag=$(make version) -image-registry=${{ vars.ACR_NAME }} -image-namespace=${{ github.repository}}

0 commit comments

Comments
 (0)