Skip to content

Commit 3deac1e

Browse files
committed
Refactor CI to run in fetch build box
This refactors the CI jobs so compilation and checks (including external CI) run in a fresh build box. This will help ensure that changes to the box configuration (new dependencies, prover updates, prover additions, ...) are reflected quickly in the CI environment and can be leveraged in external proofs right away. The workflow is now: 1. Build base and build boxes, then save them as an artefact; 2. Recover the build box, then run the compilation check; 3. Recover the build box, then compile EasyCrypt and run a matrix check; (this recompiles EC 3 times in parallel, and likely needs changed) 4. Recover the build box, then compile EasyCrypt and run the external matrix checks (this recompiles EC as many times as we have external checks, and likely needs changed) 5. Build the test box, push the base and build boxes (all pushes) and the test box (release branches and tags) The nix compilation check is unchanged, notification fires after all succeed. Documentation is built as normal.
1 parent b0c4c72 commit 3deac1e

2 files changed

Lines changed: 152 additions & 104 deletions

File tree

.github/workflows/ci.yml

Lines changed: 152 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,71 @@
1-
name: EasyCrypt compilation & check
1+
name: EasyCrypt CI
22

33
on:
44
push:
55
branches:
66
- 'main'
7+
- 'release'
8+
- 'latest'
9+
tags:
10+
- 'r[0-9]+.[0-9]+'
711
pull_request:
812
merge_group:
913

1014
env:
11-
HOME: /home/charlie
12-
OPAMYES: true
13-
OPAMJOBS: 2
15+
IMAGE_TAG: ci-${{ github.run_id }}
1416

