Skip to content

Commit

Permalink
use tox to build test environments and OpenAstronomy reusable wor…
Browse files Browse the repository at this point in the history
…kflow
  • Loading branch information
zacharyburnett committed Mar 25, 2023
1 parent c32158f commit 72d363f
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 55 deletions.
82 changes: 27 additions & 55 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,31 @@ name: CI
on: [push, pull_request]

jobs:
check:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
with:
envs: |
- linux: check-style
- linux: build-dist
- linux: build-docs
test:
name: test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.7", "3.10", "pypy-3.7", "pypy-3.8"]
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

# We need Python 3.7 to always be installed, so tests with
# multiple environments can run.
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: 3.7

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

- name: Install dependencies
run: python -m pip install -r requirements-dev.txt

- name: Install asv
run: pip install .

- name: Run tests
run: python -m pytest -v --timeout=300 --durations=100 test

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: '3.x'
cache: pip
cache-dependency-path: pyproject.toml

- name: Install dependencies
run: python -m pip install -r requirements-dev.txt

- name: Install asv
run: pip install ".[doc]"

- name: Build docs
run: sphinx-build -W docs/source html
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
with:
envs: |
- linux: test-mindeps-xdist
python-version: "3.7"
- linux: test-xdist
python-version: "3.7"
- linux: test-xdist
python-version: "pypy3.7"
- linux: test-xdist
python-version: "pypy3.8"
- linux: test-xdist
python-version: "3.10"
- linux: test-xdist
python-version: "3.11"
- macos: test-xdist
python-version: "3.11"
- linux: test-devdeps-xdist
- linux: test-xdist-cov
coverage: codecov
51 changes: 51 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[tox]
env_list =
check-{style}
test{,-mindeps}{,-warnings,-cov}-xdist
build-{docs,dist}

[testenv:check-style]
description = check code style
skip_install = true
deps =
ruff
commands =
ruff . {posargs}

[testenv]
description =
run tests
mindeps: with the minimum supported versions of key dependencies
warnings: treating warnings as errors
cov: with coverage
xdist: using parallel processing
extras =
test
deps =
xdist: pytest-xdist
mindeps: minimum_dependencies
devdeps: -rrequirements-dev.txt
commands_pre =
mindeps: minimum_dependencies asv --filename requirements-min.txt
mindeps: pip install -r requirements-min.txt
pip freeze
commands =
pytest -v --timeout 300 --durations 100 \
cov: --cov . --cov-report xml \
warnings: -W error \
xdist: -n auto \
{posargs}

[testenv:build-docs]
description = invoke sphinx-build to build the HTML docs
extras = docs
commands =
sphinx-build -W docs/source html

[testenv:build-dist]
description = package source and build wheel
skip_install = true
deps =
build
commands =
python -m build .

0 comments on commit 72d363f

Please sign in to comment.