Skip to content

Use hatch in github actions #373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cruft-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.BOT_GH_TOKEN }}
FORCE_COLOR: "1"
COLUMNS: "150"
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: cruft-logs
path: log/
2 changes: 1 addition & 1 deletion .github/workflows/deploy-instance-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:

- name: Build from template
run: |
uv tool run --with pre-commit cruft create \
uvx --with pre-commit cruft create \
--no-input \
--output-dir $INSTANCE_GENERATED \
--extra-context-file .github/assets/cookiecutter-scverse-instance.json \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/propagate-pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
token: ${{ secrets.BOT_GH_TOKEN }}
- run: pipx install pre-commit
Expand Down
17 changes: 6 additions & 11 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: "**/pyproject.toml"
- name: set python default branch
cache-dependency-glob: pyproject.toml
- name: set git default branch
run: git config --global init.defaultBranch main
- name: Install build dependencies
run: python -m pip install --upgrade pip wheel
- name: Install package
run: pip install ./scripts[test]
- name: Run tests
run: pytest -v --color=yes ./scripts
working-directory: ./scripts
run: uvx hatch test
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ To create the project, run the following command and follow the prompts:

```bash
# uv will download all dependencies on-the-fly
uv tool run --with pre-commit cruft create https://github.com/scverse/cookiecutter-scverse
uvx --with pre-commit cruft create https://github.com/scverse/cookiecutter-scverse
```

This will create a git repository generated from the template.
Expand Down
3 changes: 1 addition & 2 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def skipped_dirs():
assert path.is_dir(), path
shutil.rmtree(path)

# Update pre commit hooks
run("pre-commit autoupdate -c .pre-commit-config.yaml".split(), check=True)
# Insatll pre-commit
run("pre-commit install".split(), check=True)

# The following output was generated using rich
Expand Down
21 changes: 12 additions & 9 deletions {{cookiecutter.project_name}}/.github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,23 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash -e {0} # -e to fail on error

jobs:
package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: "**/pyproject.toml"
- name: Install build dependencies
run: python -m pip install --upgrade pip wheel twine build
filter: blob:none
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
cache-dependency-glob: pyproject.toml
- name: Build package
run: python -m build
run: uv build
- name: Check package
run: twine check --strict dist/*.whl
run: uvx twine check --strict dist/*.whl
14 changes: 9 additions & 5 deletions {{cookiecutter.project_name}}/.github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
release:
types: [published]

defaults:
run:
shell: bash -e {0} # -e to fail on error

# Use "trusted publishing", see https://docs.pypi.org/trusted-publishers/
jobs:
release:
Expand All @@ -19,11 +23,11 @@ jobs:
with:
filter: blob:none
fetch-depth: 0
- uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: "3.x"
cache: "pip"
- run: pip install build
- run: python -m build
cache-dependency-glob: pyproject.toml
- name: Build package
run: uv build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
35 changes: 13 additions & 22 deletions {{cookiecutter.project_name}}/.github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash -e {0} # -e to fail on error

jobs:
test:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -e {0} # -e to fail on error

strategy:
fail-fast: false
Expand All @@ -40,28 +41,18 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: "pip"
cache-dependency-path: "**/pyproject.toml"

- name: Install test dependencies
run: |
python -m pip install --upgrade pip wheel
- name: Install dependencies
run: |
pip install ${{ matrix.pip-flags }} ".[dev,test]"
- name: Test
filter: blob:none
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
cache-dependency-glob: pyproject.toml
- name: run tests using hatch
env:
MPLBACKEND: agg
PLATFORM: ${{ matrix.os }}
DISPLAY: :42
run: |
coverage run -m pytest -v --color=yes
- name: Report coverage
run: |
coverage report
run: uvx hatch test --cover --python ${{ matrix.python }}
- name: Upload coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
Loading