-
Notifications
You must be signed in to change notification settings - Fork 3
182 lines (151 loc) · 4.44 KB
/
ci_cd.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
name: Python CI/CD
on:
push:
pull_request:
release:
types:
- published
schedule:
# * is a special character in YAML so you have to quote this string
# Execute a "nightly" build at 2 AM UTC
- cron: '0 2 * * *'
jobs:
package:
name: Package the project
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Python tools
run: pip install build twine
- name: Create distributions
run: python -m build -o dist/
- name: Inspect dist folder
run: ls -lah dist/
- name: Check wheel's abi and platform tags
run: test $(find dist/ -name *-none-any.whl | wc -l) -gt 0
- name: Run twine check
run: twine check dist/*
- name: Check PEP440 compliance
run: |
pip install packaging setuptools_scm
python -c "import packaging.version as v; v.Version(\"$(python -m setuptools_scm)\")"
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
path: dist/*
name: dist
test:
name: 'Python${{ matrix.python }}@${{ matrix.type }}@${{ matrix.os }}'
needs: package
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -el {0}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- macos-latest
- windows-latest
type:
- apt
- conda
python:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
exclude:
- os: macos-latest
type: apt
- os: windows-latest
type: apt
steps:
- name: Set up Python
if: matrix.type == 'apt'
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- uses: conda-incubator/setup-miniconda@v2
if: matrix.type == 'conda'
with:
python-version: ${{ matrix.python }}
miniforge-variant: Mambaforge
miniforge-version: latest
channels: conda-forge
channel-priority: true
- name: Install system dependencies
if: matrix.type == 'apt'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends gazebo
# Remove following line as soon as iDynTree is available on Python 3.11:
pip install --pre idyntree
- name: Install conda dependencies
if: matrix.type == 'conda'
run: |
mamba install -y \
coloredlogs \
mashumaro \
numpy \
packaging \
scipy \
xmltodict \
black \
isort \
pptree \
idyntree \
pytest \
robot_descriptions
# pytest-icdiff \ # creates problems on macOS
mamba install -y gz-sim7 idyntree
- name: Download Python packages
uses: actions/download-artifact@v3
with:
path: dist
name: dist
- name: Install wheel (apt)
if: matrix.type == 'apt'
run: pip install "$(find dist/ -type f -name '*.whl')[all]"
- name: Install wheel (conda)
if: matrix.type == 'conda'
run: pip install --no-deps "$(find dist/ -type f -name '*.whl')[all]"
- name: Pip check
run: pip check
- name: Import the package
run: python -c "import rod"
- uses: actions/checkout@v3
if: matrix.os != 'windows-latest'
- name: Run tests
if: matrix.os != 'windows-latest'
run: pytest
publish:
name: Publish to PyPI
needs: test
if: github.event_name != 'schedule'
runs-on: ubuntu-22.04
steps:
- name: Download Python packages
uses: actions/download-artifact@v3
with:
path: dist
name: dist
- name: Inspect dist folder
run: ls -lah dist/
- name: Publish to PyPI
if: |
github.repository == 'ami-iit/rod' &&
((github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'release' && github.event.action == 'published'))
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
skip_existing: true