Skip to content

Commit fabacba

Browse files
authored
Merge pull request #62 from maxday/maxday/use-github-action-for-base-os-testing
feat: use GitHub Action for base os testing
1 parent 8f4afc8 commit fabacba

19 files changed

+267
-902
lines changed
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: integration-tests
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
branches: [main]
9+
pull_request:
10+
branches: ['*']
11+
workflow_dispatch:
12+
13+
jobs:
14+
integration-test:
15+
runs-on: ${{ matrix.arch.runner }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
arch:
20+
- runner: ubuntu-latest
21+
rie: aws-lambda-rie
22+
label: x64
23+
- runner: ubuntu-24.04-arm
24+
rie: aws-lambda-rie-arm64
25+
label: arm64
26+
distro_config:
27+
# al2023
28+
- distro: al2023
29+
distro_version: "al2023"
30+
runtime_version: "3.4"
31+
executable: /usr/local/bin/aws_lambda_ric
32+
- distro: al2023
33+
distro_version: "al2023"
34+
runtime_version: "3.3"
35+
executable: /usr/local/bin/aws_lambda_ric
36+
# Alpine
37+
- distro: alpine
38+
distro_version: "3.23"
39+
runtime_version: "3.4"
40+
executable: /usr/local/bundle/bin/aws_lambda_ric
41+
- distro: alpine
42+
distro_version: "3.23"
43+
runtime_version: "3.3"
44+
executable: /usr/local/bundle/bin/aws_lambda_ric
45+
# Debian
46+
- distro: debian
47+
distro_version: bookworm
48+
runtime_version: "3.4"
49+
executable: /usr/local/bundle/bin/aws_lambda_ric
50+
- distro: debian
51+
distro_version: bookworm
52+
runtime_version: "3.3"
53+
executable: /usr/local/bundle/bin/aws_lambda_ric
54+
# Ubuntu
55+
- distro: ubuntu
56+
distro_version: "24.04"
57+
runtime_version: "3.4"
58+
executable: /usr/local/bin/aws_lambda_ric
59+
- distro: ubuntu
60+
distro_version: "24.04"
61+
runtime_version: "3.3"
62+
executable: /usr/local/bin/aws_lambda_ric
63+
64+
name: "${{ matrix.distro_config.distro }} ${{ matrix.distro_config.distro_version }} / ruby ${{ matrix.distro_config.runtime_version }} (${{ matrix.arch.label }})"
65+
66+
steps:
67+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
68+
69+
- name: Download RIE
70+
run: |
71+
mkdir -p .scratch
72+
RIE_NAME="${{ matrix.arch.rie }}"
73+
curl -sSL "https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/${RIE_NAME}" -o ".scratch/${RIE_NAME}"
74+
chmod +x ".scratch/${RIE_NAME}"
75+
echo "RIE_NAME=${RIE_NAME}" >> "$GITHUB_ENV"
76+
77+
- name: Build Docker image
78+
run: |
79+
DOCKERFILE="test/integration/docker/Dockerfile.echo.${{ matrix.distro_config.distro }}"
80+
TMPFILE=".scratch/Dockerfile.tmp"
81+
cp "$DOCKERFILE" "$TMPFILE"
82+
echo "COPY .scratch/${{ env.RIE_NAME }} /usr/bin/${{ env.RIE_NAME }}" >> "$TMPFILE"
83+
docker build . \
84+
-f "$TMPFILE" \
85+
-t ric-test \
86+
--build-arg RUNTIME_VERSION=${{ matrix.distro_config.runtime_version }} \
87+
--build-arg DISTRO_VERSION=${{ matrix.distro_config.distro_version }}
88+
89+
- name: Run integration test
90+
run: |
91+
TEST_NAME="ric-integ-test"
92+
docker network create "${TEST_NAME}-net"
93+
94+
# Start the Lambda function container with RIE
95+
docker run \
96+
--detach \
97+
--name "${TEST_NAME}-app" \
98+
--network "${TEST_NAME}-net" \
99+
--entrypoint="" \
100+
ric-test \
101+
sh -c "/usr/bin/${{ env.RIE_NAME }} ${{ matrix.distro_config.executable }} app.App::Handler.process"
102+
103+
# Wait for RIE to be ready
104+
sleep 2
105+
106+
# Invoke the function
107+
docker run \
108+
--name "${TEST_NAME}-tester" \
109+
--env "TARGET=${TEST_NAME}-app" \
110+
--network "${TEST_NAME}-net" \
111+
--entrypoint="" \
112+
ric-test \
113+
sh -c 'curl -sS -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10'
114+
115+
# Assert response
116+
ACTUAL="$(docker logs --tail 1 "${TEST_NAME}-tester" | xargs)"
117+
EXPECTED="success"
118+
echo "Response: ${ACTUAL}"
119+
if [ "$ACTUAL" != "$EXPECTED" ]; then
120+
echo "FAIL: ${{ matrix.distro_config.distro }}-${{ matrix.distro_config.distro_version }}:${{ matrix.distro_config.runtime_version }} — expected '${EXPECTED}', got '${ACTUAL}'"
121+
exit 1
122+
fi
123+
echo "PASS"
124+
125+
- name: Dump container logs
126+
if: always()
127+
run: |
128+
TEST_NAME="ric-integ-test"
129+
echo "=== App container logs ==="
130+
docker logs "${TEST_NAME}-app" 2>&1 || true
131+
echo "=== Tester container logs ==="
132+
docker logs "${TEST_NAME}-tester" 2>&1 || true
133+
134+
- name: Cleanup
135+
if: always()
136+
run: |
137+
TEST_NAME="ric-integ-test"
138+
docker rm -f "${TEST_NAME}-app" "${TEST_NAME}-tester" 2>/dev/null || true
139+
docker network rm "${TEST_NAME}-net" 2>/dev/null || true

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ Gemfile.lock
1616
# containerized test runner clone
1717
.test-runner/
1818

19-
.vscode/
19+
.vscode/
20+
.scratch

Makefile

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,19 @@ target:
77
init:
88
bundle install
99

10-
.PHONY: setup-codebuild-agent
11-
setup-codebuild-agent:
12-
docker build -t codebuild-agent - < test/integration/codebuild-local/Dockerfile.agent
13-
14-
.PHONY: test-smoke
15-
test-smoke: setup-codebuild-agent
16-
CODEBUILD_IMAGE_TAG=codebuild-agent test/integration/codebuild-local/test_one.sh test/integration/codebuild/buildspec.os.alpine.1.yml alpine 3.16 3.1
17-
1810
.PHONY: test-unit
1911
test-unit:
2012
ruby test/run_tests.rb unit
2113

2214
.PHONY: test-integ
23-
test-integ: setup-codebuild-agent
24-
CODEBUILD_IMAGE_TAG=codebuild-agent test/integration/codebuild-local/test_all.sh test/integration/codebuild
15+
test-integ:
16+
@echo "Integration tests run via GitHub Actions (see .github/workflows/integration-tests.yml)"
17+
@echo "To run a single combo locally:"
18+
@echo " make test-integ-local DISTRO=alpine DISTRO_VERSION=3.19 RUNTIME_VERSION=3.3"
19+
20+
.PHONY: test-integ-local
21+
test-integ-local:
22+
test/integration/run-local.sh $(DISTRO) $(DISTRO_VERSION) $(RUNTIME_VERSION)
2523

2624
.PHONY: build
2725
build:
@@ -62,7 +60,7 @@ test-dockerized:
6260
/suites/*.json
6361

6462
.PHONY: pr
65-
pr: init test-unit test-smoke
63+
pr: init test-unit
6664

6765
define HELP_MESSAGE
6866

@@ -73,9 +71,9 @@ TARGETS
7371
build Builds the package.
7472
clean Cleans the working directory by removing built artifacts.
7573
init Initialize and install the dependencies and dev-dependencies for this project.
76-
test-integ Run Integration tests.
74+
test-integ Show instructions for running integration tests.
75+
test-integ-local Run a single integration test locally (requires DISTRO, DISTRO_VERSION, RUNTIME_VERSION).
7776
test-unit Run Unit Tests.
78-
test-smoke Run Sanity/Smoke tests.
7977
test-dockerized Run dockerized tests locally (requires RUBY_VERSION=X.X).
8078
run-local-ric Run local RIC changes with Runtime Interface Emulator.
8179
pr Perform all checks before submitting a Pull Request.

test/integration/codebuild-local/Dockerfile.agent

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

0 commit comments

Comments
 (0)