Skip to content

Commit a84cfb5

Browse files
chore(copier): update from template
1 parent 5e28611 commit a84cfb5

File tree

6 files changed

+37
-51
lines changed

6 files changed

+37
-51
lines changed

.config/copier/.copier-answers.python.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This file is @generated by <https://github.com/liblaf/copier-python>.
22
# DO NOT EDIT!
33
# prettier-ignore
4-
_commit: 1ca09a0
4+
_commit: 5f6ae09
55
_src_path: gh:liblaf/copier-python
66
answers_file_shared: .config/copier/.copier-answers.shared.yaml
77
namespace: ''

.config/copier/mise-tasks/install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ function has() {
1212
if [[ -f 'pixi.lock' ]]; then
1313
pixi='pixi'
1414
if has pixi-wrapper.sh; then pixi='pixi-wrapper.sh'; fi
15-
"$pixi" install
15+
"$pixi" install "$@"
1616
fi
1717

1818
if [[ -f 'uv.lock' ]]; then
1919
uv='uv'
2020
if has uv-wrapper.sh; then uv='uv-wrapper.sh'; fi
21-
"$uv" sync --all-extras --all-groups
21+
"$uv" sync --all-extras --all-groups "$@"
2222
fi

.config/copier/mise-tasks/test.sh

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,45 @@ set -o errexit
55
set -o nounset
66
set -o pipefail
77

8-
function is-true() {
9-
case "${1,,}" in
8+
function is-in-ci() {
9+
if [[ -z ${CI:-} ]]; then
10+
return 1
11+
fi
12+
case "${CI,,}" in
1013
1 | on | true | y | yes) return 0 ;;
1114
0 | off | false | n | no | "") return 1 ;;
1215
*)
13-
echo "Invalid boolean: $1." >&2
16+
echo "Invalid boolean: $CI." >&2
1417
exit 1
1518
;;
1619
esac
1720
}
1821

22+
function needs-gpu() {
23+
for pkg in jax torch warp; do
24+
if python -c "import $pkg"; then
25+
return 0
26+
fi
27+
done
28+
return 1
29+
}
30+
1931
# ref: <https://github.com/scientific-python/lazy-loader#early-failure>
2032
export EAGER_IMPORT=1
2133

22-
if is-true "${CI-}"; then
34+
if needs-gpu; then
35+
numprocesses='0'
36+
else
37+
numprocesses='auto'
38+
fi
39+
40+
if is-in-ci; then
2341
# ref: <https://docs.codecov.com/docs/test-analytics#1-output-a-junit-xml-file-in-your-ci>
2442
pytest \
2543
--junit-xml='junit.xml' --override-ini junit_family=legacy \
2644
--cov --cov-branch \
27-
--numprocesses 'auto' \
45+
--numprocesses "$numprocesses" \
2846
"$@"
2947
else
30-
pytest --numprocesses 'auto' "$@"
48+
pytest --numprocesses "$numprocesses" "$@"
3149
fi

.config/copier/mise-tasks/upgrade.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ function has() {
1313
if [[ -f 'pixi.lock' ]]; then
1414
pixi='pixi'
1515
if has pixi-wrapper.sh; then pixi='pixi-wrapper.sh'; fi
16-
"$pixi" upgrade
16+
"$pixi" upgrade "$@"
1717
fi
1818

1919
if [[ -f 'uv.lock' ]]; then
2020
uv='uv'
2121
if has uv-wrapper.sh; then uv='uv-wrapper.sh'; fi
22-
"$uv" sync --upgrade
22+
"$uv" sync --upgrade "$@"
2323
fi

.github/workflows/bench.yaml

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,11 @@ jobs:
2323
with:
2424
cancel-others: true
2525

26-
detect:
27-
name: Detect
28-
needs:
29-
- skip-duplicate
30-
if: needs.skip-duplicate.outputs.should-skip != 'true'
31-
runs-on: ubuntu-latest
32-
outputs:
33-
bench: ${{ steps.bench.outcome == 'success' }}
34-
steps:
35-
- name: Checkout
36-
uses: actions/checkout@v5
37-
- id: bench
38-
name: Detect Benches
39-
run: |-
40-
find "benches" -name "test_*.py" -type f -print -quit |
41-
grep --quiet "benches"
42-
continue-on-error: true
43-
4426
bench:
4527
name: Bench
4628
needs:
47-
- detect
48-
if: needs.detect.outputs.bench == 'true'
29+
- skip-duplicate
30+
if: needs.skip-duplicate.outputs.should-skip != 'true'
4931
runs-on: ubuntu-latest
5032
steps:
5133
- name: Checkout
@@ -59,3 +41,5 @@ jobs:
5941
with:
6042
run: mise run bench
6143
mode: instrumentation
44+
env:
45+
FORCE_COLOR: 1

.github/workflows/test.yaml

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

28-
detect:
29-
name: Detect
30-
needs:
31-
- skip-duplicate
32-
if: needs.skip-duplicate.outputs.should-skip != 'true'
33-
runs-on: ubuntu-latest
34-
outputs:
35-
test: ${{ steps.test.outcome == 'success' }}
36-
steps:
37-
- name: Checkout
38-
uses: actions/checkout@v5
39-
- id: test
40-
name: Detect Tests
41-
run: |-
42-
find "tests" -name "test_*.py" -type f -print -quit |
43-
grep --quiet "tests"
44-
continue-on-error: true
45-
4628
test:
4729
name: Test
4830
needs:
49-
- detect
50-
if: needs.detect.outputs.test == 'true'
31+
- skip-duplicate
32+
if: needs.skip-duplicate.outputs.should-skip != 'true'
5133
permissions:
5234
id-token: write
5335
runs-on: ubuntu-latest
@@ -62,6 +44,8 @@ jobs:
6244
uses: jdx/mise-action@v3
6345
- name: Test
6446
run: mise run test
47+
env:
48+
FORCE_COLOR: 1
6549
- name: Upload Coverage
6650
uses: codecov/codecov-action@v5
6751
with:

0 commit comments

Comments
 (0)