-
Notifications
You must be signed in to change notification settings - Fork 1.3k
292 lines (255 loc) · 10.7 KB
/
providers-build.yml
File metadata and controls
292 lines (255 loc) · 10.7 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
name: Test OGX Build
run-name: Test ogx build
on:
push:
branches:
- main
paths:
- 'src/ogx/cli/stack/build.py'
- 'src/ogx/cli/stack/_build.py'
- 'src/ogx/core/build.*'
- 'src/ogx/core/*.sh'
- '.github/workflows/providers-build.yml'
- 'src/ogx/distributions/**'
- 'pyproject.toml'
- 'containers/Containerfile'
- '.dockerignore'
pull_request:
paths:
- 'src/ogx/cli/stack/build.py'
- 'src/ogx/cli/stack/_build.py'
- 'src/ogx/core/build.*'
- 'src/ogx/core/*.sh'
- '.github/workflows/providers-build.yml'
- 'src/ogx/distributions/**'
- 'pyproject.toml'
- 'containers/Containerfile'
- '.dockerignore'
merge_group:
branches:
- main
- 'release-[0-9]+.[0-9]+.x'
schedule:
- cron: '0 0 * * *' # Daily at 12 AM UTC
concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.ref }}
cancel-in-progress: true
jobs:
generate-matrix:
runs-on: ubuntu-latest
outputs:
distros: ${{ steps.set-matrix.outputs.distros }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Generate Distribution List
id: set-matrix
run: |
distros=$(find src/ogx/distributions -mindepth 1 -maxdepth 1 -type d 2>/dev/null | \
awk -F'/' '{print $NF}' | \
grep -v '^__pycache__$' | \
grep -v '^ci-tests$' | \
jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "distros=$distros" >> "$GITHUB_OUTPUT"
build:
needs: generate-matrix
runs-on: ubuntu-latest
strategy:
matrix:
distro: ${{ fromJson(needs.generate-matrix.outputs.distros) }}
image-type: [venv, container]
fail-fast: false # We want to run all jobs even if some fail
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install dependencies
uses: ./.github/actions/setup-runner
- name: Install distribution into venv
if: matrix.image-type == 'venv'
run: |
uv run ogx stack list-deps ${{ matrix.distro }} | xargs -L1 uv pip install
- name: Build container image
if: matrix.image-type == 'container'
run: |
BUILD_ARGS=(--build-arg "INSTALL_MODE=editable" --build-arg "DISTRO_NAME=${{ matrix.distro }}")
if [ -n "${UV_EXTRA_INDEX_URL:-}" ]; then
BUILD_ARGS+=(--build-arg "UV_EXTRA_INDEX_URL=$UV_EXTRA_INDEX_URL")
fi
if [ -n "${UV_INDEX_STRATEGY:-}" ]; then
BUILD_ARGS+=(--build-arg "UV_INDEX_STRATEGY=$UV_INDEX_STRATEGY")
fi
docker build . \
-f containers/Containerfile \
"${BUILD_ARGS[@]}" \
--tag ogx:${{ matrix.distro }}-ci
build-arm64:
if: github.event_name == 'schedule'
needs: generate-matrix
runs-on: ubuntu-latest
strategy:
matrix:
distro: ${{ fromJson(needs.generate-matrix.outputs.distros) }}
fail-fast: false # We want to run all jobs even if some fail
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install dependencies
uses: ./.github/actions/setup-runner
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd
- name: Build ARM64 container image
run: |
BUILD_ARGS=(--build-arg "INSTALL_MODE=editable" --build-arg "DISTRO_NAME=${{ matrix.distro }}")
if [ -n "${UV_EXTRA_INDEX_URL:-}" ]; then
BUILD_ARGS+=(--build-arg "UV_EXTRA_INDEX_URL=$UV_EXTRA_INDEX_URL")
fi
if [ -n "${UV_INDEX_STRATEGY:-}" ]; then
BUILD_ARGS+=(--build-arg "UV_INDEX_STRATEGY=$UV_INDEX_STRATEGY")
fi
docker buildx build --platform linux/arm64 --load . \
-f containers/Containerfile \
"${BUILD_ARGS[@]}" \
--tag ogx:${{ matrix.distro }}-arm64-ci
build-single-provider:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install dependencies
uses: ./.github/actions/setup-runner
- name: Build a single provider
run: |
uv pip install -e .
uv run --no-sync ogx stack list-deps --providers inference=remote::ollama | xargs -L1 uv pip install
build-custom-container-distribution:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install dependencies
uses: ./.github/actions/setup-runner
- name: Build container image
run: |
BASE_IMAGE=$(yq -r '.distribution_spec.container_image // "python:3.12-slim"' src/ogx/distributions/ci-tests/config.yaml)
BUILD_ARGS=(--build-arg "INSTALL_MODE=editable" --build-arg "DISTRO_NAME=ci-tests")
BUILD_ARGS+=(--build-arg "BASE_IMAGE=$BASE_IMAGE")
BUILD_ARGS+=(--build-arg "RUN_CONFIG_PATH=/workspace/src/ogx/distributions/ci-tests/config.yaml")
if [ -n "${UV_EXTRA_INDEX_URL:-}" ]; then
BUILD_ARGS+=(--build-arg "UV_EXTRA_INDEX_URL=$UV_EXTRA_INDEX_URL")
fi
if [ -n "${UV_INDEX_STRATEGY:-}" ]; then
BUILD_ARGS+=(--build-arg "UV_INDEX_STRATEGY=$UV_INDEX_STRATEGY")
fi
docker build . \
-f containers/Containerfile \
"${BUILD_ARGS[@]}" \
-t ogx:ci-tests
- name: Inspect the container image entrypoint
run: |
IMAGE_ID=$(docker images --format "{{.Repository}}:{{.Tag}}" | head -n 1)
if [ -z "$IMAGE_ID" ]; then
echo "No image found"
exit 1
fi
entrypoint=$(docker inspect --format '{{ .Config.Entrypoint }}' "$IMAGE_ID")
echo "Entrypoint: $entrypoint"
if [ "$entrypoint" != "[/usr/local/bin/ogx-entrypoint.sh]" ]; then
echo "Entrypoint is not correct"
exit 1
fi
build-ubi9-container-distribution:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install dependencies
uses: ./.github/actions/setup-runner
- name: Pin distribution to UBI9 base
run: |
yq -i '
.distribution_spec.container_image = "registry.access.redhat.com/ubi9:latest"
' src/ogx/distributions/ci-tests/config.yaml
- name: Create UBI9 pip constraints
run: |
# UBI9 ships glibc 2.34; semgrep >= 1.158 requires manylinux_2_35
echo "semgrep<1.158" > ubi9-constraints.txt
- name: Build UBI9 container image
run: |
BASE_IMAGE=$(yq -r '.distribution_spec.container_image // "registry.access.redhat.com/ubi9:latest"' src/ogx/distributions/ci-tests/config.yaml)
BUILD_ARGS=(--build-arg "INSTALL_MODE=editable" --build-arg "DISTRO_NAME=ci-tests")
BUILD_ARGS+=(--build-arg "BASE_IMAGE=$BASE_IMAGE")
BUILD_ARGS+=(--build-arg "RUN_CONFIG_PATH=/workspace/src/ogx/distributions/ci-tests/config.yaml")
BUILD_ARGS+=(--build-arg "PIP_CONSTRAINT_FILE=/workspace/ubi9-constraints.txt")
if [ -n "${UV_EXTRA_INDEX_URL:-}" ]; then
BUILD_ARGS+=(--build-arg "UV_EXTRA_INDEX_URL=$UV_EXTRA_INDEX_URL")
fi
if [ -n "${UV_INDEX_STRATEGY:-}" ]; then
BUILD_ARGS+=(--build-arg "UV_INDEX_STRATEGY=$UV_INDEX_STRATEGY")
fi
docker build . \
-f containers/Containerfile \
"${BUILD_ARGS[@]}" \
-t ogx:ci-tests-ubi9
- name: Inspect UBI9 image
run: |
IMAGE_ID=$(docker images --format "{{.Repository}}:{{.Tag}}" | head -n 1)
if [ -z "$IMAGE_ID" ]; then
echo "No image found"
exit 1
fi
entrypoint=$(docker inspect --format '{{ .Config.Entrypoint }}' "$IMAGE_ID")
echo "Entrypoint: $entrypoint"
if [ "$entrypoint" != "[/usr/local/bin/ogx-entrypoint.sh]" ]; then
echo "Entrypoint is not correct"
exit 1
fi
echo "Checking /etc/os-release in $IMAGE_ID"
docker run --rm --entrypoint sh "$IMAGE_ID" -c \
'source /etc/os-release && echo "$ID"' \
| grep -qE '^(rhel|ubi)$' \
|| { echo "Base image is not UBI 9!"; exit 1; }
build-starter-ubi9-arm64-container:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install dependencies
uses: ./.github/actions/setup-runner
- name: Set up QEMU for ARM64 emulation
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd
- name: Build starter distribution on UBI9 ARM64
run: |
BASE_IMAGE="registry.access.redhat.com/ubi9:latest"
BUILD_ARGS=(--build-arg "INSTALL_MODE=editable" --build-arg "DISTRO_NAME=starter")
BUILD_ARGS+=(--build-arg "BASE_IMAGE=$BASE_IMAGE")
if [ -n "${UV_EXTRA_INDEX_URL:-}" ]; then
BUILD_ARGS+=(--build-arg "UV_EXTRA_INDEX_URL=$UV_EXTRA_INDEX_URL")
fi
if [ -n "${UV_INDEX_STRATEGY:-}" ]; then
BUILD_ARGS+=(--build-arg "UV_INDEX_STRATEGY=$UV_INDEX_STRATEGY")
fi
docker buildx build --platform linux/arm64 --load . \
-f containers/Containerfile \
"${BUILD_ARGS[@]}" \
--tag ogx:starter-ubi9-arm64
- name: Inspect starter UBI9 ARM64 image
run: |
IMAGE_ID=$(docker images --format "{{.Repository}}:{{.Tag}}" | head -n 1)
if [ -z "$IMAGE_ID" ]; then
echo "No image found"
exit 1
fi
entrypoint=$(docker inspect --format '{{ .Config.Entrypoint }}' "$IMAGE_ID")
echo "Entrypoint: $entrypoint"
if [ "$entrypoint" != "[/usr/local/bin/ogx-entrypoint.sh]" ]; then
echo "Entrypoint is not correct"
exit 1
fi
echo "Checking /etc/os-release in $IMAGE_ID"
docker run --rm --platform linux/arm64 --entrypoint sh "$IMAGE_ID" -c \
'source /etc/os-release && echo "$ID"' \
| grep -qE '^(rhel|ubi)$' \
|| { echo "Base image is not UBI 9!"; exit 1; }