-
Notifications
You must be signed in to change notification settings - Fork 17
93 lines (87 loc) · 2.97 KB
/
test.yaml
File metadata and controls
93 lines (87 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Test
on:
push:
branches: [main]
pull_request:
branches: [main]
defaults:
run:
# to fail on error in multiline statements (-e), in pipes (-o pipefail), and on unset variables (-u).
shell: bash -euo pipefail {0}
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python: ["3.10", "3.12"]
os: [ubuntu-latest]
# one that matches "project-name".lower().replace('-', '_'), one that doesn’t:
package-name: [project_name, package_alt]
env:
PROJECT_ROOT: project-name
steps:
# Setup
- uses: actions/checkout@v4
- name: Set git identity
run: |
git config --global user.name "scverse-bot"
git config --global user.email "108668866+scverse-bot@users.noreply.github.com"
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: "pip"
cache-dependency-path: "{{cookiecutter.project_name}}/pyproject.toml"
- name: Install Ubuntu system dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install pandoc
- name: Install build & check dependencies
run: python -m pip install --upgrade pip wheel cookiecutter pre-commit
# Build
- name: Build from template
shell: python
run: |
from cookiecutter.main import cookiecutter
overrides = dict(package_name='${{ matrix.package-name }}')
cookiecutter('.', no_input=True, extra_context=overrides)
# Check
- name: Set up pre-commit cache
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ matrix.python }}|${{ hashFiles(format('{0}/.pre-commit-config.yaml', env.PROJECT_ROOT)) }}
- name: Run pre-commit
run: |
cd "$PROJECT_ROOT"
git add .
pre-commit run --verbose --color=always --show-diff-on-failure --all-files
- name: Install the package
run: |
cd $PROJECT_ROOT
pip install ".[doc]"
python -c "import ${{ matrix.package-name }}"
# Docs
- name: Build the documentation
env:
SPHINXOPTS: -W --keep-going
run: hatch run docs:build
test-scripts:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set git identity
run: |
git config --global user.name "scverse-bot"
git config --global user.email "108668866+scverse-bot@users.noreply.github.com"
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
cache-dependency-glob: pyproject.toml
- name: set git default branch
run: git config --global init.defaultBranch main
- name: Run tests
env:
SCVERSE_BOT_READONLY_GITHUB_TOKEN: ${{ secrets.SCVERSE_BOT_READONLY_GITHUB_TOKEN }}
working-directory: ./scripts
run: uvx hatch test