|
6 | 6 | pull_request: |
7 | 7 | branches: [master] |
8 | 8 |
|
| 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 | + |
9 | 19 | jobs: |
10 | | - # Build job that creates the binaries needed by all E2E test jobs |
11 | 20 | build: |
12 | 21 | runs-on: ubuntu-latest |
13 | 22 | outputs: |
14 | 23 | cache-key: ${{ steps.cache-key.outputs.key }} |
15 | | - |
16 | 24 | steps: |
17 | | - - name: Checkout code |
18 | | - uses: actions/checkout@v4 |
| 25 | + - uses: actions/checkout@v4 |
19 | 26 |
|
20 | | - - name: Set up Go |
21 | | - uses: actions/setup-go@v4 |
| 27 | + - uses: actions/setup-go@v5 |
22 | 28 | with: |
23 | | - go-version: "1.23" |
| 29 | + go-version: ${{ env.GO_VERSION }} |
| 30 | + cache-dependency-path: "**/go.sum" |
24 | 31 |
|
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 |
31 | 33 | run: echo "key=${{ runner.os }}-binaries-${{ hashFiles('**/go.sum', '**/*.go') }}" >> $GITHUB_OUTPUT |
32 | 34 |
|
33 | | - - name: Cache binaries |
| 35 | + - uses: actions/cache@v4 |
34 | 36 | id: cache-binaries |
35 | | - uses: actions/cache@v3 |
36 | 37 | with: |
37 | 38 | path: | |
38 | 39 | ./mpcium |
39 | 40 | ./mpcium-cli |
40 | 41 | key: ${{ steps.cache-key.outputs.key }} |
41 | 42 |
|
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 |
58 | 45 |
|
59 | | - - name: Build binaries |
60 | | - if: steps.cache-binaries.outputs.cache-hit != 'true' |
| 46 | + - if: steps.cache-binaries.outputs.cache-hit != 'true' |
61 | 47 | 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 |
64 | 50 | chmod +x mpcium mpcium-cli |
65 | 51 |
|
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: |
232 | 53 | runs-on: ubuntu-latest |
233 | 54 | needs: build |
234 | | - |
| 55 | + strategy: |
| 56 | + matrix: |
| 57 | + testcase: [TestKeyGeneration, TestSigning, TestResharing] |
235 | 58 | steps: |
236 | | - - name: Checkout code |
237 | | - uses: actions/checkout@v4 |
| 59 | + - uses: actions/checkout@v4 |
238 | 60 |
|
239 | | - - name: Set up Go |
240 | | - uses: actions/setup-go@v4 |
| 61 | + - uses: actions/setup-go@v5 |
241 | 62 | 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" |
247 | 65 |
|
248 | | - - name: Set up Docker Buildx |
249 | | - uses: docker/setup-buildx-action@v3 |
| 66 | + - uses: docker/setup-buildx-action@v3 |
250 | 67 |
|
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 |
265 | 69 |
|
266 | | - - name: Restore binaries |
267 | | - uses: actions/cache@v3 |
| 70 | + - uses: actions/cache@v4 |
268 | 71 | with: |
269 | 72 | path: | |
270 | 73 | ./mpcium |
271 | 74 | ./mpcium-cli |
272 | 75 | key: ${{ needs.build.outputs.cache-key }} |
273 | 76 |
|
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/ |
278 | 78 |
|
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 |
285 | 80 |
|
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 |
296 | 82 |
|
297 | | - - name: Cleanup Docker containers |
298 | | - if: always() |
| 83 | + - name: Run ${{ matrix.testcase }} E2E tests |
299 | 84 | run: | |
300 | 85 | 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 }} |
303 | 87 |
|
304 | | - - name: Upload resharing test logs |
| 88 | + - name: Upload test logs |
305 | 89 | if: failure() |
306 | 90 | uses: actions/upload-artifact@v4 |
307 | 91 | with: |
308 | | - name: e2e-resharing-test-logs |
| 92 | + name: e2e-${{ matrix.testcase }}-test-logs |
309 | 93 | path: e2e/logs/ |
310 | 94 | retention-days: 7 |
311 | 95 |
|
312 | | - # Summary job that depends on all E2E tests |
313 | | - e2e-summary: |
| 96 | + summary: |
314 | 97 | runs-on: ubuntu-latest |
315 | | - needs: [e2e-keygen, e2e-signing, e2e-resharing] |
| 98 | + needs: e2e |
316 | 99 | if: always() |
317 | | - |
318 | 100 | steps: |
319 | | - - name: Check E2E test results |
320 | | - run: | |
| 101 | + - run: | |
321 | 102 | echo "E2E Test Results Summary:" |
322 | 103 | 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 }}" |
327 | 105 |
|
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 |
330 | 109 | echo "❌ One or more E2E tests failed" |
331 | 110 | exit 1 |
332 | | - else |
333 | | - echo "✅ All E2E tests passed successfully" |
334 | 111 | fi |
0 commit comments