-
Notifications
You must be signed in to change notification settings - Fork 3
213 lines (204 loc) · 6.96 KB
/
ci.yaml
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
name: Run CI Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
precommit:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Python 3
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Run pre-commit
run: |
./install-pre-commit.sh
pre-commit run --all
- name: generate docs
run: |
./generate_docs.sh
if [ -n "$(git status docs --porcelain)" ];then
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "GitHub Actions [Bot]"
set -x
branch=${{ github.head_ref }}
new_branch=${branch}_update_docs_$(date +%s)
git checkout -b $new_branch
git add docs
git commit -m "Update docs [Created by Github action]"
git push origin $new_branch
gh pr create --base $branch --head $new_branch --title "Update docs [Created by Github action]" --body "" \
--assignee ${{ github.actor }}
echo Docs are not up to date. Pull Request was created.
exit 1
else
echo Docs are up to date.
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run-tf-tests:
needs: [precommit]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# NOTE if newer versions are added, update sony_custom_layers.__init__ pinned_requirements!!!
py_ver: ["3.8", "3.9", "3.10", "3.11"]
tf_ver: ["2.10", "2.11", "2.12", "2.13", "2.14", "2.15"]
exclude:
- py_ver: "3.11"
tf_ver: "2.10"
- py_ver: "3.11"
tf_ver: "2.11"
- py_ver: "3.8"
tf_ver: "2.14"
- py_ver: "3.8"
tf_ver: "2.15"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Python 3
uses: actions/setup-python@v5
with:
python-version: ${{matrix.py_ver}}
- name: Install dependencies
run: |
if [ ${{matrix.tf_ver}} == 2.10 ] || [ ${{matrix.tf_ver}} == 2.11 ];then
extra_req='numpy<2'
fi
pip install tensorflow==${{matrix.tf_ver}}.* $extra_req
pip install -r requirements_test.txt
pip list
- name: Run pytest
run: |
pytest sony_custom_layers/keras
run-torch-tests:
needs: [precommit]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Test selected versions combinations as following:
# * latest/earliest torch+torchvision X latest/earliest ort X latest/earliest ort-ext X latest/earliest onnx
# * each remaining version is covered by at least one test
# !!!NOTE!!! if newer versions are added, update sony_custom_layers.__init__ pinned_requirements
py_ver: [ "3.8", "3.9", "3.10", "3.11" ]
torch_ver: ["2.0", "2.1", "2.2", "2.3", "2.4"]
ort_ver: ["1.15", "1.19"]
ort_ext_ver: ["0.8", "0.12"]
onnx_ver: ["1.14", "1.16"]
exclude:
- py_ver: "3.11" # incompatible versions
ort_ext_ver: "0.8"
include:
# torchvision ver is coupled to a specific torch ver
- torch_ver: "2.4"
torchvision_ver: "0.19"
- torch_ver: "2.3"
torchvision_ver: "0.18"
- torch_ver: "2.2"
torchvision_ver: "0.17"
- torch_ver: "2.1"
torchvision_ver: "0.16"
- torch_ver: "2.0"
torchvision_ver: "0.15"
# non-covered versions (ort, ort-ext, onnx)
- py_ver: "3.11"
torch_ver: "2.4"
torchvision_ver: "0.19"
ort_ver: "1.16"
ort_ext_ver: "0.9"
onnx_ver: "1.15"
- py_ver: "3.11"
torch_ver: "2.3"
torchvision_ver: "0.18"
ort_ver: "1.17"
ort_ext_ver: "0.10"
onnx_ver: "1.14"
- py_ver: "3.11"
torch_ver: "2.2"
torchvision_ver: "0.17"
ort_ver: "1.18"
ort_ext_ver: "0.11"
onnx_ver: "1.16"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Python 3
uses: actions/setup-python@v5
with:
python-version: ${{matrix.py_ver}}
- name: Install dependencies
run: |
pip install torch==${{matrix.torch_ver}}.* \
torchvision==${{matrix.torchvision_ver}}.* --index-url https://download.pytorch.org/whl/cpu
pip install onnxruntime==${{matrix.ort_ver}}.* \
onnxruntime_extensions==${{matrix.ort_ext_ver}}.* \
onnx==${{matrix.onnx_ver}}.* \
-r ./requirements_test.txt
pip check
pip list
- name: Run pytest
run: |
pytest sony_custom_layers/pytorch
build:
needs: [run-tf-tests, run-torch-tests]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Python 3
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: get new dev tag
shell: bash
run : |
pip install packaging
git fetch --tags
latest_tag=$(git describe --tags --abbrev=0)
latest_tag_without_v=${latest_tag#v}
new_version=$(python -c "
from packaging.version import parse
v = parse('$latest_tag_without_v')
if v.is_devrelease:
print(f'{v.major}.{v.minor}.{v.micro}.dev{v.dev + 1}')
else:
print(f'{v.major}.{v.minor+1}.0.dev0')
")
echo "new_ver=${new_version}" >> $GITHUB_ENV
echo "new_tag=v${new_version}" >> $GITHUB_ENV
echo "cat GITHUB_ENV"
cat $GITHUB_ENV
- name: update name and version to dev
shell: bash
run: |
echo "__version__ = '${{ env.new_ver }}'" > sony_custom_layers/version.py
echo "print sony_custom_layers/version.py"
cat sony_custom_layers/version.py
sed -i 's/name = sony-custom-layers/name = sony-custom-layers-dev/' setup.cfg
echo "print setup.cfg"
cat setup.cfg
- name: Build wheel
run: |
pip install build
python -m build --wheel
- name: Publish package pypi
shell: bash
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: |
pip install twine
twine upload --repository pypi dist/* -u __token__ -p ${{ secrets.PYPI_API_KEY }}
git tag ${{ env.new_tag }}
git push origin ${{ env.new_tag }}