|
1 | 1 | include ../vars.mk |
2 | 2 |
|
3 | | -# Docker settings |
4 | | -DOCKER_COMPOSE ?= docker compose |
5 | | -DOCKER_CONNECT_IMAGE ?= rstudio/rstudio-connect |
6 | | -DOCKER_PROJECT_IMAGE_TAG ?= $(PROJECT_NAME):latest |
7 | | - |
8 | | -# Connect settings |
9 | | -CONNECT_BOOTSTRAP_SECRETKEY ?= $(shell head -c 32 /dev/random | base64) |
10 | | - |
11 | 3 | # pytest settings |
12 | 4 | PYTEST_ARGS ?= "-s" |
13 | 5 |
|
14 | 6 | .DEFAULT_GOAL := latest |
15 | 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 | + |
16 | 12 | .PHONY: $(CONNECT_VERSIONS) \ |
17 | 13 | all \ |
18 | | - build \ |
19 | | - down \ |
20 | | - down-% \ |
| 14 | + clean \ |
21 | 15 | latest \ |
22 | | - test \ |
23 | | - up \ |
24 | | - up-% \ |
25 | | - help |
| 16 | + print-versions \ |
| 17 | + help \ |
| 18 | + test-% |
26 | 19 |
|
27 | 20 | # Versions |
28 | 21 | CONNECT_VERSIONS := \ |
| 22 | + 2025.10.0 \ |
| 23 | + 2025.09.1 \ |
29 | 24 | 2025.07.0 \ |
30 | 25 | 2025.06.0 \ |
31 | 26 | 2025.05.0 \ |
@@ -59,88 +54,46 @@ clean: |
59 | 54 | rm -rf logs reports |
60 | 55 | find . -type d -empty -delete |
61 | 56 |
|
62 | | -# Run test suite for a specific Connect version. |
63 | | -$(CONNECT_VERSIONS): %: down-% up-% |
| 57 | +# Run pytest for a specific version (assumes Connect is already running). |
| 58 | +test-%: |
| 59 | + @mkdir -p logs reports |
| 60 | + $(UV) run pytest $(PYTEST_ARGS) \ |
| 61 | + --junitxml=reports/junit-$*.xml | tee logs/$*.log |
| 62 | + |
| 63 | +# Spin up Connect for a specific version and run tests. |
| 64 | +$(CONNECT_VERSIONS): %: |
| 65 | + PORT=$$($(GET_PORT)); \ |
| 66 | + uv run --with https://github.com/posit-dev/with-connect.git \ |
| 67 | + with-connect --version $* --port $$PORT \ |
| 68 | + -- $(MAKE) test-$* |
64 | 69 |
|
65 | 70 | # Run test suite against all Connect versions. |
66 | | -all: $(CONNECT_VERSIONS:%=%) preview |
| 71 | +all: $(CONNECT_VERSIONS:%=%) |
67 | 72 |
|
68 | 73 | # Run test suite against latest Connect version. |
69 | 74 | latest: |
70 | 75 | $(MAKE) $(firstword $(CONNECT_VERSIONS)) |
71 | 76 |
|
72 | | -# Run test suite against preview Connect version. |
73 | | -preview: |
74 | | - $(MAKE) \ |
75 | | - DOCKER_CONNECT_IMAGE=rstudio/rstudio-connect-preview \ |
76 | | - DOCKER_CONNECT_IMAGE_TAG=dev-jammy-daily \ |
77 | | - down-preview up-preview |
78 | | - |
79 | | -# Build Dockerfile |
80 | | -build: |
81 | | - make -C .. $(UV_LOCK) |
82 | | - docker build -t $(DOCKER_PROJECT_IMAGE_TAG) .. |
83 | | - |
84 | | -# Tear down resources. |
85 | | -down: $(CONNECT_VERSIONS:%=down-%) |
86 | | -down-%: DOCKER_CONNECT_IMAGE_TAG=jammy-$* |
87 | | -down-%: CONNECT_VERSION=$* |
88 | | -down-%: |
89 | | - CONNECT_BOOTSTRAP_SECRETKEY=$(CONNECT_BOOTSTRAP_SECRETKEY) \ |
90 | | - CONNECT_VERSION=$* \ |
91 | | - DOCKER_CONNECT_IMAGE_TAG=$(DOCKER_CONNECT_IMAGE_TAG) \ |
92 | | - DOCKER_CONNECT_IMAGE=$(DOCKER_CONNECT_IMAGE) \ |
93 | | - DOCKER_PROJECT_IMAGE_TAG=$(DOCKER_PROJECT_IMAGE_TAG) \ |
94 | | - PYTEST_ARGS="$(PYTEST_ARGS)" \ |
95 | | - $(DOCKER_COMPOSE) -p $(PROJECT_NAME)-$(subst .,-,$(CONNECT_VERSION)) down -v |
96 | | - |
97 | | -# Create, start, and run Docker Compose. |
98 | | -up: $(CONNECT_VERSIONS:%=up-%) |
99 | | -up-%: CONNECT_VERSION=$* |
100 | | -up-%: DOCKER_CONNECT_IMAGE_TAG=jammy-$* |
101 | | -up-%: build |
102 | | - CONNECT_BOOTSTRAP_SECRETKEY=$(CONNECT_BOOTSTRAP_SECRETKEY) \ |
103 | | - CONNECT_VERSION=$* \ |
104 | | - DOCKER_CONNECT_IMAGE_TAG=$(DOCKER_CONNECT_IMAGE_TAG) \ |
105 | | - DOCKER_CONNECT_IMAGE=$(DOCKER_CONNECT_IMAGE) \ |
106 | | - DOCKER_PROJECT_IMAGE_TAG=$(DOCKER_PROJECT_IMAGE_TAG) \ |
107 | | - PYTEST_ARGS="$(PYTEST_ARGS)" \ |
108 | | - $(DOCKER_COMPOSE) -p $(PROJECT_NAME)-$(subst .,-,$(CONNECT_VERSION)) up -V --abort-on-container-exit --no-build |
109 | | - |
110 | 77 | # Show available versions |
111 | 78 | print-versions: |
112 | 79 | @printf "%s\n" $(strip $(CONNECT_VERSIONS)) |
113 | 80 |
|
114 | 81 | # Show help message. |
115 | 82 | help: |
116 | 83 | @echo "Makefile Targets:" |
117 | | - @echo " all (default) Run test suite for all Connect versions." |
118 | | - @echo " latest Run test suite for latest Connect version." |
119 | | - @echo " preview Run test suite for preview Connect version." |
120 | | - @echo " <version> Run test suite for the specified Connect version. (e.g., make 2024.05.0)" |
121 | | - @echo " up Start Docker Compose for all Connect versions." |
122 | | - @echo " down Tear down Docker resources for all Connect versions." |
123 | | - @echo " clean Clean up the project directory." |
| 84 | + @echo " latest (default) Run test suite for latest Connect version." |
| 85 | + @echo " all Run test suite for all Connect versions." |
| 86 | + @echo " <version> Run test suite for the specified Connect version. (e.g., make 2025.10.0)" |
| 87 | + @echo " clean Clean up logs and reports directories." |
124 | 88 | @echo " print-versions Show the available Connect versions." |
125 | 89 | @echo " help Show this help message." |
126 | 90 | @echo |
127 | 91 | @echo "Common Usage:" |
128 | | - @echo " make -j 4 Run test suite in parallel for all Connect versions." |
| 92 | + @echo " make Run test suite for latest Connect version (default)." |
129 | 93 | @echo " make latest Run test suite for latest Connect version." |
130 | | - @echo " make preview Run test suite for preview Connect version." |
131 | | - @echo " make 2024.05.0 Run test suite for specific Connect version." |
| 94 | + @echo " make 2025.10.0 Run test suite for specific Connect version." |
| 95 | + @echo " make all Run test suite for all Connect versions." |
| 96 | + @echo " make -j 4 all Run test suite in parallel for all Connect versions." |
132 | 97 | @echo |
133 | 98 | @echo "Environment Variables:" |
134 | | - @echo " DOCKER_COMPOSE Command to invoke Docker Compose. Default: docker compose" |
135 | | - @echo " DOCKER_CONNECT_IMAGE Docker image name for Connect. Default: rstudio/rstudio-connect" |
136 | | - @echo " DOCKER_PROJECT_IMAGE_TAG Docker image name and tag for the project image. Default: $(PROJECT_NAME):latest" |
137 | | - @echo " PYTEST_ARGS Arguments to pass to pytest. Default: \"-s\"" |
138 | | - |
139 | | -# Run tests. |
140 | | -test: |
141 | | - mkdir -p logs |
142 | | - set -o pipefail; \ |
143 | | - CONNECT_VERSION=${CONNECT_VERSION} \ |
144 | | - CONNECT_API_KEY="$(shell $(UV) run rsconnect bootstrap -i -s http://connect:3939 --raw)" \ |
145 | | - $(UV) run pytest $(PYTEST_ARGS) --junit-xml=./reports/$(CONNECT_VERSION).xml | \ |
146 | | - tee ./logs/$(CONNECT_VERSION).log; |
| 99 | + @echo " PYTEST_ARGS Arguments to pass to pytest. Default: \"-s\"" |
0 commit comments