-
Notifications
You must be signed in to change notification settings - Fork 70
140 lines (116 loc) · 3.67 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
name: CI
on:
push:
branches:
- master
tags:
- v*
pull_request:
branches:
- master
jobs:
build-and-test-cpp:
name: Build and test C++ library on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Build and install
if: startsWith(matrix.os, 'ubuntu')
run: |
cmake -DBUILD_TESTS=ON -DCMAKE_INSTALL_PREFIX=$PWD/install .
make install
- name: Build and install
if: startsWith(matrix.os, 'macos')
run: |
cmake -DBUILD_TESTS=ON -DCMAKE_INSTALL_PREFIX=$PWD/install -DICU_ROOT=/usr/local/opt/icu4c/ .
make install
- name: Test
run: |
test/onmt_tokenizer_test test/data
check-python-style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install black==22.* flake8==3.9.* isort==5.*
- name: Check code format with Black
working-directory: bindings/python
run: |
black --check .
- name: Check imports order with isort
working-directory: bindings/python
run: |
isort --check-only .
- name: Check code style with Flake8
working-directory: bindings/python
if: ${{ always() }}
run: |
flake8 .
build-and-test-python-wheels:
name: Build and test wheels on ${{ matrix.os }} for ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-11, windows-2019]
arch: [auto64]
include:
- os: ubuntu-20.04
arch: aarch64
- os: macos-11
arch: arm64
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: docker/setup-qemu-action@v2
if: ${{ matrix.arch == 'aarch64' }}
name: Set up QEMU
- name: Build wheels
uses: pypa/[email protected]
with:
package-dir: bindings/python
output-dir: wheelhouse
env:
CIBW_ENVIRONMENT_WINDOWS: TOKENIZER_ROOT='${{ github.workspace }}\install'
CIBW_BEFORE_ALL: bindings/python/tools/prepare_build_environment.sh
CIBW_BEFORE_ALL_WINDOWS: bash bindings/python/tools/prepare_build_environment_windows.sh
CIBW_BEFORE_BUILD: pip install pybind11==2.10.1
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
CIBW_TEST_COMMAND: pytest {project}/bindings/python/test/test.py
CIBW_TEST_REQUIRES: pytest
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_SKIP: pp* *-musllinux_*
CIBW_TEST_SKIP: "*-macosx_arm64"
- name: Upload Python wheels
uses: actions/upload-artifact@v3
with:
name: python-wheels
path: wheelhouse
publish-python-wheels-on-pypi:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [build-and-test-cpp, build-and-test-python-wheels]
runs-on: ubuntu-latest
steps:
- name: Download Python wheels
uses: actions/download-artifact@v3
with:
name: python-wheels
- name: Publish Python wheels to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: .