forked from prommis/prommis
-
Notifications
You must be signed in to change notification settings - Fork 0
221 lines (186 loc) · 5.93 KB
/
Copy pathpublish.yml
File metadata and controls
221 lines (186 loc) · 5.93 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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
name: Create and Publish prommis PyPI package
on:
push:
tags:
- "*"
defaults:
run:
shell: bash -l {0}
env:
PYTEST_ADDOPTS: --color=yes
PIP_PROGRESS_BAR: "off"
PYTHON_VERSION: "3.12"
PACKAGE_NAME: "prommis"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code to be packaged
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Generate dist files
run: |
pip install build wheel
python -m build
- name: Check that the dist directory's size is below PyPI's maximum
run: |
ls -lh dist/*
_maxsize=100000 # 100 MB
_dirsize=$(du -s dist/ | cut -f 1) ; echo $_dirsize
echo "::notice title=dist::Total size of dist/ directory is $_dirsize kB"
[ "$_dirsize" -lt "$_maxsize" ]
- name: Upload dist files as artifact
uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
retention-days: 1
test-whl:
needs: [build]
name: Test prommis from .whl file
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install from .whl file
run: |
ls -lh dist/
whl_file="$(ls dist/*.whl)"
echo "$whl_file"
pip install "${whl_file}[testing]"
- name: Check that installed package has the expected tag
run: |
pip install packaging
python -c '
import sys
from importlib.metadata import version
from packaging.version import Version
name = sys.argv[1]
tag = sys.argv[2]
normalized_tag = str(Version(tag))
pkg_version = version(name)
print(f"{name=}\n{tag=}\n{normalized_tag=}\n{pkg_version=}")
assert pkg_version == normalized_tag
' "${{ env.PACKAGE_NAME }}" "${{ github.ref_name }}"
- name: Install OS deps for ipopt
run: |
sudo apt-get update
sudo apt-get install -y liblapack3 libblas3 libgfortran5
- name: Run tests
working-directory: /tmp
run: |
idaes get-extensions --extra petsc --verbose
pip install pytest
pytest --pyargs prommis -x -vv
upload-test-pypi:
needs: [test-whl]
runs-on: ubuntu-latest
permissions:
id-token: write
environment: test-release
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist
- name: Upload dist files to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
install-test-pypi:
runs-on: ubuntu-latest
needs: [upload-test-pypi]
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install prommis==${{ github.ref_name }} from TestPyPI
env:
_wait_time_s: 15
_pip_install_flags: --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/
_pip_install_target: prommis[watertap,ui]==${{ github.ref_name }}
run: |
until pip install $_pip_install_flags "$_pip_install_target"
do
echo "pip install failed; waiting $_wait_time_s seconds"
sleep "$_wait_time_s"
done
- name: Install OS deps for ipopt
run: |
sudo apt-get update
sudo apt-get install -y liblapack3 libblas3 libgfortran5
- name: Run tests
run: |
idaes get-extensions --extra petsc --verbose
pip install pytest
pytest --pyargs prommis
upload-pypi:
needs: [install-test-pypi]
runs-on: ubuntu-latest
permissions:
id-token: write
environment: release
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist
- name: Upload dist files to PyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b
env-snapshot:
name: Create and collect env snapshot
needs: [upload-pypi]
runs-on: ubuntu-latest
permissions:
contents: write
env:
ENV_NAME: prommis-${{ github.ref_name }}
OUTPUT_DIR: prommis-${{ github.ref_name }}
steps:
- name: Set up Conda environment with Python
uses: conda-incubator/setup-miniconda@v4
with:
miniforge-version: latest
activate-environment: ${{ env.ENV_NAME }}
python-version: ${{ env.PYTHON_VERSION }}
- name: Install prommis==${{ github.ref_name }}[watertap,ui] from PyPI
run: |
pip install "prommis[watertap,ui]==${{ github.ref_name }}"
- name: Create output directory
run: mkdir "$OUTPUT_DIR"
- name: Save environment info (requirements.txt)
working-directory: ${{ env.OUTPUT_DIR }}
run: |
pip freeze > requirements.txt
cat requirements.txt
- name: Save environment info (environment.yml)
working-directory: ${{ env.OUTPUT_DIR }}
run: |
conda env export \
-n "$ENV_NAME" \
--no-builds \
-f environment.yml
cat environment.yml
- name: Save as workflow artifact
uses: actions/upload-artifact@v7
with:
name: ${{ env.ENV_NAME }}
path: ${{ env.OUTPUT_DIR }}/
if-no-files-found: error
retention-days: 90
- name: Upload to GitHub Release
uses: softprops/action-gh-release@v3
with:
files: |
${{ env.OUTPUT_DIR }}/requirements.txt
${{ env.OUTPUT_DIR }}/environment.yml