-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
196 lines (181 loc) · 5.64 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
image: python:3.12-slim
stages:
- test
- test-pedantic
- deploy
.pytest:
stage: test
script:
- python3 -m pip install -e .
- python3 -m pip install pytest
- python3 -m pytest tests/ -m "not slow"
only:
changes:
- eminus/*.py
- eminus/**/*.py
- tests/*.py
- tests/**/*.py
.pytest-pedantic:
extends: .pytest
stage: test-pedantic
when: manual
##### Lint Python files #####
lint:
stage: test
script:
- pip install ruff
- ruff check .
only:
changes:
- "*.py"
- "**/*.py"
##### Type check Python files #####
typecheck:
stage: test
script:
- pip install mypy
- mypy .
only:
changes:
- "*.py"
- "**/*.py"
##### Test and create coverage reports #####
coverage:
stage: test
script:
- python3 -m pip install -e .
- python3 -m pip install coverage pyscf pytest pytest-cov
- coverage run -m pytest tests/ --ignore=tests/examples --ignore=tests/extras
- coverage report --precision=2
- coverage xml
- coverage html --precision=2
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
paths:
- htmlcov/
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
only:
refs:
- main
# Fix: Run coverage even if only the lint or pages job run to prevent an unknown status badge
# Reference: https://gitlab.com/gitlab-org/gitlab/-/issues/346779
changes:
- "*.py"
- "**/*.py"
- docs/*
- docs/**/*
##### Test the minimally supported versions #####
minimal:
extends: .pytest
image: python:3.7-slim
before_script:
- pip install numpy==1.17.0 scipy==1.6.0
##### Test code functionality for all Python versions between #####
python:
extends: .pytest-pedantic
image: python:$PYTHON_VERSIONS-slim
parallel:
matrix:
- PYTHON_VERSIONS: ['3.8', '3.9', '3.10', '3.11']
##### Test code functionality under Linux, macOS, and Windows #####
platform:linux:
extends: .pytest-pedantic
image: ubuntu:latest
before_script:
- apt-get update -y
- apt-get install python3 python3-pip -y --no-install-recommends
platform:macos:
extends: .pytest-pedantic
image: sickcodes/docker-osx:latest
before_script:
- python3 -m ensurepip
platform:nixos:
extends: .pytest-pedantic
image: nixpkgs/nix:nixos-23.05
script:
# Remove Torch since the build time takes too long
- nix --extra-experimental-features "nix-command flakes" shell nixpkgs#gnused -c sed -i "s/ torch-bin/ \# torch-bin/g" flake.nix
# Remove Matplotlib since some example scripts will fail in the CI
- nix --extra-experimental-features "nix-command flakes" shell nixpkgs#gnused -c sed -i "s/matplotlib/\# matplotlib/g" flake.nix
# In the CI nix develop will open a shell and close it immediately afterwards, use -c to execute commands
- nix --extra-experimental-features "nix-command flakes" develop -c pytest tests/ -m "not slow"
platform:windows:
extends: .pytest-pedantic
tags:
- windows
before_script:
# https://gitlab.com/gitlab-org/ci-cd/shared-runners/images/gcp/windows-containers/-/issues/13
- Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
- choco install python -y --no-progress
- refreshenv
- Set-Alias -Name python3 -Value python
##### Test the code installation after building #####
installation:
extends: .pytest-pedantic
script:
- pip install --upgrade pip
- pip install build twine
- python -m build
# Do a check with twine
- twine check dist/*
# Remove pseudopotential files to check if the installation files work on their own
- rm -rf eminus/psp/
- cd dist/
# Test the source distribution
- tar -xf eminus-*.tar.gz
- pip install eminus-*/.
- python -c "import eminus; eminus.demo()"
# Test the wheel
- pip uninstall eminus -y
- pip install eminus-*.whl
- python -c "import eminus; eminus.demo()"
##### Build documentation #####
pages:
stage: deploy
dependencies:
- coverage
script:
- pip install -e .
# Build Sphinx documentation
- pip install sphinx furo sphinx-design sphinxcontrib-bibtex
- sphinx-build -j $(nproc) -b html ./docs ./public
# Convert notebooks to HTML
- pip install notebook
- find examples -name '*.ipynb' -exec jupyter nbconvert --to html {} --template classic --ExecutePreprocessor.store_widget_state=True \;
- find examples -name '*.html' -exec mv {} public/_static \;
# Minify all text files
- apt-get update -y
- apt-get install minify -y --no-install-recommends
- find public \( -name '*.css' -o -name '*.js' -o -name '*.svg' \) -exec minify -vo {} {} \;
- find public -name '*.html' -exec minify -vo {} {} --html-keep-document-tags --html-keep-end-tags --html-keep-whitespace \;
# Compress all text files
- find public \( -name '*.css' -o -name '*.html' -o -name '*.js' -o -name '*.svg' \) -exec gzip -vrk9 {} \;
# Copy the coverage artifacts
# For the dev build we do not generate a coverage report, fail without an error in that case
- cp -r htmlcov/ public/ || true
artifacts:
paths:
- public
only:
changes:
- docs/*
- docs/**/*
- examples/*
- examples/**/*
- eminus/version.py
refs:
- main
##### Build the documentation for the dev branch under a different URL #####
pages:dev:
extends: pages
dependencies:
after_script:
- echo "dev pages available at https://$CI_PROJECT_NAMESPACE.gitlab.io/-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/public/index.html"
only:
refs:
- dev
variables:
PUBLIC_URL: "/-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/public"