-
Notifications
You must be signed in to change notification settings - Fork 63
296 lines (281 loc) · 9.87 KB
/
ci.yml
File metadata and controls
296 lines (281 loc) · 9.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
name: EasyCrypt CI
on:
push:
branches:
- 'main'
- 'release'
- 'latest'
tags:
- 'r[0-9]+.[0-9]+'
pull_request:
merge_group:
env:
IMAGE_TAG: ci-${{ github.run_id }}
jobs:
# ── Phase 1: Build Docker images and share via artifact ──
docker:
name: Build Docker images
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Build base image
run: make -C scripts/docker build VARIANT=base TAG=$IMAGE_TAG
- name: Build build image
run: make -C scripts/docker build VARIANT=build TAG=$IMAGE_TAG
- name: Save images for downstream jobs
run: |
docker save "ghcr.io/easycrypt/ec-base-box:$IMAGE_TAG" | gzip > base-image.tar.gz
docker save "ghcr.io/easycrypt/ec-build-box:$IMAGE_TAG" | gzip > build-image.tar.gz
- uses: actions/upload-artifact@v4
with:
name: docker-images
path: |
base-image.tar.gz
build-image.tar.gz
retention-days: 1
# ── Phase 2: CI ──
compile-opam:
name: EasyCrypt compilation (opam)
needs: docker
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: docker-images
- run: gunzip -c build-image.tar.gz | docker load
- name: Install dependencies & compile
run: |
docker run --rm \
-v "$PWD:/workspace" \
-w /workspace \
-e HOME=/home/charlie \
-e OPAMYES=true \
-e OPAMJOBS=2 \
"ghcr.io/easycrypt/ec-build-box:$IMAGE_TAG" \
bash -c "
set -e
opam pin add -n easycrypt .
opam install --deps-only --depext-only --confirm-level=unsafe-yes easycrypt
opam install --deps-only easycrypt
opam exec -- make PROFILE=ci
"
compile-nix:
name: EasyCrypt compilation (nix)
env:
HOME: /home/runner
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Setup Nix
uses: cachix/install-nix-action@v26
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Setup Cachix
uses: cachix/cachix-action@v14
with:
name: formosa-crypto
authToken: '${{ secrets.CACHIX_WRITE_TOKEN }}'
- name: Build and cache EasyCrypt and dependencies
run: |
make nix-build-with-provers
check:
name: Check EasyCrypt Libraries
needs: [docker, compile-opam]
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
target: [unit, stdlib, examples]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: docker-images
- run: gunzip -c build-image.tar.gz | docker load
- name: Install, compile & test (${{ matrix.target }})
run: |
docker run --rm \
-v "$PWD:/workspace" \
-w /workspace \
-e HOME=/home/charlie \
-e OPAMYES=true \
-e OPAMJOBS=2 \
-e TARGET=${{ matrix.target }} \
"ghcr.io/easycrypt/ec-build-box:$IMAGE_TAG" \
bash -c "
set -e
opam pin add -n easycrypt .
opam install --deps-only --depext-only --confirm-level=unsafe-yes easycrypt
opam install --deps-only easycrypt
opam exec -- make
rm -f ~/.why3.conf
opam exec -- ./ec.native why3config -why3 ~/.why3.conf
opam exec -- make \$TARGET
"
- uses: actions/upload-artifact@v4
name: Upload report.log
if: always()
with:
name: report.log (${{ matrix.target }})
path: report.log
if-no-files-found: ignore
fetch-external-matrix:
name: Fetch EasyCrypt External Projects Matrix
runs-on: ubuntu-24.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
path: 'easycrypt'
- id: set-matrix
run: |
JSON=$(jq -c . < easycrypt/.github/workflows/external.json)
echo "matrix=${JSON}" >> $GITHUB_OUTPUT
external:
name: Check EasyCrypt External Projects
needs: [docker, compile-opam, fetch-external-matrix]
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
target: ${{fromJson(needs.fetch-external-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
with:
path: easycrypt
- name: Extract target branch name
id: extract_branch
run: echo "branch=merge-${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
- name: Find remote branch
id: branch_name
run: |
git ls-remote --exit-code --heads ${{ matrix.target.repository }} refs/heads/${{ steps.extract_branch.outputs.branch }} || exists=$?
if [ "$exists" = "2" ];
then echo "REPO_BRANCH=${{ matrix.target.branch }}" >> $GITHUB_OUTPUT;
else echo "REPO_BRANCH=${{ steps.extract_branch.outputs.branch }}" >> $GITHUB_OUTPUT;
fi
- name: Checkout External Project
run: |
git clone --recurse-submodules \
-b ${{ steps.branch_name.outputs.REPO_BRANCH }} \
${{ matrix.target.repository }} \
project/${{ matrix.target.name }}
- uses: actions/download-artifact@v4
with:
name: docker-images
- run: gunzip -c build-image.tar.gz | docker load
- name: Install, compile & test external project
run: |
docker run --rm \
-v "$PWD:/workspace" \
-w /workspace \
-e HOME=/home/charlie \
-e OPAMYES=true \
-e OPAMJOBS=2 \
"ghcr.io/easycrypt/ec-build-box:$IMAGE_TAG" \
bash -c "
set -e
opam pin add -n easycrypt easycrypt
opam install --deps-only --depext-only --confirm-level=unsafe-yes easycrypt
opam install --deps-only easycrypt
opam exec -- make -C easycrypt build install
rm -f ~/.why3.conf ~/.config/easycrypt/why3.conf
opam exec -- easycrypt why3config
cd project/${{ matrix.target.name }}/${{ matrix.target.subdir }}
opam exec -- easycrypt runtest \
-report report.log \
${{ matrix.target.options }} \
${{ matrix.target.config }} \
${{ matrix.target.scenario }}
"
- name: Compute real-path to report.log
if: always()
run: |
echo "report=$(realpath project/${{ matrix.target.name }}/${{ matrix.target.subdir }})/report.log" >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
name: Upload report.log
if: always()
with:
name: report.log (${{ matrix.target.name }})
path: ${{ env.report }}
if-no-files-found: ignore
external-status:
name: Check EasyCrypt External Projects (set-status)
if: always()
needs: [external]
runs-on: ubuntu-24.04
steps:
- uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
allowed-skips: external
# ── Phase 3: Publish to GHCR (only on push after CI passes) ──
publish:
name: Publish Docker images
if: |
github.event_name == 'push' && (
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/release' ||
github.ref == 'refs/heads/latest' ||
startsWith(github.ref, 'refs/tags/r')
)
needs: [compile-opam, compile-nix, check, external, external-status, docker]
runs-on: ubuntu-24.04
permissions:
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: docker-images
- run: gunzip -c base-image.tar.gz | docker load
- run: gunzip -c build-image.tar.gz | docker load
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push base image
run: |
docker tag "ghcr.io/easycrypt/ec-base-box:$IMAGE_TAG" \
"ghcr.io/easycrypt/ec-base-box:${{ github.ref_name }}"
docker push "ghcr.io/easycrypt/ec-base-box:${{ github.ref_name }}"
- name: Push build image
run: |
docker tag "ghcr.io/easycrypt/ec-build-box:$IMAGE_TAG" \
"ghcr.io/easycrypt/ec-build-box:${{ github.ref_name }}"
docker push "ghcr.io/easycrypt/ec-build-box:${{ github.ref_name }}"
- name: Build and push test image
if: |
github.ref == 'refs/heads/release' ||
github.ref == 'refs/heads/latest' ||
github.ref_type == 'tag'
run: |
make -C scripts/docker build VARIANT=test TAG=${{ github.ref_name }}
make -C scripts/docker publish VARIANT=test TAG=${{ github.ref_name }}
# ── Notification ──
notification:
name: Notification
needs: [compile-opam, compile-nix, check, external, external-status]
if: |
(github.event_name == 'push') ||
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
runs-on: ubuntu-24.04
steps:
- uses: technote-space/workflow-conclusion-action@v3
- uses: zulip/github-actions-zulip/send-message@v1
with:
api-key: ${{ secrets.ZULIP_APIKEY }}
email: ${{ secrets.ZULIP_EMAIL }}
organization-url: 'https://formosa-crypto.zulipchat.com'
type: 'stream'
to: 'GitHub notifications'
topic: 'EasyCrypt / CI'
content: |
**Build status**: ${{ env.WORKFLOW_CONCLUSION }} ${{ env.WORKFLOW_CONCLUSION == 'success' && ':check_mark:' || ':cross_mark:' }}
**Author**: [${{ github.actor }}](${{ github.server_url }}/${{ github.actor }})
**Event**: ${{ github.event_name }} on ${{ github.ref }}
**Commit**: [${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})
**Details**: [Build log](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}/checks)