forked from facebookresearch/nle
-
Notifications
You must be signed in to change notification settings - Fork 8
258 lines (256 loc) · 8.55 KB
/
test_and_deploy.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
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
---
name: Test & deploy
on:
push:
branches: [main]
pull_request:
release:
types: [prereleased, released]
jobs:
test_repo:
name: Test on ${{ matrix.os }} w/ Py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
os: [ubuntu-20.04, macos-latest]
fail-fast: false
steps:
- name: Setup Python ${{ matrix.python-version }} env
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Ensure latest pip, wheel & setuptools
run: python -m pip install -q --upgrade pip wheel setuptools
- name: Install dependencies
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get update && sudo apt-get install -yq \
apt-transport-https \
bison \
build-essential \
cmake \
flex \
libbz2-dev \
ninja-build \
software-properties-common
else
brew install cmake
fi
- uses: actions/checkout@v4
with:
submodules: true
- name: Install from repo in test mode
run: pip install -e '.[dev]'
- name: Run tests
run: python -m pytest --import-mode=append -svx nle/tests
test_sdist_3_8:
name: Test sdist on MacOS w/ Py3.8
needs: test_repo
runs-on: macos-latest
steps:
- name: Setup Python 3.8 env
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Ensure latest pip, wheel & setuptools
run: python -m pip install -q --upgrade pip wheel setuptools
- name: Install dependencies
run: |
brew install cmake
- uses: actions/checkout@v4
with:
submodules: true
- name: Generate sdist
run: |
NLE_RELEASE_BUILD=1 python setup.py sdist
- name: Install from sdist
run: |
SDISTNAME=$(ls dist/)
MODE="[all]"
pip install "dist/$SDISTNAME$MODE"
- name: Run tests outside repo dir
run: |
REPONAME=$(basename $PWD)
pushd ..
python -m pytest --import-mode=append -svx $REPONAME/nle/tests
popd
test_sdist_3_12:
name: Test sdist on MacOS w/ Py3.12
needs: test_repo
runs-on: macos-latest
steps:
- name: Setup Python 3.12 env
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Ensure latest pip, wheel & setuptools
run: python -m pip install -q --upgrade pip wheel setuptools
- name: Install dependencies
run: |
brew install cmake
- uses: actions/checkout@v4
with:
submodules: true
- name: Generate sdist
run: |
NLE_RELEASE_BUILD=1 python setup.py sdist
- name: Install from sdist
run: |
SDISTNAME=$(ls dist/)
MODE="[all]"
pip install "dist/$SDISTNAME$MODE"
- name: Run tests outside repo dir
run: |
REPONAME=$(basename $PWD)
pushd ..
python -m pytest --import-mode=append -svx $REPONAME/nle/tests
popd
- name: Save sdist
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: python-sdist
path: dist/
build_wheels:
name: Build wheels on Ubuntu
needs: test_repo
runs-on: ubuntu-20.04 # Can be also run for macOS
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up QEMU # Required for building manylinux aarch64 wheels on x86_64
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Build wheels
if: github.event_name != 'release'
uses: pypa/[email protected] # The main configuration is in pyproject.toml
env:
CIBW_BUILD: "cp312-manylinux*" # Build only python 3.12 wheels for testing
# Increase verbosity to see what's going on in the build in case of failure
CIBW_BUILD_VERBOSITY: 3
CIBW_REPAIR_WHEEL_COMMAND_LINUX: >
auditwheel show {wheel} && auditwheel repair -w {dest_dir} {wheel}
- name: Build release wheels
if: github.event_name == 'release' && (github.event.action == 'released' || github.event.action == 'prereleased')
uses: pypa/[email protected] # The main configuration is in pyproject.toml
env:
# Set NLE_RELEASE_BUILD to 1 to build release wheels
CIBW_ENVIRONMENT: "NLE_RELEASE_BUILD=1"
- name: Save wheels
uses: actions/upload-artifact@v4
with:
name: python-wheels
path: ./wheelhouse/*.whl
test_manylinux_3_12:
name: Test manylinux wheel on Ubuntu w/ Py3.12
needs: build_wheels
runs-on: ubuntu-20.04
steps:
- name: Setup Python 3.12 env
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Ensure latest pip, wheel & setuptools
run: python -m pip install -q --upgrade pip wheel tools
- uses: actions/checkout@v4
with:
submodules: true
- name: Get wheels artifacts
uses: actions/download-artifact@v4
with:
name: python-wheels
path: dist
- name: Install from wheel # Install wheel mathcing the Python version and architecture
run: |
WHEELNAME=$(ls dist/*312*manylinux*x86_64*.whl)
MODE="[all]"
pip install "$WHEELNAME$MODE"
- name: Run tests outside repo dir
run: |
REPONAME=$(basename $PWD)
pushd ..
python -m pytest --import-mode=append -svx $REPONAME/nle/tests
popd
# Use prereleases to test publish the artefacts to testpypi
test_deploy:
name: Deploy artefacts to testpypi
needs: [test_sdist_3_12, test_manylinux_3_12]
if: github.event_name == 'release' && github.event.action == 'prereleased'
runs-on: ubuntu-latest
environment:
name: prerelease
url: https://testpypi.org/p/nle
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Check version matches release tag
run: |
echo "v$(cat version.txt)"
echo "${{ github.event.release.tag_name }}"
[[ "${{ github.event.release.tag_name }}" == "v$(cat version.txt)" ]]
- name: Get sdist artifact # Get sdist artifact from the test_sdist job
uses: actions/download-artifact@v4
with:
name: python-sdist
path: dist
- name: Get wheels artifacts # Get wheels artifacts from the build_wheels job
uses: actions/download-artifact@v4
with:
name: python-wheels
path: dist
- name: Report dist contents
run: |
pwd
ls -R
ls -al .
ls -R dist/
ls -al dist/
- name: Publish package to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
# TODO move this to separate workflow whenever github decides to provide basic
# functionalities like workflow dependencies :|
deploy_sdist:
name: Deploy sdist to pypi
needs: [test_sdist_3_12, test_manylinux_3_12]
if: github.event_name == 'release' && github.event.action == 'released'
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/nle
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Check version matches release tag
run: |
echo "v$(cat version.txt)"
echo "${{ github.event.release.tag_name }}"
[[ "${{ github.event.release.tag_name }}" == "v$(cat version.txt)" ]]
- name: Get sdist artifact # Get sdist artifact from the test_sdist job
uses: actions/download-artifact@v4
with:
name: python-sdist
path: dist
- name: Get wheels artifacts # Get wheels artifacts from the build_wheels job
uses: actions/download-artifact@v4
with:
name: python-wheels
path: dist
- name: Report dist contents
run: |
pwd
ls -R
ls -al .
ls -R dist/
ls -al dist/
# NOTE: we assume that dist/ contains a built sdist and wheels (and only that).
# Yes, we could be more defensively, but What Could Go Wrong?™
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1