Skip to content

Commit e9475ae

Browse files
AlexboiboiBoisselet Alexandre (IFAT DC ATV SC D TE2)
and
Boisselet Alexandre (IFAT DC ATV SC D TE2)
authoredNov 30, 2023
Rework CI/CD (magpylib#686)
* add github actions python-app.yml * move to pyproject.toml * remove makefile * add tox file * [pre-commit.ci] auto fixes from pre-commit.com hooks * remove setup file * move pytest.ini into pyproject.toml * fix syntax * move to tox gh action --------- Co-authored-by: Boisselet Alexandre (IFAT DC ATV SC D TE2) <[email protected]>
1 parent 8ff453f commit e9475ae

15 files changed

+200
-330
lines changed
 

‎.binder/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-r ../docs/requirements.txt
1+
.[docs]

‎.circleci/config.yml

-85
This file was deleted.

‎.github/workflows/python-app.yml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Python package
2+
3+
on: [push, pull_request]
4+
5+
concurrency:
6+
group: check-${{ github.ref }}
7+
cancel-in-progress: true
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Setup Python
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: "3.11"
18+
- name: Set up testing tools and environment for pylint
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install .[test]
22+
- name: Run pylint test
23+
run: pylint --rcfile='./.pylintrc' magpylib
24+
25+
test:
26+
name: test with ${{ matrix.py }} on ${{ matrix.os }}
27+
runs-on: ${{ matrix.os }}
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
py:
32+
- "3.12"
33+
- "3.11"
34+
- "3.10"
35+
- "3.9"
36+
- "3.8"
37+
os:
38+
- ubuntu-latest
39+
- macos-latest
40+
- windows-latest
41+
steps:
42+
- name: Setup headless display
43+
uses: pyvista/setup-headless-display-action@v2
44+
- uses: actions/checkout@v3
45+
with:
46+
fetch-depth: 0
47+
- name: Setup python for test ${{ matrix.py }}
48+
uses: actions/setup-python@v4
49+
with:
50+
python-version: ${{ matrix.py }}
51+
- name: Install tox
52+
run: python -m pip install tox-gh>=1.2
53+
- name: Setup test suite
54+
run: tox -vv --notest
55+
- name: Run test suite
56+
run: tox --skip-pkg-install
57+
58+
publish:
59+
name: Publish to PyPi
60+
needs: test
61+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
62+
runs-on: ubuntu-latest
63+
permissions:
64+
# IMPORTANT: this permission is mandatory for trusted publishing
65+
id-token: write
66+
steps:
67+
- name: Checkout source
68+
uses: actions/checkout@v4
69+
- name: Set up Python 3.8
70+
uses: actions/setup-python@v4
71+
with:
72+
python-version: 3.8
73+
- name: Build package
74+
run: |
75+
pip install wheel
76+
python setup.py sdist bdist_wheel
77+
- name: Publish
78+
uses: pypa/gh-action-pypi-publish@release/v1
79+

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ share/python-wheels/
2828
.installed.cfg
2929
*.egg
3030
MANIFEST
31+
_autogen
3132

3233
# docs
3334
docs/auto_examples

‎.readthedocs.yaml

+5-2
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,8 @@ sphinx:
2929

3030
# Optionally declare the Python requirements required to build your docs
3131
python:
32-
install:
33-
- requirements: docs/requirements.txt
32+
install:
33+
- method: pip
34+
path: .
35+
extra_requirements:
36+
- docs

‎Makefile

-23
This file was deleted.

‎azure-pipelines.yml

-36
This file was deleted.

‎docs/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ help:
1616
# Catch-all target: route all unknown targets to Sphinx using the new
1717
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1818
%: Makefile
19-
@pip install -r ./requirements.txt
19+
@pip install .[docs]
2020
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

‎docs/README.md

-38
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,3 @@ The Documentation is built with [Sphinx](http://www.sphinx-doc.org/en/main/) v5.
88
### Handwritten documents
99
Handwritten pages and guides are kept in the [_pages](./_pages) folder. They are all written in [Markdown](https://www.markdownguide.org/) using [myst-parser](https://github.com/executablebooks/MyST-Parser) as interface. Some documents like in the examples folder are dynamically computed with [myst-nb](https://github.com/executablebooks/myst-nb) as jupyter notebooks. With the help of the [jupytext](https://github.com/mwouts/jupytext) library ands its jupyterlab extension, examples can be written and executed within the jupyterlab ecosystem and saved as markdown file. It is recommended to use the [jupyterlab-myst](https://github.com/executablebooks/jupyterlab-myst) extension to be able to work with the full set of myst markdown flavor within jupyterlab. When editing the docs with vscode, use the [MyST-Markdown](https://marketplace.visualstudio.com/items?itemName=ExecutableBookProject.myst-highlight) extension to visualize the rendered document.
1010

11-
12-
### Building Locally
13-
14-
This repository is set up to be easily built on [ReadTheDocs](https://readthedocs.org/) as the codebase is updated.
15-
16-
##### To build locally on Linux,
17-
1. Install the dependencies on [requirements.txt](./requirements.txt):
18-
```
19-
pip install requirements.txt
20-
```
21-
22-
23-
2. Run [make](http://man7.org/linux/man-pages/man1/make.1.html) to build the documentation:
24-
25-
```bash
26-
27-
make html
28-
```
29-
30-
This will create a `_build` folder with an `index.html`, containing the built documentation webpage structure.
31-
32-
---
33-
34-
##### To build locally on Windows,
35-
36-
1. [Install Sphinx](http://www.sphinx-doc.org/en/main/usage/installation.html)
37-
2. Install the dependencies on [requirements.txt](./requirements.txt):
38-
```
39-
pip install -r requirements.txt
40-
```
41-
42-
3. Build the documentation with the `.bat` script:
43-
44-
```bash
45-
46-
make.bat html
47-
```
48-

‎docs/requirements.txt

-15
This file was deleted.

‎pyproject.toml

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
[build-system]
2+
requires = ["flit_core >=3.2,<4"]
3+
build-backend = "flit_core.buildapi"
4+
5+
[project]
6+
name = "magpylib"
7+
dynamic = ["version"]
8+
dependencies = [
9+
"numpy>=1.20",
10+
"scipy>=1.7",
11+
"matplotlib>=3.3",
12+
"plotly>=5.3",
13+
]
14+
requires-python = ">=3.8"
15+
authors = [
16+
{name = "Michael Ortner", email = "magpylib@gmail.com"},
17+
]
18+
maintainers = [
19+
{name = "Alexandre Boisselet", email = "alexabois+magpylib@gmail.com"}
20+
]
21+
description = "Free Python3 package to compute magnetic fields."
22+
readme = "README.md"
23+
license = {file = "LICENSE"}
24+
keywords = ["magnetism", "physics", "analytical", "electromagnetic", "magnetic-field", "B-field"]
25+
classifiers = [
26+
"Development Status :: 5 - Production/Stable",
27+
"Programming Language :: Python :: 3",
28+
"Programming Language :: Python :: 3.8",
29+
"Programming Language :: Python :: 3.9",
30+
"Programming Language :: Python :: 3.10",
31+
"Programming Language :: Python :: 3.11",
32+
"Intended Audience :: Developers",
33+
"Intended Audience :: Science/Research",
34+
"Intended Audience :: Education",
35+
"Operating System :: OS Independent",
36+
]
37+
38+
[project.optional-dependencies]
39+
code_style = [
40+
"pre-commit",
41+
]
42+
docs = [
43+
"sphinx==5.3",
44+
"sphinx-design",
45+
"sphinx-thebe",
46+
"sphinx-favicon",
47+
"sphinx-gallery",
48+
"sphinx-copybutton",
49+
"sphinx-book-theme",
50+
"myst-nb",
51+
"pandas",
52+
"numpy-stl",
53+
"pyvista==0.37",
54+
"panel",
55+
]
56+
test = [
57+
"tox",
58+
"pytest",
59+
"pylint",
60+
"coverage",
61+
"pandas",
62+
"pyvista",
63+
"ipygany",
64+
"imageio[tifffile]",
65+
"kaleido",
66+
"jupyterlab",
67+
]
68+
binder = [
69+
"jupytext",
70+
"jupyterlab>=3.2",
71+
"jupyterlab-myst",
72+
]
73+
74+
[project.urls]
75+
Documentation = "https://magpylib.readthedocs.io/en/latest/"
76+
Repository = "https://github.com/magpylib/magpylib.git"
77+
"Bug Tracker" = "https://github.com/magpylib/magpylib/issues"
78+
Changelog = "https://github.com/magpylib/magpylib/blob/master/CHANGELOG.md"
79+
80+
81+
[tool.pytest.ini_options]
82+
addopts = "--doctest-modules"
83+
testpaths = ["magpylib", "tests"]

‎pytest.ini

-4
This file was deleted.

‎setup.py

-112
This file was deleted.

‎tests/test_exceptions.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def getBHv_unknown_source_type():
2222
dimension=(0, 2, 1, 0, 360),
2323
position=(0, 0, -0.5),
2424
field="B",
25-
**GETBH_KWARGS
25+
**GETBH_KWARGS,
2626
)
2727

2828

@@ -131,7 +131,7 @@ def getBHv_bad_input1():
131131
field="B",
132132
magnetization=x2,
133133
dimension=x,
134-
**GETBH_KWARGS
134+
**GETBH_KWARGS,
135135
)
136136

137137

@@ -144,7 +144,7 @@ def getBHv_bad_input2():
144144
field="B",
145145
magnetization=x,
146146
dimension=x,
147-
**GETBH_KWARGS
147+
**GETBH_KWARGS,
148148
)
149149

150150

@@ -158,7 +158,7 @@ def getBHv_bad_input3():
158158
field="B",
159159
magnetization=x,
160160
dimension=x,
161-
**GETBH_KWARGS
161+
**GETBH_KWARGS,
162162
)
163163

164164

‎tox.ini

+26-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
[tox]
2-
envlist = py39
2+
min_version = 4.11.4
3+
env_list =
4+
py311
5+
6+
[gh]
7+
python =
8+
3.12 = py312
9+
3.11 = py311 #, type
10+
3.10 = py310
11+
3.9 = py39
12+
3.8 = py38
313

414
[testenv]
5-
# install pytest in the virtualenv where commands will be executed
6-
passenv = CODECOV_TOKEN
7-
deps = pytest-cov
8-
codecov
9-
extras = dev
15+
description = run the tests with pytest
16+
package = wheel
17+
wheel_build_env = .pkg
18+
deps =
19+
pytest>=7
20+
pytest-sugar
21+
extras = test
22+
commands =
23+
pytest {tty:--color=yes} {posargs}
24+
25+
[testenv:docs]
26+
description = build documentation
27+
extras = docs
1028
commands =
11-
# NOTE: you can run any command line tool here - not just tests
12-
py.test --junitxml=test-results/magpylib/results.xml --cov-report html --cov-report term:skip-covered --cov=magpylib
13-
codecov
29+
sphinx-build -d "{envtmpdir}{/}doctree" docs "{toxworkdir}{/}docs_out" --color -b html
30+
python -c 'print(r"documentation available under file:\\{toxworkdir}{/}docs_out{/}index.html")'

0 commit comments

Comments
 (0)
Please sign in to comment.