-
Notifications
You must be signed in to change notification settings - Fork 4
177 lines (166 loc) · 6.6 KB
/
ci.yml
File metadata and controls
177 lines (166 loc) · 6.6 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, reopened, synchronize, labeled]
jobs:
static-checks:
uses: ./.github/workflows/static.yml
detect-changes:
needs: [static-checks]
name: Docker Changed Images Detection
runs-on: ubuntu-latest
outputs:
images: ${{ steps.detect.outputs.images }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Detect changed image directories
id: detect
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
CHANGED=$(git diff --name-only "origin/${{ github.base_ref }}" "${{ github.sha }}" -- images/ \
| grep '^images/' \
| cut -d/ -f2 \
| sort -u)
else
BEFORE="${{ github.event.before }}"
AFTER="${{ github.sha }}"
# First push to branch or workflow_dispatch has all-zero before SHA
if [ "$BEFORE" = "0000000000000000000000000000000000000000" ] || [ -z "$BEFORE" ]; then
CHANGED=$(ls images/)
else
CHANGED=$(git diff --name-only "$BEFORE" "$AFTER" -- images/ \
| grep '^images/' \
| cut -d/ -f2 \
| sort -u)
fi
fi
# Keep only entries that are actual image directories
VALID=""
for dir in $CHANGED; do
[ -d "images/$dir" ] && VALID="$VALID $dir"
done
IMAGES=$(echo "$VALID" | tr ' ' '\n' | grep -v '^$' | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "images=$IMAGES" >> "$GITHUB_OUTPUT"
echo "Detected images: $IMAGES"
build:
name: Docker Build ${{ matrix.image }}
needs: [detect-changes, static-checks]
if: needs.detect-changes.outputs.images != '[]' && needs.detect-changes.outputs.images != ''
runs-on: ubuntu-latest
permissions:
packages: write
strategy:
matrix:
image: ${{ fromJson(needs.detect-changes.outputs.images) }}
fail-fast: false
env:
SML_FIRECREST_CLIENT_ID: ${{ secrets.SML_FIRECREST_CLIENT_ID }}
SML_FIRECREST_CLIENT_SECRET: ${{ secrets.SML_FIRECREST_CLIENT_SECRET }}
SML_FIRECREST_TOKEN_URI: ${{ secrets.SML_FIRECREST_TOKEN_URI }}
SML_FIRECREST_URL: ${{ secrets.SML_FIRECREST_URL }}
SML_FIRECREST_SYSTEM: ${{ secrets.SML_FIRECREST_SYSTEM }}
SML_PARTITION: ${{ secrets.SML_PARTITION }}
SML_RESERVATION: ${{ secrets.SML_RESERVATION }}
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GHCR_ACTOR: ${{ github.actor }}
steps:
- uses: actions/checkout@v5
- name: Restore build cache
id: cache
uses: actions/cache/restore@v4
with:
path: .build-sentinel
key: build-${{ matrix.image }}-${{ hashFiles(format('images/{0}/**', matrix.image)) }}
- uses: ./.github/actions/setup
if: steps.cache.outputs.cache-hit != 'true'
with:
python-version: "3.12"
- name: Build image and save sqsh
if: steps.cache.outputs.cache-hit != 'true'
run: python .github/scripts/build_image.py "${{ matrix.image }}"
timeout-minutes: 300
- name: Save build cache
if: steps.cache.outputs.cache-hit != 'true'
run: mkdir -p .build-sentinel && touch .build-sentinel/built
- uses: actions/cache/save@v4
if: steps.cache.outputs.cache-hit != 'true'
with:
path: .build-sentinel
key: build-${{ matrix.image }}-${{ hashFiles(format('images/{0}/**', matrix.image)) }}
test-lightweight:
name: Integration Tests (lightweight)
needs: [detect-changes, build]
if: |
always() &&
needs.build.result != 'failure' &&
github.event_name != 'workflow_dispatch' &&
!contains(github.event.pull_request.labels.*.name, 'requires-std-tests') &&
!contains(github.event.pull_request.labels.*.name, 'requires-comprehensive-tests')
runs-on: ubuntu-latest
env:
SML_CSCS_API_KEY: ${{ secrets.SML_CSCS_API_KEY }}
SML_FIRECREST_CLIENT_ID: ${{ secrets.SML_FIRECREST_CLIENT_ID }}
SML_FIRECREST_CLIENT_SECRET: ${{ secrets.SML_FIRECREST_CLIENT_SECRET }}
SML_FIRECREST_SYSTEM: ${{ secrets.SML_FIRECREST_SYSTEM }}
SML_FIRECREST_TOKEN_URI: ${{ secrets.SML_FIRECREST_TOKEN_URI }}
SML_FIRECREST_URL: ${{ secrets.SML_FIRECREST_URL }}
SML_PARTITION: ${{ secrets.SML_PARTITION }}
SML_RESERVATION: ${{ secrets.SML_RESERVATION }}
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/setup
with:
python-version: "3.12"
- run: make _test-lightweight
test-std:
name: Integration Tests (std)
needs: [detect-changes, build]
if: |
always() &&
needs.build.result != 'failure' &&
contains(github.event.pull_request.labels.*.name, 'requires-std-tests') &&
!contains(github.event.pull_request.labels.*.name, 'requires-comprehensive-tests')
runs-on: ubuntu-latest
env:
SML_CSCS_API_KEY: ${{ secrets.SML_CSCS_API_KEY }}
SML_FIRECREST_CLIENT_ID: ${{ secrets.SML_FIRECREST_CLIENT_ID }}
SML_FIRECREST_CLIENT_SECRET: ${{ secrets.SML_FIRECREST_CLIENT_SECRET }}
SML_FIRECREST_SYSTEM: ${{ secrets.SML_FIRECREST_SYSTEM }}
SML_FIRECREST_TOKEN_URI: ${{ secrets.SML_FIRECREST_TOKEN_URI }}
SML_FIRECREST_URL: ${{ secrets.SML_FIRECREST_URL }}
SML_PARTITION: ${{ secrets.SML_PARTITION }}
SML_RESERVATION: ${{ secrets.SML_RESERVATION }}
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/setup
with:
python-version: "3.12"
- run: make _test-std
test-comprehensive:
name: Integration Tests (comprehensive)
needs: [detect-changes, build]
if: |
always() &&
needs.build.result != 'failure' &&
(github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'requires-comprehensive-tests'))
runs-on: ubuntu-latest
env:
SML_CSCS_API_KEY: ${{ secrets.SML_CSCS_API_KEY }}
SML_FIRECREST_CLIENT_ID: ${{ secrets.SML_FIRECREST_CLIENT_ID }}
SML_FIRECREST_CLIENT_SECRET: ${{ secrets.SML_FIRECREST_CLIENT_SECRET }}
SML_FIRECREST_SYSTEM: ${{ secrets.SML_FIRECREST_SYSTEM }}
SML_FIRECREST_TOKEN_URI: ${{ secrets.SML_FIRECREST_TOKEN_URI }}
SML_FIRECREST_URL: ${{ secrets.SML_FIRECREST_URL }}
SML_PARTITION: ${{ secrets.SML_PARTITION }}
SML_RESERVATION: ${{ secrets.SML_RESERVATION }}
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/setup
with:
python-version: "3.12"
- run: make _test-comprehensive