Skip to content

Commit 78f310a

Browse files
authored
ci: select Hurl examples by path (#1537)
* ci: map Hurl suites in workflow YAML * ci: simplify Hurl example selection * ci: map Hurl suites with distinct integration coverage * ci: map complex templates to focused Hurl suites
1 parent d690f3d commit 78f310a

3 files changed

Lines changed: 150 additions & 4 deletions

File tree

‎.github/hurl-examples.yml‎

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Shared changes run every examples/*/test.hurl, including newly added examples.
2+
all_examples:
3+
- 'examples/**'
4+
- 'Dockerfile'
5+
- '.dockerignore'
6+
- 'Cargo.toml'
7+
- 'Cargo.lock'
8+
- 'build.rs'
9+
- '.cargo/**'
10+
- 'scripts/**'
11+
- '.github/workflows/ci.yml'
12+
- '.github/hurl-examples.yml'
13+
14+
# Keys are example folders; add one glob per line to associate more files.
15+
# Keep suites with distinctive integration coverage; describe it above each entry.
16+
17+
# Trace propagation through nginx and actual OTLP export into Tempo.
18+
'examples/telemetry':
19+
- 'src/telemetry.rs'
20+
- 'src/app_config.rs'
21+
- 'src/main.rs'
22+
- 'src/webserver/http.rs'
23+
- 'src/webserver/http_client.rs'
24+
- 'src/webserver/database/execute_queries.rs'
25+
26+
# Mailpit checks delivered MIME parts; the form asserts delayed multipart encoding.
27+
'examples/sending emails':
28+
- 'src/app_config.rs'
29+
- 'src/webserver/http_request_info.rs'
30+
- 'src/webserver/database/sqlpage_functions/functions/send_mail.rs'
31+
- 'src/webserver/database/sqlpage_functions/functions/uploaded_file_name.rs'
32+
- 'src/webserver/database/sqlpage_functions/functions/uploaded_file_path.rs'
33+
- 'src/webserver/database/sqlpage_functions/functions/read_file_as_data_url.rs'
34+
- 'sqlpage/templates/form.handlebars'
35+
36+
# Real Keycloak discovery, login, callback cookies, and identity claims in SQL.
37+
'examples/single sign on':
38+
- 'src/app_config.rs'
39+
- 'src/lib.rs'
40+
- 'src/webserver/oidc.rs'
41+
- 'src/webserver/http.rs'
42+
- 'src/webserver/routing.rs'
43+
- 'src/webserver/http_client.rs'
44+
- 'src/webserver/http_request_info.rs'
45+
- 'src/webserver/database/sqlpage_functions/functions/user_info*.rs'
46+
- 'src/webserver/database/sqlpage_functions/functions/oidc_logout_url.rs'
47+
48+
# A real proxy connects to SQLPage's Unix socket and rewrites pretty URLs.
49+
'examples/nginx':
50+
- 'src/app_config.rs'
51+
- 'src/main.rs'
52+
- 'src/webserver/http.rs'
53+
- 'src/webserver/routing.rs'
54+
55+
# Apache proxies a site prefix, including the missing trailing slash redirect.
56+
'examples/web servers - apache':
57+
- 'src/app_config.rs'
58+
- 'src/webserver/http.rs'
59+
- 'src/webserver/routing.rs'
60+
61+
# Load SpatiaLite's native library and use its spatial functions on pooled SQLite.
62+
'examples/make a geographic data application using sqlite extensions':
63+
- 'src/app_config.rs'
64+
- 'src/webserver/database/connect.rs'
65+
66+
# Create a PostgreSQL-backed page, request it, and render dynamic rows in a table.
67+
'examples/SQLPage developer user interface':
68+
- 'src/filesystem.rs'
69+
- 'src/file_cache.rs'
70+
- 'src/webserver/routing.rs'
71+
- 'src/webserver/database/sqlpage_functions/functions/link.rs'
72+
- 'sqlpage/templates/table.handlebars'
73+
74+
# Posted arrays feed MySQL JSON_TABLE; native JSON builds the select options.
75+
'examples/mysql json handling':
76+
- 'src/webserver/http_request_info.rs'
77+
- 'src/webserver/request_variables.rs'
78+
- 'src/webserver/single_or_vec.rs'
79+
- 'src/webserver/database/sql.rs'
80+
- 'src/webserver/database/sql/**'
81+
- 'src/webserver/database/execute_queries.rs'
82+
- 'src/webserver/database/sql_to_json.rs'
83+
- 'sqlpage/templates/form.handlebars'
84+
85+
# A real cookie jar round-trips an encoded space and removes it from a subfolder.
86+
'examples/read-and-set-http-cookies':
87+
- 'src/render.rs'
88+
- 'src/webserver/http_request_info.rs'
89+
- 'src/webserver/database/sqlpage_functions/functions/cookie.rs'
90+
91+
# Hash a new signup's password, authenticate it, and invalidate its login session.
92+
'examples/user-authentication':
93+
- 'src/render.rs'
94+
- 'src/webserver/http_request_info.rs'
95+
- 'src/webserver/database/sqlpage_functions/functions/hash_password.rs'
96+
- 'src/webserver/database/sqlpage_functions/functions/random_string.rs'
97+
- 'src/webserver/database/sqlpage_functions/functions/cookie.rs'
98+
99+
# Authenticated multipart upload persists an image into a writable container mount.
100+
'examples/image gallery with user uploads':
101+
- 'src/app_config.rs'
102+
- 'src/webserver/http_request_info.rs'
103+
- 'src/webserver/database/sqlpage_functions/functions/persist_uploaded_file.rs'
104+
- 'src/webserver/database/sqlpage_functions/functions/uploaded_file_mime_type.rs'
105+
- 'src/webserver/database/sqlpage_functions/functions/random_string.rs'
106+
107+
# JSON menus with icon-only submenus and arrays of custom scripts/styles.
108+
'examples/CRUD - Authentication': ['sqlpage/templates/shell.handlebars']
109+
110+
# Cards combine Markdown and remote chart/map/table embed markup.
111+
'examples/cards-with-remote-content': ['sqlpage/templates/card.handlebars']

‎.github/workflows/ci.yml‎

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,22 +336,42 @@ jobs:
336336
retention-days: 1
337337
hurl_examples:
338338
runs-on: ubuntu-latest
339+
permissions:
340+
contents: read
341+
pull-requests: read
342+
env:
343+
DIFF_BASE: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || github.event.before }}
339344
outputs:
340345
examples: ${{ steps.examples.outputs.examples }}
341346
steps:
342347
- uses: actions/checkout@v7
348+
with:
349+
fetch-depth: 0
350+
- id: paths
351+
name: Match changed paths to Hurl suites
352+
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
353+
if: ${{ github.ref_type != 'tag' && env.DIFF_BASE != '' && !startsWith(env.DIFF_BASE, '0000000') }}
354+
continue-on-error: true
355+
with:
356+
base: ${{ env.DIFF_BASE }}
357+
ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha || github.sha }}
358+
filters: .github/hurl-examples.yml
343359
- id: examples
344-
run: |
345-
examples="$(find examples -mindepth 2 -maxdepth 2 -name test.hurl -print | sed 's#/test.hurl$##' | sort | jq -R -s -c 'split("\n")[:-1]')"
346-
echo "examples=$examples" >> "$GITHUB_OUTPUT"
360+
name: Select relevant Hurl examples
361+
run: scripts/select-hurl-examples.sh
362+
env:
363+
PATHS_OUTCOME: ${{ steps.paths.outcome }}
364+
ALL_EXAMPLES: ${{ steps.paths.outputs.all_examples }}
365+
MATCHED_EXAMPLES: ${{ steps.paths.outputs.changes }}
347366
- name: Restore Hurl archive
348367
id: hurl-cache
368+
if: steps.examples.outputs.examples != '[]'
349369
uses: actions/cache@v6
350370
with:
351371
path: .cache/hurl
352372
key: hurl-${{ runner.os }}-x86_64-unknown-linux-gnu-${{ env.HURL_VERSION }}
353373
- name: Download Hurl archive
354-
if: steps.hurl-cache.outputs.cache-hit != 'true'
374+
if: steps.examples.outputs.examples != '[]' && steps.hurl-cache.outputs.cache-hit != 'true'
355375
run: |
356376
set -euo pipefail
357377
archive="hurl-${HURL_VERSION}-x86_64-unknown-linux-gnu.tar.gz"
@@ -366,6 +386,7 @@ jobs:
366386
test "$expected_sha" = "$actual_sha"
367387
)
368388
- name: Upload Hurl archive
389+
if: steps.examples.outputs.examples != '[]'
369390
uses: actions/upload-artifact@v7
370391
with:
371392
name: hurl-${{ env.HURL_VERSION }}-x86_64-unknown-linux-gnu
@@ -376,6 +397,7 @@ jobs:
376397
hurl:
377398
name: hurl (${{ matrix.example }})
378399
runs-on: ubuntu-latest
400+
if: ${{ needs.hurl_examples.outputs.examples != '[]' }}
379401
timeout-minutes: 15
380402
needs:
381403
- docker_build

‎scripts/select-hurl-examples.sh‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [[ "${PATHS_OUTCOME:-}" == success && "${ALL_EXAMPLES:-}" != true ]]; then
5+
examples="$MATCHED_EXAMPLES"
6+
else
7+
# Tags, missing diff bases, and failed path filtering run every example.
8+
examples="$(find examples -mindepth 2 -maxdepth 2 -name test.hurl -print \
9+
| sed 's#/test.hurl$##' | sort | jq -R -s -c 'split("\n")[:-1]')"
10+
fi
11+
12+
echo "examples=$examples" >> "$GITHUB_OUTPUT"
13+
echo "Selected Hurl examples: $examples" >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)