Repository navigation
116 lines (106 loc) · 4.55 KB
/
Copy pathci.yml
File metadata and controls
116 lines (106 loc) · 4.55 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
# Generic SMS++ module CI for GitHub: identical in every module repository.
#
# The per-module build recipe is single-sourced from this repo's
# .gitlab-ci.yml: the -DBUILD_* flags are extracted from it, so adding or
# changing a module only ever touches that file, never this workflow.
#
# It runs inside the prebuilt image ghcr.io/smspp-project/smspp-project (the
# same dependencies as the GitLab CI, produced by .github/workflows/
# docker-image.yml in the umbrella), clones the umbrella, then configures,
# builds and tests with CTest.
name: CI
on:
push:
branches: [develop, master]
pull_request:
workflow_dispatch:
jobs:
build-test:
runs-on: ubuntu-latest
container:
image: ghcr.io/smspp-project/smspp-project:latest
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Extract the -DBUILD_* flags from .gitlab-ci.yml
id: flags
run: |
flags=$(grep -oE '\-DBUILD_[A-Za-z_]+=(ON|OFF)' .gitlab-ci.yml \
| grep -v '^-DBUILD_TESTING=' | sort -u | tr '\n' ' ')
echo "flags=$flags" >> "$GITHUB_OUTPUT"
echo "Using: $flags"
- name: Clone the umbrella
run: |
git clone --branch develop \
https://gitlab.com/smspp/smspp-project.git
# MOSEK, which is in the image but unlicensed, reads its license from
# the file in MOSEKLM_LICENSE_FILE; with no secret it is left out of
# the build, since every test that runs it would fail
- name: Write the MOSEK license, if the secret is set
env:
MOSEK_LICENSE: ${{ secrets.MOSEK_LICENSE }}
run: |
if [ -n "$MOSEK_LICENSE" ]; then
printf '%s\n' "$MOSEK_LICENSE" > /tmp/mosek.lic
echo "MOSEKLM_LICENSE_FILE=/tmp/mosek.lic" >> "$GITHUB_ENV"
fi
- name: Configure
run: |
mosek=""
[ -n "$MOSEKLM_LICENSE_FILE" ] || mosek="-DMILPSolver_USE_MOSEK=OFF"
cmake -S smspp-project -B smspp-project/build \
-DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON \
${{ steps.flags.outputs.flags }} $mosek
- name: Build
run: cmake --build smspp-project/build --target install -- -j$(nproc)
- name: Write the Gurobi WLS license, if the secrets are set
env:
GRB_LICENSEID: ${{ secrets.GRB_LICENSEID }}
GRB_WLSACCESSID: ${{ secrets.GRB_WLSACCESSID }}
GRB_WLSSECRET: ${{ secrets.GRB_WLSSECRET }}
run: |
if [ -n "$GRB_WLSSECRET" ]; then
printf 'LICENSEID=%s\nWLSACCESSID=%s\nWLSSECRET=%s\n' \
"$GRB_LICENSEID" "$GRB_WLSACCESSID" "$GRB_WLSSECRET" \
> /tmp/gurobi.lic
echo "GRB_LICENSE_FILE=/tmp/gurobi.lic" >> "$GITHUB_ENV"
fi
- name: Test
# Mirror the GitLab CI, single-sourced: if this module's .gitlab-ci.yml
# runs a labelled ctest (ctest ... -L ...), run exactly that set here,
# selecting by the repo-name label (each test is tagged in tests/ with
# its owning module). Otherwise the module has no integration tests, so
# this is a build-only (compile-check) CI. This workflow is identical
# in every repo and never needs per-module changes: the recipe lives
# in .gitlab-ci.yml.
run: |
run_tests() {
if grep -qE 'ctest .* -L ' .gitlab-ci.yml; then
ctest --test-dir smspp-project/build \
-L "${GITHUB_REPOSITORY##*/}" \
-V -C Release --no-tests=error
else
echo "no labelled tests for ${GITHUB_REPOSITORY##*/};" \
"build-only CI"
fi
}
# the academic Gurobi WLS license caps concurrent sessions; during
# a push wave a job can abort with "GRBstartenv ... status 10030".
# Retry ONLY on that transient cap (a real test failure fails
# immediately, so no re-runs are wasted). GitHub Actions has no
# native job retry.
log=smspp-project/build/Testing/Temporary/LastTest.log
for attempt in 1 2 3 4 5 6; do
run_tests && exit 0
rc=$?
cap='status 10030|too many sessions|cannot initialize Gurobi'
if [ -f "$log" ] && grep -qE "$cap" "$log"; then
echo "Gurobi WLS session cap hit (attempt $attempt/6);" \
"retrying after backoff..."
sleep 90
continue
fi
exit $rc
done
echo "Gurobi WLS session cap still hit after 6 attempts"
exit 1