-
Notifications
You must be signed in to change notification settings - Fork 19
211 lines (180 loc) · 6.46 KB
/
release.yml
File metadata and controls
211 lines (180 loc) · 6.46 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
name: Release Images
on:
push:
branches: [main, dev]
tags: ["v*.*.*"]
workflow_dispatch:
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
packages: write
env:
PYTHON_VERSION: "3.11"
REGISTRY_IMAGE: ghcr.io/usnavy13/librecodeinterpreter
RUNTIME_R_IMAGE: ghcr.io/usnavy13/librecodeinterpreter/runtime-r
BUILDCACHE_IMAGE: ghcr.io/usnavy13/librecodeinterpreter/buildcache
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
runtime_hash: ${{ steps.runtime.outputs.runtime_hash }}
sha_tag: ${{ steps.tags.outputs.sha_tag }}
moving_tag: ${{ steps.tags.outputs.moving_tag }}
version_tag: ${{ steps.tags.outputs.version_tag }}
steps:
- uses: actions/checkout@v4
- id: runtime
run: echo "runtime_hash=$(scripts/ci/compute_runtime_hash.sh)" >> "${GITHUB_OUTPUT}"
- id: tags
run: |
echo "sha_tag=sha-${GITHUB_SHA}" >> "${GITHUB_OUTPUT}"
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
echo "moving_tag=main" >> "${GITHUB_OUTPUT}"
elif [[ "${GITHUB_REF}" == "refs/heads/dev" ]]; then
echo "moving_tag=dev" >> "${GITHUB_OUTPUT}"
else
echo "moving_tag=" >> "${GITHUB_OUTPUT}"
fi
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
echo "version_tag=${GITHUB_REF#refs/tags/}" >> "${GITHUB_OUTPUT}"
else
echo "version_tag=" >> "${GITHUB_OUTPUT}"
fi
build-app:
needs: [prepare]
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
platform: linux/amd64
runner: ubuntu-24.04
- arch: arm64
platform: linux/arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: runtime
name: Resolve runtime base
run: |
runtime_base="$(scripts/ci/resolve_runtime_base.sh "${RUNTIME_R_IMAGE}" "${{ needs.prepare.outputs.runtime_hash }}")"
echo "runtime_base=${runtime_base}" >> "${GITHUB_OUTPUT}"
- name: Build and push app image
uses: docker/build-push-action@v6
with:
context: .
target: app
push: true
platforms: ${{ matrix.platform }}
provenance: false
tags: ${{ env.REGISTRY_IMAGE }}:${{ github.sha }}-${{ matrix.arch }}
build-args: |
RUNTIME_R_BASE=${{ steps.runtime.outputs.runtime_base }}
cache-from: |
type=registry,ref=${{ env.BUILDCACHE_IMAGE }}:app-${{ matrix.arch }}
type=registry,ref=${{ env.BUILDCACHE_IMAGE }}:runtime-r-${{ matrix.arch }}
cache-to: type=registry,ref=${{ env.BUILDCACHE_IMAGE }}:app-${{ matrix.arch }},mode=max
smoke:
needs: [prepare, build-app]
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
runner: ubuntu-24.04
- arch: arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install test dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-asyncio pytest-cov pytest-mock
- name: Pull release candidate
run: docker pull "${REGISTRY_IMAGE}:${GITHUB_SHA}-${{ matrix.arch }}"
- name: Start smoke stack
env:
API_IMAGE: ${{ env.REGISTRY_IMAGE }}:${{ github.sha }}-${{ matrix.arch }}
run: |
cp .env.example .env
docker compose up -d
- name: Wait for API
run: |
if ! scripts/ci/wait_for_api.sh http://localhost:8000/health 24 5; then
docker compose logs --no-color api
exit 1
fi
- name: Run release smoke suite
env:
API_BASE: http://localhost:8000
API_KEY: your-secure-api-key-here-change-this-in-production
run: |
mkdir -p test-results
pytest \
tests/functional/test_health.py \
tests/functional/test_exec_workflow.py::TestSessionWorkflow::test_execution_creates_session \
tests/functional/test_files.py::TestFileUpload::test_upload_single_file \
tests/functional/test_ptc.py::TestPTCInitialExecution::test_ptc_simple_code_completes \
-v \
--junitxml=test-results/release-smoke-${{ matrix.arch }}.xml
- name: Capture compose logs on failure
if: failure()
run: docker compose logs --no-color > release-compose-${{ matrix.arch }}.log
- name: Upload release smoke artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: release-smoke-${{ matrix.arch }}
path: |
test-results/
release-compose-${{ matrix.arch }}.log
if-no-files-found: ignore
- name: Stop smoke stack
if: always()
run: docker compose down -v
publish-manifest:
needs: [prepare, smoke]
runs-on: ubuntu-latest
steps:
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish multi-arch manifest tags
run: |
tags=(
"-t" "${REGISTRY_IMAGE}:${{ needs.prepare.outputs.sha_tag }}"
)
if [[ -n "${{ needs.prepare.outputs.moving_tag }}" ]]; then
tags+=("-t" "${REGISTRY_IMAGE}:${{ needs.prepare.outputs.moving_tag }}")
fi
if [[ -n "${{ needs.prepare.outputs.version_tag }}" ]]; then
tags+=("-t" "${REGISTRY_IMAGE}:${{ needs.prepare.outputs.version_tag }}")
fi
docker buildx imagetools create \
"${tags[@]}" \
"${REGISTRY_IMAGE}:${GITHUB_SHA}-amd64" \
"${REGISTRY_IMAGE}:${GITHUB_SHA}-arm64"