Skip to content

Commit 296b39f

Browse files
authored
Merge pull request #207 from aws/maxday/fast-ci
ci: fast CI
2 parents ced34be + dd73fd4 commit 296b39f

16 files changed

Lines changed: 330 additions & 948 deletions

.github/workflows/test-on-push-and-pr.yml

Lines changed: 222 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ on:
44
push:
55
branches: [ main ]
66
pull_request:
7-
branches: [ '*' ]
7+
branches: [ '**' ]
8+
9+
permissions:
10+
contents: read
811

912
jobs:
1013
build:
@@ -15,34 +18,230 @@ jobs:
1518
- name: Run 'pr' target
1619
run: make pr
1720

18-
alpine:
21+
integration-test:
1922
runs-on: ubuntu-latest
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include:
27+
# Alpine
28+
- distro: alpine
29+
distro_version: "3.19"
30+
runtime_version: "3.10"
31+
python_location: /usr/local/bin/python
32+
- distro: alpine
33+
distro_version: "3.19"
34+
runtime_version: "3.11"
35+
python_location: /usr/local/bin/python
36+
- distro: alpine
37+
distro_version: "3.19"
38+
runtime_version: "3.12"
39+
python_location: /usr/local/bin/python
40+
- distro: alpine
41+
distro_version: "3.19"
42+
runtime_version: "3.13"
43+
python_location: /usr/local/bin/python
44+
- distro: alpine
45+
distro_version: "3.20"
46+
runtime_version: "3.10"
47+
python_location: /usr/local/bin/python
48+
- distro: alpine
49+
distro_version: "3.20"
50+
runtime_version: "3.11"
51+
python_location: /usr/local/bin/python
52+
- distro: alpine
53+
distro_version: "3.20"
54+
runtime_version: "3.12"
55+
python_location: /usr/local/bin/python
56+
- distro: alpine
57+
distro_version: "3.20"
58+
runtime_version: "3.13"
59+
python_location: /usr/local/bin/python
60+
- distro: alpine
61+
distro_version: "3.21"
62+
runtime_version: "3.14"
63+
python_location: /usr/local/bin/python
64+
# Debian
65+
- distro: debian
66+
distro_version: bookworm
67+
runtime_version: "3.10"
68+
python_location: /usr/local/bin/python
69+
- distro: debian
70+
distro_version: bookworm
71+
runtime_version: "3.11"
72+
python_location: /usr/local/bin/python
73+
- distro: debian
74+
distro_version: bookworm
75+
runtime_version: "3.12"
76+
python_location: /usr/local/bin/python
77+
- distro: debian
78+
distro_version: bookworm
79+
runtime_version: "3.13"
80+
python_location: /usr/local/bin/python
81+
- distro: debian
82+
distro_version: bookworm
83+
runtime_version: "3.14"
84+
python_location: /usr/local/bin/python
85+
- distro: debian
86+
distro_version: bullseye
87+
runtime_version: "3.10"
88+
python_location: /usr/local/bin/python
89+
- distro: debian
90+
distro_version: bullseye
91+
runtime_version: "3.11"
92+
python_location: /usr/local/bin/python
93+
- distro: debian
94+
distro_version: bullseye
95+
runtime_version: "3.12"
96+
python_location: /usr/local/bin/python
97+
- distro: debian
98+
distro_version: bullseye
99+
runtime_version: "3.13"
100+
python_location: /usr/local/bin/python
101+
# Amazon Linux 2
102+
- distro: amazonlinux2
103+
distro_version: "2"
104+
runtime_version: "3.10"
105+
python_location: /usr/local/bin/python3
106+
- distro: amazonlinux2
107+
distro_version: "2"
108+
runtime_version: "3.11"
109+
python_location: /usr/local/bin/python3
110+
# Amazon Linux 2023
111+
- distro: amazonlinux2023
112+
distro_version: "2023"
113+
runtime_version: "3.12"
114+
python_location: /usr/local/bin/python3
115+
- distro: amazonlinux2023
116+
distro_version: "2023"
117+
runtime_version: "3.13"
118+
python_location: /usr/local/bin/python3
119+
- distro: amazonlinux2023
120+
distro_version: "2023"
121+
runtime_version: "3.14"
122+
python_location: /usr/local/bin/python3
123+
# Ubuntu
124+
- distro: ubuntu
125+
distro_version: "22.04"
126+
runtime_version: "3.10"
127+
python_location: /usr/bin/python3.10
128+
- distro: ubuntu
129+
distro_version: "22.04"
130+
runtime_version: "3.11"
131+
python_location: /usr/bin/python3.11
132+
- distro: ubuntu
133+
distro_version: "22.04"
134+
runtime_version: "3.12"
135+
python_location: /usr/bin/python3.12
136+
- distro: ubuntu
137+
distro_version: "22.04"
138+
runtime_version: "3.13"
139+
python_location: /usr/bin/python3.13
140+
- distro: ubuntu
141+
distro_version: "22.04"
142+
runtime_version: "3.14"
143+
python_location: /usr/bin/python3.14
144+
- distro: ubuntu
145+
distro_version: "24.04"
146+
runtime_version: "3.10"
147+
python_location: /usr/bin/python3.10
148+
- distro: ubuntu
149+
distro_version: "24.04"
150+
runtime_version: "3.11"
151+
python_location: /usr/bin/python3.11
152+
- distro: ubuntu
153+
distro_version: "24.04"
154+
runtime_version: "3.12"
155+
python_location: /usr/bin/python3.12
156+
- distro: ubuntu
157+
distro_version: "24.04"
158+
runtime_version: "3.13"
159+
python_location: /usr/bin/python3.13
160+
- distro: ubuntu
161+
distro_version: "24.04"
162+
runtime_version: "3.14"
163+
python_location: /usr/bin/python3.14
164+
165+
name: "${{ matrix.distro }} ${{ matrix.distro_version }} / python ${{ matrix.runtime_version }}"
20166

