-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
203 lines (192 loc) · 6.74 KB
/
.gitlab-ci.yml
File metadata and controls
203 lines (192 loc) · 6.74 KB
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
197
198
199
200
201
202
203
# stages:
# - base
# - deploy
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_PIPELINE_SOURCE == "push"
- if: $CI_PIPELINE_SOURCE == "web"
# Python version lists for test jobs (update these when adding/removing versions)
.default_python: &default_python ["3.14"]
.other_pythons: &other_pythons ["3.11", "3.12", "3.13"]
variables:
# Tools = {
# sphinx (publish docs on Gitlab Pages),
# twine (publish package on PyPI)
# } (all running on linux)
PYTHON_VERSION_FOR_TOOLS: "3.13"
SCIP_LINUX: "scipoptsuite_10.0.0-1+trixie_amd64.deb"
SCIP_WINDOWS: "scipoptsuite-10.0.0-win-x64"
# ===== Base templates =====
.test_linux_base:
# stage: base
image: python:${PYTHON_VERSION}
tags: [linux]
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
before_script:
- export DEBIAN_FRONTEND=noninteractive
- echo 'deb http://debian.lth.se/debian testing main contrib' | tee /etc/apt/sources.list.d/debian-testing.list
- |
printf 'Package: *\nPin: release a=testing\nPin-Priority: 100\n' | tee /etc/apt/preferences.d/99-testing-low-priority
- apt-get update
- apt-get install -yq coinor-cbc
- apt install -yq -t testing scip
# >>> scip/fscip section begin
# - test -f "downloads/$SCIP_LINUX" || wget --no-verbose -P downloads "https://www.scipopt.org/download/release/$SCIP_LINUX"
# - apt-get install -yq "./downloads/$SCIP_LINUX"
# <<< scip/fscip section end
- python3 -m venv tests/venv
- source tests/venv/bin/activate
- pip install --progress-bar off -e .[test]
- python3 --version
script:
- pytest --numprocesses auto --cov-report term-missing:skip-covered --cov=optiwindnet --cov-config .coveragerc
cache:
key: CI_JOB_NAME
paths:
- downloads
.test_windows_base:
# stage: base
image: registry.windenergy.dtu.dk/dockerimages/windows-miniconda:ltsc2019
tags: [docker-windows]
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
before_script:
# The next 3 lines install the Miniforge3 conda
# - Invoke-WebRequest -UserAgent curl https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Windows-x86_64.exe -OutFile Miniforge3-Windows-x86_64.exe
# - Start-Process -Wait -FilePath Miniforge3-Windows-x86_64.exe -ArgumentList "/InstallationType=JustMe","/RegisterPython=0","/S","/D=$($env:UserProfile)\condaforge"
# - . "$($env:UserProfile)\condaforge\shell\condabin\conda-hook.ps1"
- (conda shell.powershell hook) | Out-String | ?{$_} | Invoke-Expression
- conda config --add channels conda-forge
- conda config --set channel_priority strict
- conda create -y -q --name own_test python=${PYTHON_VERSION}
- conda activate own_test
# the packages beyond the solvers are dependencies that would be pulled later via pip install
- conda install -y -q coin-or-cbc numba networkx shapely scipy pyyaml bitarray pandas pillow
# >>> scip/fscip section begin
- if (!(Test-Path "downloads\$env:SCIP_WINDOWS.zip")) { New-Item -Force -Name "downloads" -ItemType "Directory" | Out-Null; Invoke-WebRequest -UserAgent curl https://www.scipopt.org/download/release/$env:SCIP_WINDOWS.zip -OutFile "downloads\$env:SCIP_WINDOWS.zip" }
- Expand-Archive -Path "downloads\$env:SCIP_WINDOWS.zip" -DestinationPath .
- $env:Path = "$env:Path;$env:SCIP_WINDOWS\bin\"
# <<< scip/fscip section end
- pip install --progress-bar off -e .[test]
- python --version
script:
- pytest --numprocesses auto --cov-report term-missing:skip-covered --cov=optiwindnet --cov-config .coveragerc
cache:
key: CI_JOB_NAME
paths:
- downloads
# ===== Test OptiWindNet on Linux =====
test_linux:
extends: .test_linux_base
parallel:
matrix:
- PYTHON_VERSION: *default_python
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_BRANCH || $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
compare_to: refs/heads/main
paths:
- pyproject.toml
- optiwindnet/**/*
- tests/**/*
# ===== Test OptiWindNet on Windows =====
test_windows:
extends: .test_windows_base
parallel:
matrix:
- PYTHON_VERSION: *default_python
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: never
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
compare_to: refs/heads/main
paths:
- pyproject.toml
- optiwindnet/**/*
- tests/**/*
- if: $CI_COMMIT_BRANCH
changes:
compare_to: refs/heads/main
paths:
- pyproject.toml
- optiwindnet/**/*
- tests/**/*
when: manual
allow_failure: true
# ===== Manual multi-version test matrix =====
test_matrix_linux:
extends: .test_linux_base
allow_failure: true
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: never
- if: $CI_COMMIT_BRANCH || $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
compare_to: refs/heads/main
paths:
- pyproject.toml
- optiwindnet/**/*
- tests/**/*
when: manual
parallel:
matrix:
- PYTHON_VERSION: *other_pythons
test_matrix_windows:
extends: .test_windows_base
allow_failure: true
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: never
- if: $CI_COMMIT_BRANCH || $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
compare_to: refs/heads/main
paths:
- pyproject.toml
- optiwindnet/**/*
- tests/**/*
when: manual
parallel:
matrix:
- PYTHON_VERSION: *other_pythons
# ===== Update GitLab Pages =====
make_pages:
# stage: base
image: python:$PYTHON_VERSION_FOR_TOOLS
tags: [linux]
pages: true
allow_failure: true
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes:
- docs/**/*
- optiwindnet/**/*.py
when: manual
script:
- apt-get update
- apt-get -yq install make pandoc graphviz
- pip install --progress-bar off .[docs] --upgrade
- make -C docs html
- mv docs/build/html public/
artifacts:
paths: [public]
# ===== Publish new version on PyPI =====
pypi_deploy:
# stage: deploy
image: python:$PYTHON_VERSION_FOR_TOOLS
tags: [linux]
rules:
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/
before_script:
- |
if ! git branch -a --contains "$CI_COMMIT_SHA" | grep -q "origin/$CI_DEFAULT_BRANCH"; then
echo "ERROR: Tag is not reachable from $CI_DEFAULT_BRANCH, aborting deploy"
exit 1
fi
script:
- pip install --progress-bar off --upgrade pip build twine packaging
- python3 -m build
- twine upload dist/* -u $TWINE_USERNAME -p $TWINE_PASSWORD