Skip to content

Commit 49e122d

Browse files
committed
refactor: enhance unit and E2E test workflows with image tagging and GHCR integration
1 parent 6065ebf commit 49e122d

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

.github/workflows/test.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,40 @@ jobs:
3535
unit_test:
3636
name: Run Unit Tests
3737
runs-on: ubuntu-latest
38+
permissions:
39+
contents: read
40+
packages: read
3841
steps:
3942
- uses: actions/checkout@v6
4043
- name: set up go
4144
uses: actions/setup-go@v6
4245
with:
4346
go-version-file: ./go.mod
47+
- name: Compute image tag
48+
id: image-tag
49+
shell: bash
50+
run: |
51+
if [ -n "${{ github.event.pull_request.number }}" ]; then
52+
TAG="pr-${{ github.event.pull_request.number }}"
53+
else
54+
TAG="${{ github.ref_name }}"
55+
TAG="${TAG//\//-}"
56+
fi
57+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
58+
- name: Log in to GHCR
59+
uses: docker/login-action@v3
60+
with:
61+
registry: ghcr.io
62+
username: ${{ github.actor }}
63+
password: ${{ secrets.GITHUB_TOKEN }}
64+
- name: Pull and tag ev-node-testapp image for tests
65+
shell: bash
66+
run: |
67+
set -euo pipefail
68+
SRC_IMAGE="ghcr.io/${{ github.repository_owner }}/ev-node-testapp:${{ steps.image-tag.outputs.tag }}"
69+
echo "Pulling $SRC_IMAGE"
70+
docker pull "$SRC_IMAGE"
71+
docker tag "$SRC_IMAGE" evstack:local-dev
4472
- name: Run unit test
4573
run: make test-cover
4674
- name: Upload unit test coverage report
@@ -70,12 +98,40 @@ jobs:
7098
name: Run E2E System Tests
7199
needs: build_all-apps
72100
runs-on: ubuntu-latest
101+
permissions:
102+
contents: read
103+
packages: read
73104
steps:
74105
- uses: actions/checkout@v6
75106
- name: set up go
76107
uses: actions/setup-go@v6
77108
with:
78109
go-version-file: ./go.mod
110+
- name: Compute image tag
111+
id: image-tag
112+
shell: bash
113+
run: |
114+
if [ -n "${{ github.event.pull_request.number }}" ]; then
115+
TAG="pr-${{ github.event.pull_request.number }}"
116+
else
117+
TAG="${{ github.ref_name }}"
118+
TAG="${TAG//\//-}"
119+
fi
120+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
121+
- name: Log in to GHCR
122+
uses: docker/login-action@v3
123+
with:
124+
registry: ghcr.io
125+
username: ${{ github.actor }}
126+
password: ${{ secrets.GITHUB_TOKEN }}
127+
- name: Pull and tag ev-node-testapp image for tests
128+
shell: bash
129+
run: |
130+
set -euo pipefail
131+
SRC_IMAGE="ghcr.io/${{ github.repository_owner }}/ev-node-testapp:${{ steps.image-tag.outputs.tag }}"
132+
echo "Pulling $SRC_IMAGE"
133+
docker pull "$SRC_IMAGE"
134+
docker tag "$SRC_IMAGE" evstack:local-dev
79135
- name: E2E Tests
80136
run: make test-e2e
81137

0 commit comments

Comments
 (0)