This repository has been archived by the owner on May 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 113
144 lines (139 loc) · 4.16 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
---
name: Test & deploy
on:
push:
branches:
- main
pull_request:
schedule:
- cron: "0 6,18 * * *"
release:
types: [released]
jobs:
test_repo:
name: Test on ${{ matrix.os }} w/ Py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9"]
os: [ubuntu-20.04, macos-latest]
fail-fast: false
steps:
- name: Setup Python ${{ matrix.python-version }} env
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Ensure latest pip & wheel
run: "python -m pip install -q --upgrade pip wheel"
- 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@v2
with:
submodules: true
- name: Install from repo in test mode
run: "pip install -e '.[dev]'"
- name: Run tests
run: "python -m pytest -svx nle/tests --basetemp=nle_test_data"
- name: Compress test output dir
if: ${{ always() }}
run: |
tar -zcvf nle_test_ci_${{ github.sha }}.tar.gz nle_test_data
- name: Save test results
if: ${{ always() }}
uses: actions/upload-artifact@v1
with:
name: nle_test_data_${{ matrix.python-version }}
path: nle_test_ci_${{ github.sha }}.tar.gz
test_sdist:
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@v2
with:
python-version: 3.8
- name: Ensure latest pip & wheel
run: "python -m pip install -q --upgrade pip wheel"
- name: Install dependencies
run: |
brew install cmake
- uses: actions/checkout@v2
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 -svx $REPONAME/nle/tests --basetemp=$REPONAME/nle_test_data
popd
- name: Compress test output dir
if: ${{ always() }}
run: |
tar -zcvf nle_test_ci_${{ github.sha }}.tar.gz nle_test_data
- name: Save test results
if: ${{ always() }}
uses: actions/upload-artifact@v1
with:
name: nle_test_data_sdist
path: nle_test_ci_${{ github.sha }}.tar.gz
- name: Save sdist
if: ${{ always() }}
uses: actions/upload-artifact@v1
with:
name: nle_dist
path: dist/
# 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
if: github.event_name == 'release' && github.event.action == 'released'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- 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 dist artifacts from test_sdist
uses: actions/download-artifact@v2
with:
name: nle_dist
path: dist
- name: Install from sdist
run: |
pwd
ls -R
ls -al .
ls -R dist/
ls -al dist/
# NOTE: we assume that dist/ contains a built sdist (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@master
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}