-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (148 loc) · 4.55 KB
/
Copy pathci.yml
File metadata and controls
175 lines (148 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
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
name: CI
on:
pull_request:
push:
branches:
- main
concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
ruff:
name: Ruff
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Run Ruff
# ruff-action has v4.1.0 / v4.0.0 tags, not a floating v4 major.
uses: astral-sh/ruff-action@v4.1.0
with:
version: "0.16.3"
args: check --output-format=github
- name: Check Ruff format
uses: astral-sh/ruff-action@v4.1.0
with:
version: "0.16.3"
args: format --check
hadolint:
name: Hadolint
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Lint Dockerfile
run: docker run --rm -i hadolint/hadolint < Dockerfile
spectral:
name: Spectral
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Lint OpenAPI
run: make spectral
lint:
name: Lint
if: ${{ !cancelled() }}
needs: [ruff, hadolint, spectral]
runs-on: ubuntu-latest
steps:
- name: Require Ruff, Hadolint, and Spectral
run: |
test "${{ needs.ruff.result }}" = "success"
test "${{ needs.hadolint.result }}" = "success"
test "${{ needs.spectral.result }}" = "success"
unit-tests:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Get Python version from Dockerfile
id: get-version
run: |
# Extract version like "3.14" from "FROM python:3.14-slim..."
VERSION=$(grep -m 1 "^FROM python:" Dockerfile | sed -E 's/^FROM python:([0-9]+\.[0-9]+).*/\1/')
if [ -z "$VERSION" ]; then
echo "Error: Could not extract Python version from Dockerfile"
exit 1
fi
echo "Extracted version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: ${{ steps.get-version.outputs.version }}
cache: "pip"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Execute unit test suite
run: python -m unittest discover -s tests -p "test_*.py" -v
- name: Typecheck
run: make typecheck
- name: Verify OpenAPI snapshot
run: make openapi-verify
docker-smoke-image:
name: Docker smoke image (linux/amd64, cache)
runs-on: ubuntu-latest
permissions:
contents: read
actions: write
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build and cache smoke image
uses: docker/build-push-action@v7
with:
context: .
push: false
load: true
platforms: linux/amd64
tags: botasaurus-api-smoke:ci
cache-from: type=gha,scope=smoke-linux-amd64
cache-to: type=gha,mode=max,scope=smoke-linux-amd64
smoke-test:
name: ${{ matrix.title }}
needs: docker-smoke-image
runs-on: ubuntu-latest
timeout-minutes: ${{ matrix.timeout_minutes }}
permissions:
contents: read
actions: write
strategy:
fail-fast: false
matrix:
include:
- title: "Smoke (prewarm=false, cold)"
profile: contract-prewarm-off
timeout_minutes: 30
- title: "Smoke (prewarm=true, warm-handoff)"
profile: prewarm-on-warm-handoff
timeout_minutes: 20
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Load smoke image from cache
uses: docker/build-push-action@v7
with:
context: .
push: false
load: true
platforms: linux/amd64
tags: botasaurus-api-smoke:ci
cache-from: type=gha,scope=smoke-linux-amd64
- name: Execute smoke profile
env:
SMOKE_SKIP_BUILD: "1"
SMOKE_IMAGE_NAME: botasaurus-api-smoke:ci
SMOKE_PROFILE: ${{ matrix.profile }}
run: make smoke