Skip to content

Commit f86b303

Browse files
committed
fix(ci): Simplify workflow triggers and improve test collection logic
The `on.push` trigger for the `bench`, `docs`, and `test` workflows has been updated to explicitly run only on the `main` branch. This streamlines the CI process by ensuring workflows are only triggered on relevant pushes to the primary development branch. Additionally, the logic for detecting whether tests or benchmarks exist in `bench.yaml` and `test.yaml` has been made more robust. It now explicitly checks for `pytest` exit code `5` (no tests collected) before setting the `has-tests` output to false. The `has-benches` output in `bench.yaml` was also renamed to `has-tests` for consistency across related workflows.
1 parent bf3a8cb commit f86b303

3 files changed

Lines changed: 15 additions & 18 deletions

File tree

template/.github/workflows/bench.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ name: Bench
55

66
on:
77
push:
8-
branches-ignore:
9-
- copier-update
10-
- mega-linter-fix/**
11-
- pre-commit-ci-update-config
12-
- release-please--branches**
8+
branches:
9+
- main
1310
pull_request:
1411
workflow_dispatch:
1512

@@ -35,12 +32,18 @@ jobs:
3532
name: Collect
3633
run: |-
3734
if pytest -m 'benchmark' --collect-only; then
38-
echo 'has-benches=true' >> "$GITHUB_OUTPUT"
35+
echo 'has-tests=true' >> "$GITHUB_OUTPUT"
3936
else
40-
echo 'has-benches=false' >> "$GITHUB_OUTPUT"
37+
code="$?"
38+
if (("$code" == 5)); then
39+
echo 'has-tests=false' >> "$GITHUB_OUTPUT"
40+
else
41+
exit "$code"
42+
fi
4143
fi
4244
4345
# CodSpeedHQ does not support the same benchmark multiple times
46+
# so we don't run on multiple python versions here.
4447
bench:
4548
name: Bench
4649
needs:

template/.github/workflows/docs.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ name: Docs
55

66
on:
77
push:
8-
branches-ignore:
9-
- copier-update
10-
- mega-linter-fix/**
11-
- pre-commit-ci-update-config
12-
- release-please--branches**
8+
branches:
9+
- main
1310
pull_request:
1411
workflow_dispatch:
1512

@@ -29,7 +26,7 @@ jobs:
2926
name: Configure GitHub Pages
3027
uses: actions/configure-pages@v5
3128
- name: Set Environment Variables
32-
run: printf 'SITE_URL=%s\n' '${{ steps.config.outputs.base_url }}' >> "$GITHUB_ENV"
29+
run: echo 'SITE_URL=${{ steps.config.outputs.base_url }}' >> "$GITHUB_ENV"
3330
- name: Setup Python
3431
uses: liblaf/actions/setup-python@v1
3532
- if: hashFiles('docs/scripts/pre-build.sh') != ''

template/.github/workflows/test.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@ name: Test
77

88
on:
99
push:
10-
branches-ignore:
11-
- copier-update
12-
- mega-linter-fix/**
13-
- pre-commit-ci-update-config
14-
- release-please--branches**
10+
branches:
11+
- main
1512
pull_request:
1613
workflow_dispatch:
1714

0 commit comments

Comments
 (0)