Skip to content

Commit db2f421

Browse files
committed
ci: skip workflows when no tests/benchmarks exist and clean up config
- Add collect jobs to test and benchmark workflows to skip when no tests/benchmarks are present - Remove default dependencies to make the template more generic - Clean up pyright and ruff exclude patterns and remove unused pytest option
1 parent 76f1295 commit db2f421

3 files changed

Lines changed: 49 additions & 8 deletions

File tree

template/.github/workflows/bench.yaml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,34 @@ jobs:
2323
with:
2424
cancel-others: true
2525

26-
bench:
27-
name: Bench
26+
collect:
27+
name: Collect
2828
needs:
2929
- skip-duplicate
3030
if: needs.skip-duplicate.outputs.should-skip != 'true'
3131
runs-on: ubuntu-latest
32+
outputs:
33+
has-benches: ${{ steps.collect.outputs.has-benches }}
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v5
37+
- name: Setup Python
38+
uses: liblaf/actions/setup-python@dist
39+
- id: collect
40+
name: Collect
41+
run: |-
42+
if pytest -m 'benchmark' --collect-only; then
43+
echo 'has-benches=true' >> "$GITHUB_OUTPUT"
44+
else
45+
echo 'has-benches=false' >> "$GITHUB_OUTPUT"
46+
fi
47+
48+
bench:
49+
name: Bench
50+
needs:
51+
- collect
52+
if: needs.collect.outputs.has-benches == 'true'
53+
runs-on: ubuntu-latest
3254
steps:
3355
- name: Checkout
3456
uses: actions/checkout@v5

template/.github/workflows/test.yaml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,33 @@ jobs:
2525
with:
2626
cancel-others: true
2727

28-
test:
29-
name: Test
28+
collect:
29+
name: Collect
3030
needs:
3131
- skip-duplicate
3232
if: needs.skip-duplicate.outputs.should-skip != 'true'
33+
runs-on: ubuntu-latest
34+
outputs:
35+
has-tests: ${{ steps.collect.outputs.has-tests }}
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v5
39+
- name: Setup Python
40+
uses: liblaf/actions/setup-python@dist
41+
- id: collect
42+
name: Collect
43+
run: |-
44+
if pytest --collect-only; then
45+
echo 'has-tests=true' >> "$GITHUB_OUTPUT"
46+
else
47+
echo 'has-tests=false' >> "$GITHUB_OUTPUT"
48+
fi
49+
50+
test:
51+
name: Test
52+
needs:
53+
- collect
54+
if: needs.collect.outputs.has-tests == 'true'
3355
permissions:
3456
id-token: write
3557
runs-on: ubuntu-latest

template/pyproject.toml.jinja

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ classifiers = [
2323
"Programming Language :: Python :: 3.13",
2424
"Typing :: Typed",
2525
]
26-
dependencies = ["lazy-loader>=0.4,<0.5", "loguru>=0.7,<0.8"]
26+
dependencies = []
2727
dynamic = ["version"]
2828

2929
[project.urls]
@@ -84,7 +84,6 @@ linux = "6.12"
8484
# %% endif
8585

8686
[tool.pyright]
87-
exclude = ["**/.*", "**/__pycache__", "**/marimo", "**/node_modules"]
8887
extends = ".config/linters/pyrightconfig.json"
8988

9089
[tool.pytest.ini_options]
@@ -95,12 +94,10 @@ addopts = [
9594
"--showlocals",
9695
"--strict-config",
9796
"--strict-markers",
98-
"--suppress-no-test-exit-code",
9997
]
10098
testpaths = ["benches", "src", "tests"]
10199

102100
[tool.ruff]
103-
exclude = ["**/marimo/"]
104101
extend = ".config/linters/.ruff.toml"
105102

106103
# %% if package_manager == "uv":

0 commit comments

Comments
 (0)