21167
steps:
22-
- uses: actions/checkout@v4
23-
- name: Run alpine integration tests
24-
run: DISTRO=alpine make test-integ
168+
- uses: actions/checkout@v4
25169

26-
amazonlinux:
27-
runs-on: ubuntu-latest
170+
- name: Extract RIE
171+
run: |
172+
mkdir -p .scratch
173+
ARCHITECTURE=$(arch)
174+
if [[ "$ARCHITECTURE" == "x86_64" ]]; then
175+
RIE="aws-lambda-rie"
176+
elif [[ "$ARCHITECTURE" == "aarch64" ]]; then
177+
RIE="aws-lambda-rie-arm64"
178+
else
179+
echo "Architecture $ARCHITECTURE is not currently supported."
180+
exit 1
181+
fi
182+
tar -xvf tests/integration/resources/${RIE}.tar.gz --directory .scratch
183+
echo "RIE=${RIE}" >> "$GITHUB_ENV"
28184
29-
steps:
30-
- uses: actions/checkout@v4
31-
- name: Run amazonlinux integration tests
32-
run: DISTRO=amazonlinux make test-integ
185+
- name: Build Docker image
186+
run: |
187+
DOCKERFILE="tests/integration/docker/Dockerfile.echo.${{ matrix.distro }}"
188+
TMPFILE=".scratch/Dockerfile.tmp"
189+
cp "$DOCKERFILE" "$TMPFILE"
190+
if [[ "${{ matrix.distro }}" == "alpine" ]]; then
191+
echo "RUN apk add curl" >> "$TMPFILE"
192+
fi
193+
echo "COPY .scratch/${RIE} /usr/bin/${RIE}" >> "$TMPFILE"
194+
docker build . \
195+
-f "$TMPFILE" \
196+
-t ric-test \
197+
--build-arg RUNTIME_VERSION=${{ matrix.runtime_version }} \
198+
--build-arg DISTRO_VERSION=${{ matrix.distro_version }} \
199+
--build-arg ARCHITECTURE=$(arch)
33200
34-
debian:
35-
runs-on: ubuntu-latest
201+
- name: Run integration test
202+
run: |
203+
TEST_NAME="ric-integ-test"
204+
docker network create "${TEST_NAME}-net"
36205
37-
steps:
38-
- uses: actions/checkout@v4
39-
- name: Run debian integration tests
40-
run: DISTRO=debian make test-integ
206+
docker run \
207+
--detach \
208+
--name "${TEST_NAME}-app" \
209+
--network "${TEST_NAME}-net" \
210+
--entrypoint="" \
211+
ric-test \
212+
sh -c "/usr/bin/${RIE} ${{ matrix.python_location }} -m awslambdaric app.handler"
41213
42-
ubuntu:
43-
runs-on: ubuntu-latest
214+
sleep 2
44215
45-
steps:
46-
- uses: actions/checkout@v4
47-
- name: Run ubuntu integration tests
48-
run: DISTRO=ubuntu make test-integ
216+
docker run \
217+
--name "${TEST_NAME}-tester" \
218+
--env "TARGET=${TEST_NAME}-app" \
219+
--network "${TEST_NAME}-net" \
220+
--entrypoint="" \
221+
ric-test \
222+
sh -c 'curl -sS -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10'
223+
224+
ACTUAL="$(docker logs --tail 1 "${TEST_NAME}-tester" | xargs)"
225+
EXPECTED="success"
226+
echo "Response: ${ACTUAL}"
227+
if [ "$ACTUAL" != "$EXPECTED" ]; then
228+
echo "FAIL: expected '${EXPECTED}', got '${ACTUAL}'"
229+
exit 1
230+
fi
231+
echo "PASS"
232+
233+
- name: Dump container logs
234+
if: always()
235+
run: |
236+
TEST_NAME="ric-integ-test"
237+
echo "=== App container logs ==="
238+
docker logs "${TEST_NAME}-app" 2>&1 || true
239+
echo "=== Tester container logs ==="
240+
docker logs "${TEST_NAME}-tester" 2>&1 || true
241+
242+
- name: Cleanup
243+
if: always()
244+
run: |
245+
TEST_NAME="ric-integ-test"
246+
docker rm -f "${TEST_NAME}-app" "${TEST_NAME}-tester" 2>/dev/null || true
247+
docker network rm "${TEST_NAME}-net" 2>/dev/null || true

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ generated.docker-compose.*.yml
22