1517
jobs:
18+
# ── Phase 1: Build Docker images and share via artifact ──
19+
20+
docker:
21+
name: Build Docker images
22+
runs-on: ubuntu-24.04
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Build base image
26+
run: make -C scripts/docker build VARIANT=base TAG=$IMAGE_TAG
27+
- name: Build build image
28+
run: make -C scripts/docker build VARIANT=build TAG=$IMAGE_TAG
29+
- name: Save images for downstream jobs
30+
run: |
31+
docker save "ghcr.io/easycrypt/ec-base-box:$IMAGE_TAG" | gzip > base-image.tar.gz
32+
docker save "ghcr.io/easycrypt/ec-build-box:$IMAGE_TAG" | gzip > build-image.tar.gz
33+
- uses: actions/upload-artifact@v4
34+
with:
35+
name: docker-images
36+
path: |
37+
base-image.tar.gz
38+
build-image.tar.gz
39+
retention-days: 1
40+
41+
# ── Phase 2: CI ──
42+
1643
compile-opam:
1744
name: EasyCrypt compilation (opam)
45+
needs: docker
1846
runs-on: ubuntu-24.04
19-
container:
20-
image: ghcr.io/easycrypt/ec-build-box:main
2147
steps:
2248
- uses: actions/checkout@v4
23-
- name: Install EasyCrypt dependencies
49+
- uses: actions/download-artifact@v4
50+
with:
51+
name: docker-images
52+
- run: gunzip -c build-image.tar.gz | docker load
53+
- name: Install dependencies & compile
2454
run: |
25-
opam pin add -n easycrypt .
26-
opam install --deps-only --depext-only --confirm-level=unsafe-yes easycrypt
27-
opam install --deps-only easycrypt
28-
- name: Compile EasyCrypt
29-
run: opam exec -- make PROFILE=ci
55+
docker run --rm \
56+
-v "$PWD:/workspace" \
57+
-w /workspace \
58+
-e HOME=/home/charlie \
59+
-e OPAMYES=true \
60+
-e OPAMJOBS=2 \
61+
"ghcr.io/easycrypt/ec-build-box:$IMAGE_TAG" \
62+
bash -c "
63+
set -e
64+
opam pin add -n easycrypt .
65+
opam install --deps-only --depext-only --confirm-level=unsafe-yes easycrypt
66+
opam install --deps-only easycrypt
67+
opam exec -- make PROFILE=ci
68+
"
3069
3170
compile-nix:
3271
name: EasyCrypt compilation (nix)
@@ -50,31 +89,38 @@ jobs:
5089
5190
check:
5291
name: Check EasyCrypt Libraries
53-
needs: compile-opam
92+
needs: [docker, compile-opam]
5493
runs-on: ubuntu-24.04
55-
container:
56-
image: ghcr.io/easycrypt/ec-build-box:main
5794
strategy:
5895
fail-fast: false
5996
matrix:
6097
target: [unit, stdlib, examples]
6198
steps:
6299
- uses: actions/checkout@v4
63-
- name: Install EasyCrypt dependencies
64-
run: |
65-
opam pin add -n easycrypt .
66-
opam install --deps-only --depext-only --confirm-level=unsafe-yes easycrypt
67-
opam install --deps-only easycrypt
68-
- name: Compile EasyCrypt
69-
run: opam exec -- make
70-
- name: Detect SMT provers
100+
- uses: actions/download-artifact@v4
101+
with:
102+
name: docker-images
103+
- run: gunzip -c build-image.tar.gz | docker load
104+
- name: Install, compile & test (${{ matrix.target }})
71105
run: |
72-
rm -f ~/.why3.conf
73-
opam exec -- ./ec.native why3config -why3 ~/.why3.conf
74-
- name: Compile Library (${{ matrix.target }})
75-
env:
76-
TARGET: ${{ matrix.target }}
77-
run: opam exec -- make $TARGET
106+
docker run --rm \
107+
-v "$PWD:/workspace" \
108+
-w /workspace \
109+
-e HOME=/home/charlie \
110+
-e OPAMYES=true \
111+
-e OPAMJOBS=2 \
112+
-e TARGET=${{ matrix.target }} \
113+
"ghcr.io/easycrypt/ec-build-box:$IMAGE_TAG" \
114+
bash -c "
115+
set -e
116+
opam pin add -n easycrypt .
117+
opam install --deps-only --depext-only --confirm-level=unsafe-yes easycrypt
118+
opam install --deps-only easycrypt
119+
opam exec -- make
120+
rm -f ~/.why3.conf
121+
opam exec -- ./ec.native why3config -why3 ~/.why3.conf
122+
opam exec -- make \$TARGET
123+
"
78124
- uses: actions/upload-artifact@v4
79125
name: Upload report.log
80126
if: always()
@@ -99,10 +145,8 @@ jobs:
99145
100146
external:
101147
name: Check EasyCrypt External Projects
102-
needs: [compile-opam, fetch-external-matrix]
148+
needs: [docker, compile-opam, fetch-external-matrix]
103149
runs-on: ubuntu-24.04
104-
container:
105-
image: ghcr.io/easycrypt/ec-build-box:main
106150
strategy:
107151
fail-fast: false
108152
matrix:
@@ -112,8 +156,8 @@ jobs:
112156
with:
113157
path: easycrypt
114158
- name: Extract target branch name
115-
run: echo "branch=merge-${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
116159
id: extract_branch
160+
run: echo "branch=merge-${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
117161
- name: Find remote branch
118162
id: branch_name
119163
run: |
@@ -128,25 +172,34 @@ jobs:
128172
-b ${{ steps.branch_name.outputs.REPO_BRANCH }} \
129173
${{ matrix.target.repository }} \
130174
project/${{ matrix.target.name }}
131-
- name: Install EasyCrypt dependencies
132-
run: |
133-
opam pin add -n easycrypt easycrypt
134-
opam install --deps-only --depext-only --confirm-level=unsafe-yes easycrypt
135-
opam install --deps-only easycrypt
136-
- name: Compile & Install EasyCrypt
137-
run: opam exec -- make -C easycrypt build install
138-
- name: Detect SMT provers
139-
run: |
140-
rm -f ~/.why3.conf ~/.config/easycrypt/why3.conf
141-
opam exec -- easycrypt why3config
142-
- name: Compile project
143-
working-directory: project/${{ matrix.target.name }}/${{ matrix.target.subdir }}
175+
- uses: actions/download-artifact@v4
176+
with:
177+
name: docker-images
178+
- run: gunzip -c build-image.tar.gz | docker load
179+
- name: Install, compile & test external project
144180
run: |
145-
opam exec -- easycrypt runtest \
146-
-report report.log \
147-
${{ matrix.target.options }} \
148-
${{ matrix.target.config }} \
149-
${{ matrix.target.scenario }}
181+
docker run --rm \
182+
-v "$PWD:/workspace" \
183+
-w /workspace \
184+
-e HOME=/home/charlie \
185+
-e OPAMYES=true \
186+
-e OPAMJOBS=2 \
187+
"ghcr.io/easycrypt/ec-build-box:$IMAGE_TAG" \
188+
bash -c "
189+
set -e
190+
opam pin add -n easycrypt easycrypt
191+
opam install --deps-only --depext-only --confirm-level=unsafe-yes easycrypt
192+
opam install --deps-only easycrypt
193+
opam exec -- make -C easycrypt build install
194+
rm -f ~/.why3.conf ~/.config/easycrypt/why3.conf
195+
opam exec -- easycrypt why3config
196+
cd project/${{ matrix.target.name }}/${{ matrix.target.subdir }}
197+
opam exec -- easycrypt runtest \
198+
-report report.log \
199+
${{ matrix.target.options }} \
200+
${{ matrix.target.config }} \
201+
${{ matrix.target.scenario }}
202+
"
150203
- name: Compute real-path to report.log
151204
if: always()
152205
run: |
@@ -170,6 +223,54 @@ jobs:
170223
jobs: ${{ toJSON(needs) }}
171224
allowed-skips: external
172225

