Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Nov 6, 2024
1 parent f6faad3 commit 5301889
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 47 deletions.
46 changes: 0 additions & 46 deletions .github/workflows/checks.yml

This file was deleted.

79 changes: 79 additions & 0 deletions .github/workflows/cruft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# from https://cruft.github.io/cruft/#automating-updates-with-github-actions

name: Update repository with Cruft

permissions:
contents: write
pull-requests: write

on:
workflow_dispatch:
schedule:
- cron: "0 2 * * 1" # Every Monday at 2am

jobs:
update:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- add-paths: .
body: Use this to merge the changes to this repository.
branch: cruft/update
commit-message: "chore: accept new Cruft update"
title: New updates detected with Cruft
- add-paths: .cruft.json
body: Use this to reject the changes in this repository.
branch: cruft/reject
commit-message: "chore: reject new Cruft update"
title: Reject new updates detected with Cruft
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install Cruft
run: pip3 install cruft

- name: Check if update is available
continue-on-error: false
id: check
run: |
CHANGES=0
if [ -f .cruft.json ]; then
if ! cruft check; then
CHANGES=1
fi
else
echo "No .cruft.json file"
fi
echo "has_changes=$CHANGES" >> "$GITHUB_OUTPUT"
- name: Run update if available
if: steps.check.outputs.has_changes == '1'
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub"
cruft update --skip-apply-ask --refresh-private-variables
git restore --staged .
- name: Create pull request
if: steps.check.outputs.has_changes == '1'
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
add-paths: ${{ matrix.add-paths }}
commit-message: ${{ matrix.commit-message }}
branch: ${{ matrix.branch }}
delete-branch: true
branch-suffix: timestamp
title: ${{ matrix.title }}
body: |
This is an autogenerated PR. ${{ matrix.body }}
[Cruft](https://cruft.github.io/cruft/) has detected updates from the Cookiecutter repository.
2 changes: 1 addition & 1 deletion .github/workflows/ndex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@master
- uses: actions/setup-python@v2
with:
python-version: "3.9"
python-version: "3.12"
- name: Install dependencies
run: |
pip install tox
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# This file configures the continuous integration (CI) system on GitHub.
# Introductory materials can be found here: https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions.
# Documentation for editing this file can be found here: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions

name: Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
lint:
name: Code Quality
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.12", "3.9" ]
tox-command: ["manifest", "lint", "pyroma", "mypy"]
steps:
- uses: actions/checkout@v4
- name: "Install uv"
uses: "astral-sh/setup-uv@v3"
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: "Run command"
run: |
uvx -p ${{ matrix.python-version }} --with tox-uv tox -e ${{ matrix.tox-command }}
docs:
name: Documentation
runs-on: ubuntu-latest
strategy:
matrix:
# We only test documentation on the latest version
# sphinx 8.0 / sphinx-rtd-theme 3.0 discontinued Python 3.9 support
# a year early, which prompted re-thinking about this.
python-version: [ "3.12" ]
steps:
- uses: actions/checkout@v4
- name: "Install uv"
uses: "astral-sh/setup-uv@v3"
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Install dependencies
run: |
sudo apt-get install graphviz
- name: Check RST conformity with doc8
run: uvx -p ${{ matrix.python-version }} --with tox-uv tox -e doc8
- name: Check docstring coverage
run: uvx -p ${{ matrix.python-version }} --with tox-uv tox -e docstr-coverage
- name: Check documentation build with Sphinx
run: uvx -p ${{ matrix.python-version }} --with tox-uv tox -e docs-test
tests:
name: Tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
python-version: [ "3.12", "3.9" ]
steps:
- uses: actions/checkout@v4
- name: "Install uv"
uses: "astral-sh/setup-uv@v3"
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Test with pytest and generate coverage file
run:
uvx -p ${{ matrix.python-version }} --with tox-uv tox -e py
- name: Upload coverage report to codecov
uses: codecov/codecov-action@v4
if: success()
with:
file: coverage.xml

0 comments on commit 5301889

Please sign in to comment.