33
tests/integration/resources/init
44

5+
.scratch
6+
57
.idea
68

79
node_modules/

Makefile

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@ init:
1111
test: check-format
1212
pytest --cov awslambdaric --cov-report term-missing --cov-fail-under 90 tests
1313

14-
.PHONY: setup-codebuild-agent
15-
setup-codebuild-agent:
16-
docker build -t codebuild-agent - < tests/integration/codebuild-local/Dockerfile.agent
17-
18-
.PHONY: test-smoke
19-
test-smoke: setup-codebuild-agent
20-
CODEBUILD_IMAGE_TAG=codebuild-agent tests/integration/codebuild-local/test_one.sh tests/integration/codebuild/buildspec.os.alpine.yml alpine 3.15 3.9
21-
2214
.PHONY: test-integ
23-
test-integ: setup-codebuild-agent
24-
CODEBUILD_IMAGE_TAG=codebuild-agent DISTRO="$(DISTRO)" tests/integration/codebuild-local/test_all.sh tests/integration/codebuild/.
15+
test-integ:
16+
@echo "Integration tests run via GitHub Actions (see .github/workflows/test-on-push-and-pr.yml)"
17+
@echo "To run a single combo locally:"
18+
@echo " make test-integ-local DISTRO=alpine DISTRO_VERSION=3.20 RUNTIME_VERSION=3.13"
19+
20+
.PHONY: test-integ-local
21+
test-integ-local:
22+
tests/integration/run-local.sh $(DISTRO) $(DISTRO_VERSION) $(RUNTIME_VERSION)
2523

2624
.PHONY: check-security
2725
check-security:
@@ -43,9 +41,6 @@ dev: init test
4341
.PHONY: pr
4442
pr: init check-format check-security dev
4543

46-
codebuild: setup-codebuild-agent
47-
CODEBUILD_IMAGE_TAG=codebuild-agent DISTRO="$(DISTRO)" tests/integration/codebuild-local/test_all.sh tests/integration/codebuild
48-
4944
.PHONY: clean
5045
clean:
5146
rm -rf dist

tests/integration/codebuild-local/Dockerfile.agent

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)