-
Notifications
You must be signed in to change notification settings - Fork 51
201 lines (190 loc) · 7.16 KB
/
main.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
name: ci
on:
push:
tags:
- "*"
branches:
- master
- development
pull_request:
jobs:
read-project-info:
runs-on: ubuntu-20.04
outputs:
platform_dependent_packages: ${{ steps.set-platform-dependent-packages.outputs.platform_dependent_packages }}
platform_independent_packages: ${{ steps.set-platform-independent-packages.outputs.platform_independent_packages }}
all_packages: ${{ steps.set-all-packages.outputs.all_packages }}
tests_dir: ${{ steps.set-tests-dir.outputs.tests_dir }}
examples_dir: ${{ steps.set-examples-dir.outputs.examples_dir }}
examples: ${{ steps.set-examples.outputs.examples }}
revolve2_namespace: ${{ steps.set-revolve2-namespace.outputs.revolve2_namespace }}
steps:
- uses: actions/checkout@v4
- id: set-platform-dependent-packages
run: echo platform_dependent_packages=$(python3 -c "import yaml;print(yaml.safe_load(open('project.yml'))['platform_dependent_packages'])") >> $GITHUB_OUTPUT
- id: set-platform-independent-packages
run: echo platform_independent_packages=$(python3 -c "import yaml;print(yaml.safe_load(open('project.yml'))['platform_independent_packages'])") >> $GITHUB_OUTPUT
- id: set-all-packages
run: echo all_packages=$(python3 -c "import yaml;print(yaml.safe_load(open('project.yml'))['platform_dependent_packages'] + yaml.safe_load(open('project.yml'))['platform_independent_packages'])") >> $GITHUB_OUTPUT
- id: set-tests-dir
run: echo tests_dir=$(python3 -c "import yaml;print(yaml.safe_load(open('project.yml'))['tests-dir'])") >> $GITHUB_OUTPUT
- id: set-examples-dir
run: echo examples_dir=$(python3 -c "import yaml;print(yaml.safe_load(open('project.yml'))['examples-dir'])") >> $GITHUB_OUTPUT
- id: set-examples
run: echo examples=$(python3 -c "import yaml;print(yaml.safe_load(open('project.yml'))['examples'])") >> $GITHUB_OUTPUT
- id: set-revolve2-namespace
run: echo revolve2_namespace=$(python3 -c "import yaml;print(yaml.safe_load(open('project.yml'))['revolve2-namespace'])") >> $GITHUB_OUTPUT
check_format:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
- name: install_tools
run: pip install -r ./codetools/requirements.txt
- name: black
run: ./codetools/black/check.sh
- name: isort
run: ./codetools/isort/check.sh
- name: pydocstyle
run: ./codetools/pydocstyle/check.sh
- name: darglint
run: ./codetools/darglint/check.sh
- name: pyflakes
run: ./codetools/pyflakes/check.sh
- name: sort-all
run: |
./codetools/sort_all/fix.sh
[[ -z $(git status -s) ]]
git checkout -- .
mypy-examples:
needs: read-project-info
strategy:
matrix:
example: ${{ fromJson(needs.read-project-info.outputs.examples) }}
uses: ./.github/workflows/mypy.yml
with:
directory: ./${{ needs.read-project-info.outputs.examples_dir }}/${{ matrix.example }}
mypy-tests:
needs: read-project-info
uses: ./.github/workflows/mypy.yml
with:
directory: ./${{ needs.read-project-info.outputs.tests_dir }}
mypy-packages:
needs: read-project-info
strategy:
matrix:
package: ${{ fromJson(needs.read-project-info.outputs.all_packages) }}
uses: ./.github/workflows/mypy.yml
with:
directory: ./${{ matrix.package }}/${{ needs.read-project-info.outputs.revolve2_namespace }}
docs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
python-version: 3.11
- name: install_revolve2
run: pip install -r ./requirements_dev.txt
- name: setup_graphviz
uses: ts-graphviz/setup-graphviz@v2
- name: sphinx
run: make -C docs html
- name: deploy
if: ${{ github.ref == 'refs/heads/master' }}
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: docs/build/html
clean-exclude: .nojekyll
unit_tests:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [ "3.10", "3.11" ]
steps:
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
- name: install virtual display
run: |
bash .github/workflows/install_display.sh
echo "DISPLAY=:0" >> $GITHUB_ENV
- name: install_revolve2
run: pip install -r ./requirements_dev.txt
- name: run pytest
run: pytest -v
build_wheels_platform_independent:
needs: read-project-info
runs-on: ubuntu-22.04
strategy:
matrix:
package: ${{ fromJson(needs.read-project-info.outputs.platform_independent_packages) }}
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- uses: actions/[email protected]
with:
python-version: 3.11
- name: Build wheels
run: pip wheel --no-deps ./${{ matrix.package }} -w ./dist/${{ matrix.package }}
- uses: actions/upload-artifact@v3
with:
name: dist
path: ./dist/**/*.whl
build_wheels_platform_dependent:
needs: read-project-info
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2022, ubuntu-22.04, macos-12]
package: ${{ fromJson(needs.read-project-info.outputs.platform_dependent_packages) }}
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- uses: actions/[email protected]
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.16.2
- name: Build wheels
run: python -m cibuildwheel ./${{ matrix.package }} --output-dir ./dist/${{ matrix.package }}
env:
CIBW_BUILD: cp310-* cp311-*
CIBW_ARCHS_WINDOWS: AMD64
CIBW_ARCHS_MACOS: universal2
CIBW_ARCHS_LINUX: x86_64
- uses: actions/upload-artifact@v3
with:
name: dist
path: ./dist/**/*.whl
publish:
runs-on: ubuntu-22.04
if: startsWith(github.ref, 'refs/tags/')
needs: [read-project-info, build_wheels_platform_independent, build_wheels_platform_dependent]
strategy:
matrix:
package: ${{ fromJson(needs.read-project-info.outputs.all_packages) }}
environment:
name: publish
permissions:
id-token: write
steps:
- name: Download dist artifact
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- name: Generate name for package
# Prepend 'revolve2-', replace '/' with '-' and remove '/simulators'
run: echo "PACKAGE_URL=https://pypi.org/p/revolve2-$(echo ${{ matrix.package }} | sed 's/_/-/g' | sed 's/simulators\///g')" >> $GITHUB_ENV
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/${{ matrix.package }}