Skip to content

Commit cc58ade

Browse files
tdsteinclaude
andcommitted
feat: Add integration Makefile with dynamic port allocation and simplify CI workflow
Add a new Makefile for integration tests that: - Dynamically allocates available ports using Python socket binding - Parses CONNECT_VERSION correctly from Make target patterns - Supports running tests for individual or all Connect versions - Includes comprehensive help documentation Update CI workflow to: - Extract Connect versions dynamically from the Makefile - Simplify the integration test matrix setup - Eliminate duplicate version list maintenance 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent fd37a5c commit cc58ade

File tree

2 files changed

+116
-32
lines changed

2 files changed

+116
-32
lines changed

.github/workflows/ci.yaml

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,42 +37,26 @@ jobs:
3737
- run: make dev
3838
- run: make test
3939

40+
setup-integration-test:
41+
runs-on: ubuntu-latest
42+
outputs:
43+
versions: ${{ steps.versions.outputs.versions }}
44+
steps:
45+
- uses: actions/checkout@v4
46+
- id: versions
47+
working-directory: ./integration
48+
# The `jq` command is "output compact, raw input, slurp, split on new lines, and remove the last element". This results in a JSON array of Connect versions (e.g., ["2025.01.0", "2024.12.0"]).
49+
run: |
50+
versions=$(make print-versions | jq -c -Rs 'split("\n") | .[:-1]')
51+
echo "versions=$versions" >> "$GITHUB_OUTPUT"
52+
4053
integration-test:
4154
runs-on: ubuntu-latest
55+
needs: setup-integration-test
4256
strategy:
4357
fail-fast: false
4458
matrix:
45-
CONNECT_VERSION:
46-
- 2025.10.0
47-
- 2025.09.1
48-
- 2025.07.0
49-
- 2025.06.0
50-
- 2025.05.0
51-
- 2025.04.0
52-
- 2025.03.0
53-
- 2025.02.0
54-
- 2025.01.0
55-
- 2024.12.0
56-
- 2024.11.0
57-
- 2024.09.0
58-
- 2024.08.0
59-
- 2024.06.0
60-
- 2024.05.0
61-
- 2024.04.1
62-
- 2024.04.0
63-
- 2024.03.0
64-
- 2024.02.0
65-
- 2024.01.0
66-
- 2023.12.0
67-
- 2023.10.0
68-
- 2023.09.0
69-
- 2023.07.0
70-
- 2023.06.0
71-
- 2023.05.0
72-
- 2023.01.1
73-
- 2023.01.0
74-
- 2022.12.0
75-
- 2022.11.0
59+
CONNECT_VERSION: ${{ fromJson(needs.setup-integration-test.outputs.versions) }}
7660
steps:
7761
- uses: actions/checkout@v5
7862
- uses: astral-sh/setup-uv@v7
@@ -83,7 +67,7 @@ jobs:
8367
version: ${{ matrix.CONNECT_VERSION }}
8468
license: ${{ secrets.CONNECT_LICENSE }}
8569
command:
86-
uv run pytest -s --junit-xml=./integration/reports/${{ matrix.CONNECT_VERSION }}.xml
70+
make -C ./integration test-${{ matrix.CONNECT_VERSION }}
8771
- uses: actions/upload-artifact@v5
8872
if: always()
8973
with:

integration/Makefile

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
include ../vars.mk
2+
3+
# pytest settings
4+
PYTEST_ARGS ?= "-s"
5+
6+
.DEFAULT_GOAL := latest
7+
8+
define GET_PORT
9+
$(UV) run -- python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'
10+
endef
11+
12+
.PHONY: $(CONNECT_VERSIONS) \
13+
all \
14+
clean \
15+
latest \
16+
print-versions \
17+
help \
18+
test-%
19+
20+
# Versions
21+
CONNECT_VERSIONS := \
22+
2025.10.0 \
23+
2025.09.1 \
24+
2025.09.0 \
25+
2025.07.0 \
26+
2025.06.0 \
27+
2025.05.0 \
28+
2025.04.0 \
29+
2025.03.0 \
30+
2025.02.0 \
31+
2025.01.0 \
32+
2024.12.0 \
33+
2024.11.0 \
34+
2024.09.0 \
35+
2024.08.0 \
36+
2024.06.0 \
37+
2024.05.0 \
38+
2024.04.1 \
39+
2024.04.0 \
40+
2024.03.0 \
41+
2024.02.0 \
42+
2024.01.0 \
43+
2023.12.0 \
44+
2023.10.0 \
45+
2023.09.0 \
46+
2023.07.0 \
47+
2023.06.0 \
48+
2023.05.0 \
49+
2023.01.1 \
50+
2023.01.0 \
51+
2022.12.0 \
52+
2022.11.0
53+
54+
clean:
55+
rm -rf logs reports
56+
find . -type d -empty -delete
57+
58+
# Run pytest for a specific version (assumes Connect is already running).
59+
test-%:
60+
@mkdir -p logs reports
61+
$(UV) run pytest $(PYTEST_ARGS) \
62+
--junitxml=reports/junit-$*.xml | tee logs/$*.log
63+
64+
# Spin up Connect for a specific version and run tests.
65+
$(CONNECT_VERSIONS): %:
66+
PORT=$$($(GET_PORT)); \
67+
uv run --with https://github.com/posit-dev/with-connect.git \
68+
with-connect --version $* --port $$PORT \
69+
-- $(MAKE) test-$*
70+
71+
# Run test suite against all Connect versions.
72+
all: $(CONNECT_VERSIONS:%=%)
73+
74+
# Run test suite against latest Connect version.
75+
latest:
76+
$(MAKE) $(firstword $(CONNECT_VERSIONS))
77+
78+
# Show available versions
79+
print-versions:
80+
@printf "%s\n" $(strip $(CONNECT_VERSIONS))
81+
82+
# Show help message.
83+
help:
84+
@echo "Makefile Targets:"
85+
@echo " latest (default) Run test suite for latest Connect version."
86+
@echo " all Run test suite for all Connect versions."
87+
@echo " <version> Run test suite for the specified Connect version. (e.g., make 2025.10.0)"
88+
@echo " clean Clean up logs and reports directories."
89+
@echo " print-versions Show the available Connect versions."
90+
@echo " help Show this help message."
91+
@echo
92+
@echo "Common Usage:"
93+
@echo " make Run test suite for latest Connect version (default)."
94+
@echo " make latest Run test suite for latest Connect version."
95+
@echo " make 2025.10.0 Run test suite for specific Connect version."
96+
@echo " make all Run test suite for all Connect versions."
97+
@echo " make -j 4 all Run test suite in parallel for all Connect versions."
98+
@echo
99+
@echo "Environment Variables:"
100+
@echo " PYTEST_ARGS Arguments to pass to pytest. Default: \"-s\""

0 commit comments

Comments
 (0)