Skip to content

Commit 832e724

Browse files
authored
ci(e2e-tests): refactor E2E tests workflow for improved structure and… (#82)
* ci(e2e-tests): refactor E2E tests workflow for improved structure and caching - consolidate E2E test jobs into a single job with matrix strategy - update Go and Docker actions to latest versions - streamline caching and build steps for efficiency * ci(e2e-tests): update Go build flags and add CGO_ENABLED environment variable - Add CGO_ENABLED environment variable for cross-compilation - Simplify Go build flags by removing unnecessary linker flags
1 parent d679948 commit 832e724

1 file changed

Lines changed: 46 additions & 269 deletions

File tree

.github/workflows/e2e-tests.yml

Lines changed: 46 additions & 269 deletions
Original file line numberDiff line numberDiff line change
@@ -6,329 +6,106 @@ on:
66
pull_request:
77
branches: [master]
88

9+
env:
10+
GO_VERSION: "1.23"
11+
CGO_ENABLED: 0
12+
DOCKER_BUILDKIT: 1
13+
GO_BUILD_FLAGS: -trimpath -ldflags="-s -w"
14+
15+
defaults:
16+
run:
17+
shell: bash
18+
919
jobs:
10-
# Build job that creates the binaries needed by all E2E test jobs
1120
build:
1221
runs-on: ubuntu-latest
1322
outputs:
1423
cache-key: ${{ steps.cache-key.outputs.key }}
15-
1624
steps:
17-
- name: Checkout code
18-
uses: actions/checkout@v4
25+
- uses: actions/checkout@v4
1926

20-
- name: Set up Go
21-
uses: actions/setup-go@v4
27+
- uses: actions/setup-go@v5
2228
with:
23-
go-version: "1.23"
29+
go-version: ${{ env.GO_VERSION }}
30+
cache-dependency-path: "**/go.sum"
2431

25-
- name: Tidy Go modules
26-
run: |
27-
go mod tidy
28-
29-
- name: Generate cache key
30-
id: cache-key
32+
- id: cache-key
3133
run: echo "key=${{ runner.os }}-binaries-${{ hashFiles('**/go.sum', '**/*.go') }}" >> $GITHUB_OUTPUT
3234

33-
- name: Cache binaries
35+
- uses: actions/cache@v4
3436
id: cache-binaries
35-
uses: actions/cache@v3
3637
with:
3738
path: |
3839
./mpcium
3940
./mpcium-cli
4041
key: ${{ steps.cache-key.outputs.key }}
4142

42-
- name: Cache Go modules
43-
if: steps.cache-binaries.outputs.cache-hit != 'true'
44-
uses: actions/cache@v3
45-
with:
46-
path: |
47-
~/.cache/go-build
48-
~/go/pkg/mod
49-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
50-
restore-keys: |
51-
${{ runner.os }}-go-
52-
53-
- name: Install dependencies
54-
if: steps.cache-binaries.outputs.cache-hit != 'true'
55-
run: |
56-
go mod download
57-
cd e2e && go mod download
43+
- if: steps.cache-binaries.outputs.cache-hit != 'true'
44+
run: cd e2e && go mod tidy
5845

59-
- name: Build binaries
60-
if: steps.cache-binaries.outputs.cache-hit != 'true'
46+
- if: steps.cache-binaries.outputs.cache-hit != 'true'
6147
run: |
62-
go build -o mpcium ./cmd/mpcium
63-
go build -o mpcium-cli ./cmd/mpcium-cli
48+
go build ${{ env.GO_BUILD_FLAGS }} -o mpcium ./cmd/mpcium
49+
go build ${{ env.GO_BUILD_FLAGS }} -o mpcium-cli ./cmd/mpcium-cli
6450
chmod +x mpcium mpcium-cli
6551
66-
# Key Generation E2E Tests
67-
e2e-keygen:
68-
runs-on: ubuntu-latest
69-
needs: build
70-
71-
steps:
72-
- name: Checkout code
73-
uses: actions/checkout@v4
74-
75-
- name: Set up Go
76-
uses: actions/setup-go@v4
77-
with:
78-
go-version: "1.23"
79-
80-
- name: Tidy Go modules
81-
run: |
82-
go mod tidy
83-
84-
- name: Set up Docker Buildx
85-
uses: docker/setup-buildx-action@v3
86-
87-
- name: Verify Docker Compose
88-
run: |
89-
docker --version
90-
docker compose version
91-
92-
- name: Cache Go modules
93-
uses: actions/cache@v3
94-
with:
95-
path: |
96-
~/.cache/go-build
97-
~/go/pkg/mod
98-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
99-
restore-keys: |
100-
${{ runner.os }}-go-
101-
102-
- name: Restore binaries
103-
uses: actions/cache@v3
104-
with:
105-
path: |
106-
./mpcium
107-
./mpcium-cli
108-
key: ${{ needs.build.outputs.cache-key }}
109-
110-
- name: Install binaries
111-
run: |
112-
sudo mv mpcium /usr/local/bin/
113-
sudo mv mpcium-cli /usr/local/bin/
114-
115-
- name: Verify binaries are available
116-
run: |
117-
which mpcium
118-
which mpcium-cli
119-
mpcium --version || echo "mpcium binary ready"
120-
mpcium-cli --version || echo "mpcium-cli binary ready"
121-
122-
- name: Install E2E dependencies
123-
run: |
124-
cd e2e && go mod tidy && go mod download
125-
126-
- name: Run Key Generation E2E tests
127-
run: |
128-
cd e2e
129-
go test -v -timeout=1200s -run TestKeyGeneration
130-
env:
131-
DOCKER_BUILDKIT: 1
132-
133-
- name: Cleanup Docker containers
134-
if: always()
135-
run: |
136-
cd e2e
137-
docker compose -f docker-compose.test.yaml down -v || true
138-
docker system prune -f || true
139-
140-
- name: Upload keygen test logs
141-
if: failure()
142-
uses: actions/upload-artifact@v4
143-
with:
144-
name: e2e-keygen-test-logs
145-
path: e2e/logs/
146-
retention-days: 7
147-
148-
# Signing E2E Tests
149-
e2e-signing:
150-
runs-on: ubuntu-latest
151-
needs: build
152-
153-
steps:
154-
- name: Checkout code
155-
uses: actions/checkout@v4
156-
157-
- name: Set up Go
158-
uses: actions/setup-go@v4
159-
with:
160-
go-version: "1.23"
161-
162-
- name: Tidy Go modules
163-
run: |
164-
go mod tidy
165-
166-
- name: Set up Docker Buildx
167-
uses: docker/setup-buildx-action@v3
168-
169-
- name: Verify Docker Compose
170-
run: |
171-
docker --version
172-
docker compose version
173-
174-
- name: Cache Go modules
175-
uses: actions/cache@v3
176-
with:
177-
path: |
178-
~/.cache/go-build
179-
~/go/pkg/mod
180-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
181-
restore-keys: |
182-
${{ runner.os }}-go-
183-
184-
- name: Restore binaries
185-
uses: actions/cache@v3
186-
with:
187-
path: |
188-
./mpcium
189-
./mpcium-cli
190-
key: ${{ needs.build.outputs.cache-key }}
191-
192-
- name: Install binaries
193-
run: |
194-
sudo mv mpcium /usr/local/bin/
195-
sudo mv mpcium-cli /usr/local/bin/
196-
197-
- name: Verify binaries are available
198-
run: |
199-
which mpcium
200-
which mpcium-cli
201-
mpcium --version || echo "mpcium binary ready"
202-
mpcium-cli --version || echo "mpcium-cli binary ready"
203-
204-
- name: Install E2E dependencies
205-
run: |
206-
cd e2e && go mod tidy && go mod download
207-
208-
- name: Run Signing E2E tests
209-
run: |
210-
cd e2e
211-
go test -v -timeout=1200s -run TestSigning
212-
env:
213-
DOCKER_BUILDKIT: 1
214-
215-
- name: Cleanup Docker containers
216-
if: always()
217-
run: |
218-
cd e2e
219-
docker compose -f docker-compose.test.yaml down -v || true
220-
docker system prune -f || true
221-
222-
- name: Upload signing test logs
223-
if: failure()
224-
uses: actions/upload-artifact@v4
225-
with:
226-
name: e2e-signing-test-logs
227-
path: e2e/logs/
228-
retention-days: 7
229-
230-
# Resharing E2E Tests
231-
e2e-resharing:
52+
e2e:
23253
runs-on: ubuntu-latest
23354
needs: build
234-
55+
strategy:
56+
matrix:
57+
testcase: [TestKeyGeneration, TestSigning, TestResharing]
23558
steps:
236-
- name: Checkout code
237-
uses: actions/checkout@v4
59+
- uses: actions/checkout@v4
23860

239-
- name: Set up Go
240-
uses: actions/setup-go@v4
61+
- uses: actions/setup-go@v5
24162
with:
242-
go-version: "1.23"
243-
244-
- name: Tidy Go modules
245-
run: |
246-
go mod tidy
63+
go-version: ${{ env.GO_VERSION }}
64+
cache-dependency-path: "**/go.sum"
24765

248-
- name: Set up Docker Buildx
249-
uses: docker/setup-buildx-action@v3
66+
- uses: docker/setup-buildx-action@v3
25067

251-
- name: Verify Docker Compose
252-
run: |
253-
docker --version
254-
docker compose version
255-
256-
- name: Cache Go modules
257-
uses: actions/cache@v3
258-
with:
259-
path: |
260-
~/.cache/go-build
261-
~/go/pkg/mod
262-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
263-
restore-keys: |
264-
${{ runner.os }}-go-
68+
- run: docker --version && docker compose version
26569

266-
- name: Restore binaries
267-
uses: actions/cache@v3
70+
- uses: actions/cache@v4
26871
with:
26972
path: |
27073
./mpcium
27174
./mpcium-cli
27275
key: ${{ needs.build.outputs.cache-key }}
27376

274-
- name: Install binaries
275-
run: |
276-
sudo mv mpcium /usr/local/bin/
277-
sudo mv mpcium-cli /usr/local/bin/
77+
- run: sudo mv mpcium /usr/local/bin/ && sudo mv mpcium-cli /usr/local/bin/
27878

279-
- name: Verify binaries are available
280-
run: |
281-
which mpcium
282-
which mpcium-cli
283-
mpcium --version || echo "mpcium binary ready"
284-
mpcium-cli --version || echo "mpcium-cli binary ready"
79+
- run: which mpcium && which mpcium-cli
28580

286-
- name: Install E2E dependencies
287-
run: |
288-
cd e2e && go mod tidy && go mod download
289-
290-
- name: Run Resharing E2E tests
291-
run: |
292-
cd e2e
293-
go test -v -timeout=1200s -run TestResharing
294-
env:
295-
DOCKER_BUILDKIT: 1
81+
- run: cd e2e && go mod tidy
29682

297-
- name: Cleanup Docker containers
298-
if: always()
83+
- name: Run ${{ matrix.testcase }} E2E tests
29984
run: |
30085
cd e2e
301-
docker compose -f docker-compose.test.yaml down -v || true
302-
docker system prune -f || true
86+
go test -v -timeout=1200s -run ${{ matrix.testcase }}
30387
304-
- name: Upload resharing test logs
88+
- name: Upload test logs
30589
if: failure()
30690
uses: actions/upload-artifact@v4
30791
with:
308-
name: e2e-resharing-test-logs
92+
name: e2e-${{ matrix.testcase }}-test-logs
30993
path: e2e/logs/
31094
retention-days: 7
31195

312-
# Summary job that depends on all E2E tests
313-
e2e-summary:
96+
summary:
31497
runs-on: ubuntu-latest
315-
needs: [e2e-keygen, e2e-signing, e2e-resharing]
98+
needs: e2e
31699
if: always()
317-
318100
steps:
319-
- name: Check E2E test results
320-
run: |
101+
- run: |
321102
echo "E2E Test Results Summary:"
322103
echo "========================="
323-
echo "Key Generation Tests: ${{ needs.e2e-keygen.result }}"
324-
echo "Signing Tests: ${{ needs.e2e-signing.result }}"
325-
echo "Resharing Tests: ${{ needs.e2e-resharing.result }}"
326-
echo ""
104+
echo "Matrix job status: ${{ needs.e2e.result }}"
327105
328-
# Check if any tests failed
329-
if [[ "${{ needs.e2e-keygen.result }}" != "success" || "${{ needs.e2e-signing.result }}" != "success" || "${{ needs.e2e-resharing.result }}" != "success" ]]; then
106+
if [[ "${{ needs.e2e.result }}" == "success" ]]; then
107+
echo "✅ All E2E tests passed successfully"
108+
else
330109
echo "❌ One or more E2E tests failed"
331110
exit 1
332-
else
333-
echo "✅ All E2E tests passed successfully"
334111
fi

0 commit comments

Comments
 (0)