Skip to content

Commit daa33ee

Browse files
committed
consolidate builds
1 parent 3deac1e commit daa33ee

1 file changed

Lines changed: 71 additions & 109 deletions

File tree

.github/workflows/ci.yml

Lines changed: 71 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -13,59 +13,51 @@ on:
1313

1414
env:
1515
IMAGE_TAG: ci-${{ github.run_id }}
16+
OPAMYES: true
17+
OPAMJOBS: 2
1618

1719
jobs:
18-
# ── Phase 1: Build Docker images and share via artifact ──
20+
# ── Phase 1: Build and push all Docker images ──
1921

2022
docker:
21-
name: Build Docker images
23+
name: Build and push Docker images
2224
runs-on: ubuntu-24.04
25+
permissions:
26+
packages: write
2327
steps:
2428
- 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
29+
- uses: docker/login-action@v3
3430
with:
35-
name: docker-images
36-
path: |
37-
base-image.tar.gz
38-
build-image.tar.gz
39-
retention-days: 1
31+
registry: ghcr.io
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
- name: Build and push base image
35+
run: |
36+
make -C scripts/docker build publish VARIANT=base TAG=$IMAGE_TAG
37+
- name: Build and push build image
38+
run: |
39+
make -C scripts/docker build publish VARIANT=build TAG=$IMAGE_TAG
40+
- name: Build and push test image
41+
run: |
42+
make -C scripts/docker build publish VARIANT=test TAG=$IMAGE_TAG
4043
41-
# ── Phase 2: CI ──
44+
# ── Phase 2: Compile CI profile in build box ──
4245

4346
compile-opam:
4447
name: EasyCrypt compilation (opam)
4548
needs: docker
4649
runs-on: ubuntu-24.04
50+
container:
51+
image: ghcr.io/easycrypt/ec-build-box:${{ env.IMAGE_TAG }}
4752
steps:
4853
- uses: actions/checkout@v4
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
54+
- name: Install EasyCrypt dependencies
5455
run: |
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-
"
56+
opam pin add -n easycrypt .
57+
opam install --deps-only --depext-only --confirm-level=unsafe-yes easycrypt
58+
opam install --deps-only easycrypt
59+
- name: Compile EasyCrypt
60+
run: opam exec -- make PROFILE=ci
6961

7062
compile-nix:
7163
name: EasyCrypt compilation (nix)
@@ -87,40 +79,28 @@ jobs:
8779
run: |
8880
make nix-build-with-provers
8981
82+
# ── Phase 3: Test in test box (no rebuild) ──
83+
9084
check:
9185
name: Check EasyCrypt Libraries
92-
needs: [docker, compile-opam]
86+
needs: docker
9387
runs-on: ubuntu-24.04
88+
container:
89+
image: ghcr.io/easycrypt/ec-test-box:${{ env.IMAGE_TAG }}
9490
strategy:
9591
fail-fast: false
9692
matrix:
9793
target: [unit, stdlib, examples]
9894
steps:
9995
- uses: actions/checkout@v4
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 }})
96+
- name: Detect SMT provers
10597
run: |
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-
"
98+
rm -f ~/.why3.conf
99+
opam exec -- easycrypt why3config -why3 ~/.why3.conf
100+
- name: Compile Library (${{ matrix.target }})
101+
env:
102+
TARGET: ${{ matrix.target }}
103+
run: opam exec -- easycrypt runtest config/tests.config $TARGET
124104
- uses: actions/upload-artifact@v4
125105
name: Upload report.log
126106
if: always()
@@ -145,8 +125,10 @@ jobs:
145125
146126
external:
147127
name: Check EasyCrypt External Projects
148-
needs: [docker, compile-opam, fetch-external-matrix]
128+
needs: [docker, fetch-external-matrix]
149129
runs-on: ubuntu-24.04
130+
container:
131+
image: ghcr.io/easycrypt/ec-test-box:${{ env.IMAGE_TAG }}
150132
strategy:
151133
fail-fast: false
152134
matrix:
@@ -156,8 +138,8 @@ jobs:
156138
with:
157139
path: easycrypt
158140
- name: Extract target branch name
159-
id: extract_branch
160141
run: echo "branch=merge-${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
142+
id: extract_branch
161143
- name: Find remote branch
162144
id: branch_name
163145
run: |
@@ -172,34 +154,18 @@ jobs:
172154
-b ${{ steps.branch_name.outputs.REPO_BRANCH }} \
173155
${{ matrix.target.repository }} \
174156
project/${{ matrix.target.name }}
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
157+
- name: Detect SMT provers
158+
run: |
159+
rm -f ~/.why3.conf ~/.config/easycrypt/why3.conf
160+
opam exec -- easycrypt why3config
161+
- name: Compile project
162+
working-directory: project/${{ matrix.target.name }}/${{ matrix.target.subdir }}
180163
run: |
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-
"
164+
opam exec -- easycrypt runtest \
165+
-report report.log \
166+
${{ matrix.target.options }} \
167+
${{ matrix.target.config }} \
168+
${{ matrix.target.scenario }}
203169
- name: Compute real-path to report.log
204170
if: always()
205171
run: |
@@ -223,7 +189,7 @@ jobs:
223189
jobs: ${{ toJSON(needs) }}
224190
allowed-skips: external
225191

226-
# ── Phase 3: Publish to GHCR (only on push after CI passes) ──
192+
# ── Phase 4: Retag and push with permanent tags ──
227193

228194
publish:
229195
name: Publish Docker images
@@ -239,37 +205,33 @@ jobs:
239205
permissions:
240206
packages: write
241207
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
248208
- uses: docker/login-action@v3
249209
with:
250210
registry: ghcr.io
251211
username: ${{ github.actor }}
252212
password: ${{ secrets.GITHUB_TOKEN }}
253-
- name: Push base image
213+
- name: Pull and retag base image
254214
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
215+
docker pull ghcr.io/easycrypt/ec-base-box:${{ env.IMAGE_TAG }}
216+
docker tag ghcr.io/easycrypt/ec-base-box:${{ env.IMAGE_TAG }} \
217+
ghcr.io/easycrypt/ec-base-box:${{ github.ref_name }}
218+
docker push ghcr.io/easycrypt/ec-base-box:${{ github.ref_name }}
219+
- name: Pull and retag build image
259220
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
221+
docker pull ghcr.io/easycrypt/ec-build-box:${{ env.IMAGE_TAG }}
222+
docker tag ghcr.io/easycrypt/ec-build-box:${{ env.IMAGE_TAG }} \
223+
ghcr.io/easycrypt/ec-build-box:${{ github.ref_name }}
224+
docker push ghcr.io/easycrypt/ec-build-box:${{ github.ref_name }}
225+
- name: Pull and retag test image
264226
if: |
265227
github.ref == 'refs/heads/release' ||
266228
github.ref == 'refs/heads/latest' ||
267229
github.ref_type == 'tag'
268230
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 ──
231+
docker pull ghcr.io/easycrypt/ec-test-box:${{ env.IMAGE_TAG }}
232+
docker tag ghcr.io/easycrypt/ec-test-box:${{ env.IMAGE_TAG }} \
233+
ghcr.io/easycrypt/ec-test-box:${{ github.ref_name }}
234+
docker push ghcr.io/easycrypt/ec-test-box:${{ github.ref_name }}
273235
274236
notification:
275237
name: Notification

0 commit comments

Comments
 (0)