Skip to content

Commit 713cb98

Browse files
committed
Add GitHub Actions CI
1 parent 6506ca4 commit 713cb98

14 files changed

Lines changed: 793 additions & 22 deletions

File tree

.github/workflows/_build.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Compiler build (reusable)
2+
3+
# Reusable: compile the MiniZinc compiler for ONE platform against the pinned
4+
# minizinc-vendor release (vendor.lock) and upload it as the `minizinc-<platform>`
5+
# artifact. Called by ci.yml (matrixed over all platforms) and benchmark.yml
6+
# (linux only). Not triggered directly.
7+
#
8+
# Same build model as minizinc-vendor: glibc-linux builds run in a manylinux
9+
# container (low glibc floor), musl in alpine, osx/win64 natively. A per-platform
10+
# `setup` installs whatever the bare base image lacks, then scripts/build.sh runs.
11+
12+
on:
13+
workflow_call:
14+
inputs:
15+
platform: { type: string, required: true }
16+
triple: { type: string, required: true }
17+
runner: { type: string, required: true }
18+
container: { type: string, default: "" }
19+
setup: { type: string, default: "" } # deps to install in the container
20+
generator: { type: string, default: "Ninja" } # manylinux -> "Unix Makefiles"
21+
22+
permissions:
23+
contents: read
24+
25+
env:
26+
# Lets `gh release download` read minizinc-vendor's (public) releases.
27+
GH_TOKEN: ${{ github.token }}
28+
29+
jobs:
30+
build:
31+
runs-on: ${{ inputs.runner }}
32+
name: build
33+
steps:
34+
- uses: actions/checkout@v7
35+
36+
# TODO: re-add `cbc` (fetch here + -DOsiCBC_ROOT in scripts/build.sh) once
37+
# cbc:win64 is fixed and CBC is reactivated in minizinc-vendor.
38+
- name: Fetch pinned vendor deps (gecode)
39+
shell: bash
40+
run: bash scripts/fetch_vendor.sh ${{ inputs.triple }} gecode
41+
42+
- name: Set up MSVC (win64)
43+
if: startsWith(inputs.platform, 'win64')
44+
uses: ilammy/msvc-dev-cmd@v1
45+
with:
46+
arch: ${{ inputs.platform == 'win64-arm' && 'arm64' || 'x64' }}
47+
48+
- name: Configure & build
49+
shell: bash
50+
env:
51+
# MSVC reports __cplusplus as 199711L unless asked not to, so Gecode's
52+
# bundled Boost cannot pick a rounding-control implementation on ARM64,
53+
# where its x86/x64 paths do not apply. minizinc-vendor builds Gecode
54+
# itself with the same flag.
55+
CXXFLAGS: ${{ inputs.platform == 'win64-arm' && '/Zc:__cplusplus' || '' }}
56+
run: |
57+
set -eux
58+
SETUP='${{ inputs.setup }}'
59+
if [ -n "${{ inputs.container }}" ]; then
60+
docker run --rm -v "$PWD:/work" -w /work \
61+
-e ROOT=/work \
62+
-e CMAKE_GENERATOR="${{ inputs.generator }}" \
63+
-e BUILD_REF="${{ github.run_id }}" \
64+
"${{ inputs.container }}" \
65+
sh -c "${SETUP}${SETUP:+ && }bash scripts/build.sh"
66+
else
67+
ROOT="$PWD" \
68+
CMAKE_GENERATOR="${{ inputs.generator }}" \
69+
BUILD_REF="${{ github.run_id }}" \
70+
bash scripts/build.sh
71+
fi
72+
73+
# Catches the deployment target silently following the runner image.
74+
- name: Check macOS deployment target
75+
if: inputs.platform == 'osx'
76+
shell: bash
77+
run: vtool -show-build minizinc/bin/minizinc | grep -w "minos 12.0"
78+
79+
# Archived here, not uploaded as a tree: artifacts do not preserve the
80+
# executable bit, so a bare tree arrives unrunnable and every consumer has
81+
# to chmod it back. This tarball is also exactly what the release ships, so
82+
# it is built once and never repacked.
83+
- name: Archive
84+
shell: bash
85+
run: tar -czf "minizinc-compiler-only-${{ inputs.triple }}.tar.gz" -C minizinc .
86+
87+
- uses: actions/upload-artifact@v7
88+
with:
89+
name: minizinc-${{ inputs.platform }}
90+
path: minizinc-compiler-only-${{ inputs.triple }}.tar.gz

.github/workflows/benchmark.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Benchmarks
2+
3+
# SLURM flattening benchmarks. Manual-dispatch only (GitHub-hosted runners cannot
4+
# reach SLURM); the bench job targets a self-hosted runner. Builds linux via the
5+
# reusable _build.yml, then flattens a benchmark set through the compiler.
6+
7+
on:
8+
workflow_dispatch: {}
9+
10+
permissions:
11+
contents: read
12+
13+
env:
14+
GH_TOKEN: ${{ github.token }}
15+
16+
jobs:
17+
build:
18+
name: build (linux)
19+
uses: ./.github/workflows/_build.yml
20+
with:
21+
platform: linux
22+
triple: x86_64-linux-gnu
23+
runner: ubuntu-24.04
24+
container: "quay.io/pypa/manylinux_2_28_x86_64"
25+
generator: "Unix Makefiles"
26+
27+
bench:
28+
name: flatten (${{ matrix.mznlib }})
29+
needs: build
30+
strategy:
31+
matrix:
32+
mznlib: [std, linear]
33+
runs-on: [self-hosted, slurm]
34+
steps:
35+
- uses: actions/checkout@v7
36+
- uses: actions/download-artifact@v8
37+
with:
38+
name: minizinc-linux
39+
- name: Unpack the compiler
40+
shell: bash
41+
run: mkdir -p minizinc && tar -xzf minizinc-compiler-only-*.tar.gz -C minizinc
42+
- name: Flatten benchmark
43+
run: |
44+
cd tests/flattening
45+
mkdir -p results
46+
curl --retry 10 --location --silent https://gitlab.com/-/snippets/2095682/raw/master/instances.csv | tr -d '\r' > instances.csv
47+
git clone https://github.com/minizinc/minizinc-benchmarks.git
48+
python3 flatten.py --minizinc="$PWD/../../minizinc/bin/minizinc" \
49+
--prefix-args="srun -w critical001 --nice --mem=8192 -t 10" \
50+
--args="-G ${{ matrix.mznlib }}" --parallel="-1" instances.csv results/stats.csv
51+
- uses: actions/upload-artifact@v7
52+
with:
53+
name: bench-${{ matrix.mznlib }}
54+
path: tests/flattening/results/

0 commit comments

Comments
 (0)