Skip to content

Commit

Permalink
chore: simplify tox and ci pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
Rogdham committed Aug 14, 2023
1 parent 7273b44 commit 1c416db
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 79 deletions.
69 changes: 21 additions & 48 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: build

on: [push, pull_request]
on:
- push
- pull_request

env:
PY_COLORS: 1
Expand All @@ -26,76 +28,49 @@ jobs:
- name: Install dependencies
run: pip install tox
- name: Run tests
run: tox -e py
run: tox run -e py

tests-misc:
runs-on: ubuntu-latest
strategy:
matrix:
env: [type, lint, format]
env:
- build
- docs
- format
- lint
- type
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: pip install tox
- name: Run ${{ matrix.env }}
run: tox -e ${{ matrix.env }}

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# build env: fetch all commits for version computation
fetch-depth: ${{ matrix.env == 'build' && '0' || '1' }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: pip install tox
- name: Run docs
run: |
tox -e docs
mkdir -p dist
tar czf dist/docs.tar.gz -C build docs
- name: Save docs artifacts
uses: actions/upload-artifact@v3
with:
name: docs
path: dist/docs.tar.gz

build:
needs: [tests-py, tests-misc, docs]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# fetch all commits for setuptools_scm
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: pip install build
- name: Build
run: python -m build
- name: Save build artifacts
- name: Run ${{ matrix.env }}
run: tox run -e ${{ matrix.env }}
- if: ${{ matrix.env == 'build' || matrix.env == 'docs' }}
name: Save ${{ matrix.env }} artifacts
uses: actions/upload-artifact@v3
with:
name: dist
name: ${{ matrix.env }}
path: dist

publish:
if: startsWith(github.ref, 'refs/tags')
needs: build
needs:
- tests-py
- tests-misc
runs-on: ubuntu-latest
steps:
- name: Restore build artifacts
uses: actions/download-artifact@v3
with:
name: dist
name: build
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand All @@ -112,8 +87,6 @@ jobs:
with:
name: docs
path: dist
- name: Extract docs
run: tar xf dist/docs.tar.gz -C dist
- name: Deploy docs
uses: JamesIves/github-pages-deploy-action@v4
with:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ this project is described in the documentation.

- Necessary code changes following dev dependency update: ruff
- Use `pyproject.toml` and modern build system
- Improve tox & CI pipelines

## [0.10.0] - 2023-04-22

Expand Down
26 changes: 13 additions & 13 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# install + dependencies
-e .

# typing
mypy
# build
build

# tests
coverage
pytest
pytest-cov
# docs
mkdocs

# format
black

# lint
pylint
ruff==0.0.284

# format
black

# publish
build
# tests
coverage
pytest
pytest-cov

# docs
mkdocs
# type
mypy
2 changes: 1 addition & 1 deletion docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repo_url: https://github.com/rogdham/bigxml
site_url: https://bigxml.rogdham.net/
edit_uri: blob/master/docs/src
docs_dir: src
site_dir: ../build/docs
site_dir: ../dist/docs
nav:
- Home: index.md
- User guide:
Expand Down
4 changes: 2 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ The most used imports are the following:
:::python
from bigxml import Parser, xml_handle_element, xml_handle_text

If you want to catch [exceptions](exceptions) raised by this module:
If you want to catch [exceptions](exceptions.md) raised by this module:

:::python
from bigxml import BigXmlError

For [type hints](typing):
For [type hints](typing.md):

:::python
from bigxml import HandlerTypeHelper, XMLElement, XMLText
Expand Down
39 changes: 24 additions & 15 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
[tox]
envlist =
py, py38, py39, py310, py311, pypy3
docs, format, lint, type
build, docs, format, lint, type

[testenv]
package = wheel
wheel_build_env = .pkg # reuse same wheel accross envs
deps =
pytest
pytest-cov
Expand All @@ -17,13 +19,24 @@ commands =
pytest {posargs:-vv --cov-fail-under=100}
py: -coverage html

[testenv:type]
[testenv:build]
skip_install = true
deps = build
commands =
python -m build

[testenv:docs]
skip_install = true
deps = mkdocs
commands =
mkdocs {posargs:build} -f docs/mkdocs.yml

[testenv:format]
skip_install = true
deps =
mypy
pytest # for typing
black
commands =
mypy
mypy --explicit-package-bases docs tests
black {posargs:--check --diff} docs src stubs tests

[testenv:lint]
deps =
Expand All @@ -34,14 +47,10 @@ commands =
ruff check src docs tests
pylint src docs tests

[testenv:format]
skip_install = true
[testenv:type]
deps =
black
mypy
pytest # for typing
commands =
black {posargs:--check --diff} docs src stubs tests

[testenv:docs]
skip_install = true
deps = mkdocs
commands = mkdocs {posargs:build} -f docs/mkdocs.yml
mypy
mypy --explicit-package-bases docs tests

0 comments on commit 1c416db

Please sign in to comment.