226+
# ── Phase 3: Publish to GHCR (only on push after CI passes) ──
227+
228+
publish:
229+
name: Publish Docker images
230+
if: |
231+
github.event_name == 'push' && (
232+
github.ref == 'refs/heads/main' ||
233+
github.ref == 'refs/heads/release' ||
234+
github.ref == 'refs/heads/latest' ||
235+
startsWith(github.ref, 'refs/tags/r')
236+
)
237+
needs: [compile-opam, compile-nix, check, external, external-status, docker]
238+
runs-on: ubuntu-24.04
239+
permissions:
240+
packages: write
241+
steps:
242+
- uses: actions/checkout@v4
243+
- uses: actions/download-artifact@v4
244+
with:
245+
name: docker-images
246+
- run: gunzip -c base-image.tar.gz | docker load
247+
- run: gunzip -c build-image.tar.gz | docker load
248+
- uses: docker/login-action@v3
249+
with:
250+
registry: ghcr.io
251+
username: ${{ github.actor }}
252+
password: ${{ secrets.GITHUB_TOKEN }}
253+
- name: Push base image
254+
run: |
255+
docker tag "ghcr.io/easycrypt/ec-base-box:$IMAGE_TAG" \
256+
"ghcr.io/easycrypt/ec-base-box:${{ github.ref_name }}"
257+
docker push "ghcr.io/easycrypt/ec-base-box:${{ github.ref_name }}"
258+
- name: Push build image
259+
run: |
260+
docker tag "ghcr.io/easycrypt/ec-build-box:$IMAGE_TAG" \
261+
"ghcr.io/easycrypt/ec-build-box:${{ github.ref_name }}"
262+
docker push "ghcr.io/easycrypt/ec-build-box:${{ github.ref_name }}"
263+
- name: Build and push test image
264+
if: |
265+
github.ref == 'refs/heads/release' ||
266+
github.ref == 'refs/heads/latest' ||
267+
github.ref_type == 'tag'
268+
run: |
269+
make -C scripts/docker build VARIANT=test TAG=${{ github.ref_name }}
270+
make -C scripts/docker publish VARIANT=test TAG=${{ github.ref_name }}
271+
272+
# ── Notification ──
273+
173274
notification:
174275
name: Notification
175276
needs: [compile-opam, compile-nix, check, external, external-status]

.github/workflows/docker.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)