-
Notifications
You must be signed in to change notification settings - Fork 1
163 lines (138 loc) · 4.18 KB
/
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
name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- develop
release:
types:
- published
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
FORCE_COLOR: 3
jobs:
pre-commit:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- uses: pre-commit/[email protected]
with:
extra_args: --hook-stage manual --all-files
checks:
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 15
needs: [pre-commit]
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.11"]
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install poke-env
run: cd poke-env && python -m pip install . && cd ..
## copied from poke-env's CI (thank you!) ##
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Checkout PS
uses: actions/checkout@v3
with:
repository: smogon/pokemon-showdown
path: pokemon-showdown
submodules: recursive
- name: Get last showdown commit hash
id: showdown-hash
run: |
cd pokemon-showdown/
export hash=`git log -1 --pretty=format:%H`
echo "hash=$hash" >> $GITHUB_OUTPUT
- name: Restore server cache
uses: actions/cache@v3
with:
path: pokemon-showdown/node_modules
key:
showdown-python${{ matrix.python-version }}-${{
steps.showdown-hash.outputs.hash }}
restore-keys: showdown-python${{ matrix.python-version }}-
- name: Install PS dependencies & setup config
run: |
cd pokemon-showdown
npm install
cp config/config-example.js config/config.js
sed -i 's/backdoor = true/backdoor = false/g' config/config.js
sed -i 's/simulatorprocesses = 1/simulatorprocesses = 2/g' config/config.js
sed -i 's/.workers = 1 = 1/.workers = 2/g' config/config.js
- name: Start PS
run:
cd pokemon-showdown;node pokemon-showdown start --no-security
--max-old-space-size=3000 &
- name: Wait for server to be up
run: |
until $(curl --output /dev/null --silent --head --fail http://localhost:8000); do
sleep .01
done
sleep 1
## end of poke-env's CI copy ##
- name: Install package
run: python -m pip install .[test]
- name: Test package
run: >-
python -m pytest -ra --cov --cov-report=xml --cov-report=term
--durations=20
- name: Upload coverage report
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
dist:
needs: [pre-commit]
name: Distribution build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build sdist and wheel
run: pipx run build
- uses: actions/upload-artifact@v3
with:
path: dist
- name: Check products
run: pipx run twine check dist/*
publish:
needs: [dist]
name: Publish to PyPI
environment: pypi
permissions:
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'release' && github.event.action == 'published'
with:
# Remember to tell (test-)pypi about this repo before publishing
# Remove this line to publish to PyPI
repository-url: https://test.pypi.org/legacy/