Skip to content

Commit

Permalink
DX: add test stage to GitLab CI (#253)
Browse files Browse the repository at this point in the history
* DX: always upload GitLab CI caches
* DX: cache Julia packages
* DX: cache `julia` binary
* DX: define GitLab CI stages
* DX: print `julia` version
* DX: run `pre-commit` on GitLab CI
* DX: run `pytest` on GitLab CI
* FIX: add JAX to package dependencies
* FIX: add `matplotlib` to package dependencies
* FIX: add `tensorwaves` to package dependencies
* FIX: list `pytest` under `sty` dependencies
* MAINT: address pre-commit issues
* MAINT: reduce cache sizes
* MAINT: remove deprecated `set-output`
  https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
* MAINT: set `JULIA_CI` to `true`
  https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_CI
* MAINT: update hashes in `test_get_readable_hash_large`
* MAINT: update pip constraints and pre-commit

Co-authored-by: GitHub <[email protected]>
  • Loading branch information
redeboer and web-flow authored Nov 21, 2022
1 parent 66cdcbd commit 20991b6
Show file tree
Hide file tree
Showing 15 changed files with 176 additions and 57 deletions.
8 changes: 4 additions & 4 deletions .constraints/py3.10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ ipywidgets==8.0.2
isort==5.10.1
jax==0.3.25
jaxlib==0.3.25
jedi==0.18.1
jedi==0.18.2
jinja2==3.1.2
json5==0.9.10
jsonschema==4.17.0
jupyter-cache==0.5.0
jupyter-client==7.4.7
jupyter-core==5.0.0
jupyter-resource-usage==0.6.4
jupyter-server==1.23.2
jupyter-server==1.23.3
jupyterlab==3.5.0
jupyterlab-code-formatter==1.5.3
jupyterlab-markup==1.1.0
Expand Down Expand Up @@ -97,7 +97,7 @@ nest-asyncio==1.5.6
nodeenv==1.7.0
notebook==6.5.2
notebook-shim==0.2.2
numpy==1.23.4
numpy==1.23.5
opt-einsum==3.3.0
packaging==21.3
pandas==1.5.1
Expand All @@ -113,7 +113,7 @@ plotly==5.11.0
pluggy==1.0.0
pre-commit==2.20.0
prometheus-client==0.15.0
prompt-toolkit==3.0.32
prompt-toolkit==3.0.33
psutil==5.9.4
ptyprocess==0.7.0
pure-eval==0.2.2
Expand Down
6 changes: 3 additions & 3 deletions .constraints/py3.7.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ ipywidgets==8.0.2
isort==5.10.1
jax==0.3.25
jaxlib==0.3.25
jedi==0.18.1
jedi==0.18.2
jinja2==3.1.2
json5==0.9.10
jsonschema==4.17.0
jupyter-cache==0.5.0
jupyter-client==7.4.7
jupyter-core==4.11.2
jupyter-resource-usage==0.6.4
jupyter-server==1.23.2
jupyter-server==1.23.3
jupyterlab==3.5.0
jupyterlab-code-formatter==1.5.3
jupyterlab-markup==1.1.0
Expand Down Expand Up @@ -112,7 +112,7 @@ plotly==5.11.0
pluggy==1.0.0
pre-commit==2.20.0
prometheus-client==0.15.0
prompt-toolkit==3.0.32
prompt-toolkit==3.0.33
psutil==5.9.4
ptyprocess==0.7.0
py==1.11.0
Expand Down
8 changes: 4 additions & 4 deletions .constraints/py3.8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ ipywidgets==8.0.2
isort==5.10.1
jax==0.3.25
jaxlib==0.3.25
jedi==0.18.1
jedi==0.18.2
jinja2==3.1.2
json5==0.9.10
jsonschema==4.17.0
jupyter-cache==0.5.0
jupyter-client==7.4.7
jupyter-core==5.0.0
jupyter-resource-usage==0.6.4
jupyter-server==1.23.2
jupyter-server==1.23.3
jupyterlab==3.5.0
jupyterlab-code-formatter==1.5.3
jupyterlab-markup==1.1.0
Expand Down Expand Up @@ -98,7 +98,7 @@ nest-asyncio==1.5.6
nodeenv==1.7.0
notebook==6.5.2
notebook-shim==0.2.2
numpy==1.23.4
numpy==1.23.5
opt-einsum==3.3.0
packaging==21.3
pandas==1.5.1
Expand All @@ -115,7 +115,7 @@ plotly==5.11.0
pluggy==1.0.0
pre-commit==2.20.0
prometheus-client==0.15.0
prompt-toolkit==3.0.32
prompt-toolkit==3.0.33
psutil==5.9.4
ptyprocess==0.7.0
pure-eval==0.2.2
Expand Down
8 changes: 4 additions & 4 deletions .constraints/py3.9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ ipywidgets==8.0.2
isort==5.10.1
jax==0.3.25
jaxlib==0.3.25
jedi==0.18.1
jedi==0.18.2
jinja2==3.1.2
json5==0.9.10
jsonschema==4.17.0
jupyter-cache==0.5.0
jupyter-client==7.4.7
jupyter-core==5.0.0
jupyter-resource-usage==0.6.4
jupyter-server==1.23.2
jupyter-server==1.23.3
jupyterlab==3.5.0
jupyterlab-code-formatter==1.5.3
jupyterlab-markup==1.1.0
Expand Down Expand Up @@ -97,7 +97,7 @@ nest-asyncio==1.5.6
nodeenv==1.7.0
notebook==6.5.2
notebook-shim==0.2.2
numpy==1.23.4
numpy==1.23.5
opt-einsum==3.3.0
packaging==21.3
pandas==1.5.1
Expand All @@ -113,7 +113,7 @@ plotly==5.11.0
pluggy==1.0.0
pre-commit==2.20.0
prometheus-client==0.15.0
prompt-toolkit==3.0.32
prompt-toolkit==3.0.33
psutil==5.9.4
ptyprocess==0.7.0
pure-eval==0.2.2
Expand Down
2 changes: 2 additions & 0 deletions .cspell/python.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ linewidth
linspace
makedirs
matplotlib
maxsize
meshgrid
nbconvert
ncols
Expand All @@ -66,6 +67,7 @@ pyplot
pyright
pytest
rcdefaults
repr
scipy
seealso
sharey
Expand Down
1 change: 1 addition & 0 deletions .cspell/this-project.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ nbformat
pdfnb
phsp
pushd
pytest
PYTHONHASHSEED
Remco
texlive
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/requirements-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ jobs:
fetch-depth: 0
- name: Determine dependency changes
run: |
DIFF="$(git diff origin/main --color -- .constraints .pre-commit-config.yaml setup.cfg)"
echo ::set-output name=diff::"${DIFF}"
echo 'diff<<EOF' >> $GITHUB_OUTPUT
git diff origin/main --color -- .constraints .pre-commit-config.yaml setup.cfg >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
id: diff
outputs:
diff: ${{ steps.diff.outputs.diff }}
Expand Down Expand Up @@ -80,7 +81,7 @@ jobs:
cd artifact
ls -A
[[ -f .pre-commit-config.yaml ]] && mv -f .pre-commit-config.yaml ..
[[ "$(ls)" != "" ]] && mkdir -p ../.constraints/ && mv -f * ../.constraints/
[[ "$(ls)" != "" ]] && mv -f * ../.constraints/
fi
- run: git status -s
- name: Commit and push changes
Expand All @@ -91,7 +92,7 @@ jobs:
git checkout -b ${GITHUB_HEAD_REF}
if [[ $(git status -s) ]]; then
git add -A
git commit -m "MAINT: update pip constraints and pre-commit config"
git commit -m "MAINT: update pip constraints and pre-commit"
git config pull.rebase true
git pull origin ${GITHUB_HEAD_REF}
git push origin HEAD:${GITHUB_HEAD_REF}
Expand Down
122 changes: 108 additions & 14 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
image: python:3.8

cache:
- paths:
- .cache/pip
- key:
.cache-definitions:
- &julia
key:
prefix: julia
files:
- julia/Manifest.toml
- julia/Project.toml
paths:
- .julia/
- julia-*/
when: always

- &pip
key:
prefix: pip
files:
- .constraints/*.txt
paths:
- .cache/pip/
when: always

- &pre-commit
key:
prefix: pre-commit
files:
- .pre-commit-config.yaml
paths:
- .cache/pre-commit/
when: always

- &sphinx
key:
prefix: myst-nb
files:
- .constraints/*.txt
Expand All @@ -17,39 +45,105 @@ cache:
- docs/_static/export
- docs/_static/images
- docs/appendix/export
- key:
when: always

- &sympy
key:
prefix: sympy
files:
- .constraints/*.txt
paths:
- .sympy-cache-jax
- .sympy-cache
when: always

pages:
only:
- main
- tags
pre-commit:
stage: test
cache:
- *pip
- *pre-commit
before_script:
- python3 -m pip install -e .[sty] -c .constraints/py3.8.txt
script:
- pre-commit run -a --color always

pytest:
stage: test
cache:
- *pip
- *sympy
before_script:
- python3 -m pip install .[test] -c .constraints/py3.8.txt
script:
- pytest -n auto

pytest-slow:
stage: build
cache:
- *pip
- *sympy
before_script:
- python3 -m pip install .[test] -c .constraints/py3.8.txt
script:
- pytest -n auto -m slow

documentation:
stage: build
cache:
- *julia
- *pip
- *sphinx
- *sympy
before_script:
- apt-get update
- apt-get install -y cm-super dvipng inkscape latexmk texlive-fonts-extra texlive-latex-extra texlive-xetex xindy
- python3 -m pip install .[doc] tox -c .constraints/py3.8.txt
- wget -q https://julialang-s3.julialang.org/bin/linux/x64/1.7/julia-1.7.3-linux-x86_64.tar.gz
- tar xzf julia-1.7.3-linux-x86_64.tar.gz
- mv julia-1.7.3 /opt/
- ln -s /opt/julia-1.7.3/bin/julia /usr/local/bin/julia
- version=$(sed -n '3p' julia/Manifest.toml)
- version=${version:17:-1}
- major_version=${version:0:-2}
- filename=julia-${version}-linux-x86_64.tar.gz
- |
if [ ! -d julia-${version} ]; then
wget -q https://julialang-s3.julialang.org/bin/linux/x64/${major_version}/${filename}
tar xzf ${filename}
fi
- mv julia-${version} /opt/
- ln -s /opt/julia-${version}/bin/julia /usr/local/bin/julia
- julia --version
- julia --project=./julia -e 'import Pkg; Pkg.instantiate()'
script:
- tox -e pdfnb
- EXECUTE_PLUTO="YES" tox -e docnb
artifacts:
paths:
- docs/_build/html
- docs/_build/latex
when: always

pages:
stage: deploy
dependencies:
- documentation
only:
- main
- tags
script:
- mv docs/_build/html/ public/
- tar czf public/latex.tar.gz -C docs/_build/ latex/
artifacts:
paths:
- public
when: always

stages:
- test
- build
- deploy

# https://docs.gitlab.com/ee/ci/caching/#cache-python-dependencies
variables:
JULIA_CI: "true"
JULIA_DEPOT_PATH: "$CI_PROJECT_DIR/.julia/"
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
PRE_COMMIT_HOME: "$CI_PROJECT_DIR/.cache/pre-commit"
PYTHONHASHSEED: "0"
SYMPY_CACHE_DIR: "$CI_PROJECT_DIR"
2 changes: 2 additions & 0 deletions docs/extensions/relink_references.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# cspell:ignore refdomain refspecific reftarget reftype
# pyright: reportMissingImports=false
# pyright: reportMissingModuleSource=false
"""Abbreviated the annotations generated by sphinx-autodoc.
It's not necessary to generate the full path of type hints, because they are
Expand Down
2 changes: 2 additions & 0 deletions docs/extensions/support_bibtex_math.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# cspell:ignore bibtex latexcodec pybtex sphinxcontrib ulatex
# pyright: reportMissingImports=false
# pyright: reportMissingModuleSource=false
"""Enable math mode in `sphinxcontrib-bibtex`.
.. note:: The source code below is inspired by
Expand Down
2 changes: 2 additions & 0 deletions docs/extensions/unsrt_et_al.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# pyright: reportMissingImports=false
# pyright: reportMissingModuleSource=false
from pybtex.database import Entry
from pybtex.plugin import register_plugin
from pybtex.richtext import Tag, Text
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ black = [
]
flake8 = [
"--extend-ignore=E501,E731",
"--per-file-ignores=docs/appendix/homomorphism*:E402",
"--per-file-ignores=docs/zz.polarization-fit*:E741",
"--per-file-ignores=docs/appendix/homomorphism*:E402,docs/zz.polarization-fit*:E741",
]
isort = [
"--line-length=85",
Expand Down
Loading

0 comments on commit 20991b6

Please sign in to comment.