Skip to content

Commit

Permalink
adopt Tox for local dev/ci (#20)
Browse files Browse the repository at this point in the history
* add tox testenv:[dev,docs]
* add publish doc workflow
* mkdocs.yml updated
  • Loading branch information
github-actions[bot] authored Jun 23, 2022
1 parent 786d9bc commit e1538b3
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ jobs:
fetch-depth: 0

- name: Set up Python 3.10
uses: actions/setup-python@v1
uses: actions/setup-python@v3
with:
python-version: '3.10'

Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/publish_doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Publish Docs
on:
push:
branches:
- master
paths:
- docs
- overrides
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: 3.10
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ site/
coverage.xml
coverage.txt
unit.xml

mydev/
1 change: 0 additions & 1 deletion docs/reference/SunEarthAnalyzer.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# SunEarthAnalyzer

::: fseg.SunEarthAnalyzer
8 changes: 4 additions & 4 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ repo_url: https://github.com/mikesongming/SE-Geometry

theme:
name: material
nav_style: light
# nav_style: dark
logo: assets/images/logo.png
custom_dir: overrides
highlightjs: true
hljs_languages:
- yaml
# highlightjs: true
# hljs_languages:
# - yaml
features:
- navigation.tabs
- navigation.tabs.sticky
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = [
"setuptools >= 61",
"wheel >= 0.37",
"build >= 0.7",
"versioningit >= 1.1",
"versioningit >= 2.0",
"ninja >= 1.10",
]
build-backend = "setuptools.build_meta"
Expand Down Expand Up @@ -72,7 +72,7 @@ markers = [
"mpi: mark tests for mpi implementation",
"gpu: mark tests for gpu implementation",
]
addopts = """-s --cache-clear \
addopts = """--cache-clear \
--cov-report term-missing --cov=fseg \
--cov-fail-under=80 --cov-branch \
-rfExXs
Expand Down
16 changes: 10 additions & 6 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
tox
tox-conda
pre-commit
tox>=3.25.0
build>=0.7.0
ninja>=1.10
versioningit>=2
towncrier

pre-commit>=2.19
flake8>=4
black>=22
isort>=5.10
mypy
flake8
black
isort

-r requirements-test.txt
8 changes: 4 additions & 4 deletions requirements-doc.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fseg # mkdocs need to retrieve version
# fseg # mkdocs need to retrieve version

mkdocs
mkdocs-material
mkdocs-include-markdown-plugin
mkdocs-material>=8.3
mkdocs-include-markdown-plugin>=3.5
mkdocstrings
mkdocstrings-python
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pytest>=7.1
numpy>=1.21
pytest-cov>=3
65 changes: 49 additions & 16 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,55 @@
# and then run "tox" from this directory.

[tox]
envlist = py
envlist = dev, docs
minversion = 3.25.0
; skipsdist = True

# auto-provision
requires =
tox_conda

# use PEP517 build system
isolated_build = True

[testenv]
basepython = python3.10

setenv =
PYTHONHASHSEED=23

# use customized PYPI server
; setenv =
; PIP_INDEX_URL = https://pypi.my-alternative-index.org
; PIP_EXTRA_INDEX_URL = https://mypypiserver.org

whitelist_externals =
echo

[testenv:dev]
; deps告诉tox确保pytest已经安装,如果有多个测试依赖,可以按行罗列,同时也可以指定版本
# recreate env for each run
; recreate = True

# anaconda dependencies
conda_deps=
numpy>=1.21
conda_channels=
conda-forge

# pypi dependencies
deps =
-rrequirements-dev.txt

commands =
pre-commit run --all-files
pytest --basetemp="{envtmpdir}" {posargs}

[testenv:docs]
description = Run a development server for working on documentation

deps =
pytest
; 告诉tox在每个测试环境里运行pytest
commands = pytest --junitxml=junit-{envname}.xml
[pytest]
markers =
smoke: 用于冒烟测试
get

addopts = -rsxX -l --tb=short --strict
xfail_strict = true
minversion = 3.0
norecursedirs = .* venv src *.egg dist build
testpaths = tests
python_classes = *Test Test* *Suit
-rrequirements-doc.txt

commands = mkdocs build --clean
python -c 'print("###### Starting local server. Press Control+C to stop server ######")'
- mkdocs serve -a localhost:8080

0 comments on commit e1538b3

Please sign in to comment.