Skip to content

Commit

Permalink
use Tox in github workflow (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyburnett committed Sep 14, 2023
1 parent 60c77b1 commit 8e6053b
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: tests

on:
push:
branches:
- main
- '*x'
tags:
- '*'
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
with:
envs: |
- linux: check-style
test:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
with:
envs: |
- linux: py39
- linux: py310
- linux: py311-xdist
- macos: py311-xdist
- linux: py3-devdeps-xdist
- linux: py3-cov-xdist
coverage: codecov
pytest-results-summary: true
28 changes: 28 additions & 0 deletions .github/workflows/tests_scheduled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: scheduled tests

on:
schedule:
# Weekly Monday 6AM build
- cron: "0 0 * * 1"
pull_request:
# We also want this workflow triggered if the `Weekly CI` label is
# added or present when PR is updated
types:
- synchronize
- labeled
push:
tags: "*"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
if: (github.repository == 'spacetelescope/costools' && (github.event_name == 'schedule' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'Weekly CI')))
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
with:
envs: |
- linux: py3-devdeps-xdist
pytest-results-summary: true
55 changes: 55 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-case-conflict
- id: check-yaml
args: ["--unsafe"]
- id: check-toml
- id: check-merge-conflict
- id: check-symlinks
- id: debug-statements
- id: detect-private-key
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-mock-methods
- id: rst-directive-colons
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char

- repo: https://github.com/asottile/pyupgrade
rev: 'v3.10.1'
hooks:
- id: pyupgrade
args: ["--py38-plus"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.0.287'
hooks:
- id: ruff
args: ["--fix"]

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: bandit
args: ["-c", "pyproject.toml"]
additional_dependencies: ["bandit[toml]"]
8 changes: 8 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Use weekly astropy dev build
--extra-index-url https://pypi.anaconda.org/astropy/simple astropy --pre

# Use Bi-weekly numpy/scipy dev builds
--extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
numpy>=0.0.dev0
scipy>=0.0.dev0

41 changes: 41 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[tox]
env_list =
check-{style}
test{,-devdeps}{,-warnings,-cov}-xdist

[testenv:check-style]
skip_install = true
description = Run all style and file checks with pre-commit
deps =
pre-commit
commands =
pre-commit install-hooks
pre-commit run {posargs:--color always --all-files --show-diff-on-failure}

[testenv]
description =
run tests
devdeps: with the latest developer version of key dependencies
warnings: treating warnings as errors
cov: with coverage
xdist: using parallel processing
pass_env =
HOME
CI
TOXENV
CODECOV_*
extras =
test
deps =
xdist: pytest-xdist
commands_pre =
devdeps: pip install -r requirements-dev.txt -U --upgrade-strategy eager
pip list
commands =
pytest \
cov: --cov --cov-report term-missing --cov-report xml \
warnings: -W error \
regtests: --bigdata --slow --basetemp={homedir}/test_outputs \
xdist: -n auto \
{posargs}

0 comments on commit 8e6053b

Please sign in to comment.