-
Notifications
You must be signed in to change notification settings - Fork 39
192 lines (181 loc) · 7 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
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
name: CI
on:
release:
types: [published]
push:
pull_request:
jobs:
rust:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/cargo@v1
with:
command: build
args: --verbose --all-features --release -p nlprule
- run: rustup component add clippy
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
- run: |
mkdir data
mkdir storage
cd data
wget https://f000.backblazeb2.com/file/nlprule/en.zip
unzip en.zip
wget https://f000.backblazeb2.com/file/nlprule/de.zip
unzip de.zip
- uses: actions-rs/cargo@v1
with:
command: run
# build english, see BUILD.md
args: --all-features --release --bin compile -- --tag-paths data/en/tags/output.dump data/en/tags/added.txt --tag-remove-paths data/en/tags/removed.txt --disambiguation-path data/en/disambiguation.canonic.xml --tokenizer-config-path configs/en/tokenizer.json --grammar-path data/en/grammar.canonic.xml --rules-config-path configs/en/rules.json --common-words-path data/en/common.txt --chunker-path data/en/chunker.json --out-tokenizer-path storage/en_tokenizer.bin --out-rules-path storage/en_rules.bin --regex-cache-path data/en/regex_cache.bin
- uses: actions-rs/cargo@v1
with:
command: run
# build german, see BUILD.md
args: --all-features --release --bin compile -- --tag-paths data/de/tags/output.dump data/de/tags/added.txt --tag-remove-paths data/de/tags/removed.txt --disambiguation-path data/de/disambiguation.canonic.xml --tokenizer-config-path configs/de/tokenizer.json --grammar-path data/de/grammar.canonic.xml --rules-config-path configs/de/rules.json --common-words-path data/de/common.txt --out-tokenizer-path storage/de_tokenizer.bin --out-rules-path storage/de_rules.bin --regex-cache-path data/de/regex_cache.bin
- uses: actions-rs/cargo@v1
with:
command: test
args: --verbose --all-features --release -p nlprule
- uses: actions-rs/cargo@v1
with:
command: run
args: --all-features --release --bin test_disambiguation -- --tokenizer storage/en_tokenizer.bin
- uses: actions-rs/cargo@v1
with:
command: run
args: --all-features --release --bin test -- --tokenizer storage/en_tokenizer.bin --rules storage/en_rules.bin
- uses: actions-rs/cargo@v1
with:
command: run
args: --all-features --release --bin test_disambiguation -- --tokenizer storage/de_tokenizer.bin
- uses: actions-rs/cargo@v1
with:
command: run
args: --all-features --release --bin test -- --tokenizer storage/de_tokenizer.bin --rules storage/de_rules.bin
- name: Upload binaries as artifact
uses: actions/upload-artifact@v2
with:
name: binaries
path: storage/*
matrix_prep:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
# Required as the JSON input file needs to be read
- uses: actions/checkout@v2
- id: set-matrix
uses: JoshuaTheMiller/[email protected]
with:
# inputFile: '.github/workflows/matrix_includes.json' # Default input file path
filter: '[?runOnEvent==`${{ github.event_name }}` || runOnEvent==`always`]'
python:
needs: [matrix_prep, rust]
strategy:
matrix: ${{fromJson(needs.matrix_prep.outputs.matrix)}}
runs-on: ${{ matrix.os }}
env:
working-directory: bindings/python
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@v2
with:
name: binaries
path: storage
- name: Install GSED (if needed) # needed by set_version.sh and maturin.sh
if: matrix.os == 'macos-latest'
run: |
brew install gnu-sed
- name: Update version (if release)
if: github.event_name == 'release'
run: |
bash scripts/set_version.sh ${{ github.event.release.tag_name }}
- name: Build
run: |
python -m pip install --upgrade pip
pip install maturin==0.8.3 pytest==6.1.2
bash scripts/maturin.sh build --interpreter python --release --manylinux 1
wheel=
pip install $(ls target/wheels/* | head -n1)
pytest bindings/python/test.py -s
shell: bash
- name: Upload wheel as artifact
uses: actions/upload-artifact@v2
with:
name: python-wheel
path: target/wheels/*
publish:
runs-on: ubuntu-latest
needs: [rust, python]
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- uses: actions/download-artifact@v2
with:
name: python-wheel
path: python-wheel
- uses: actions/download-artifact@v2
with:
name: binaries
path: storage
- run: |
gzip storage/en_tokenizer.bin
gzip storage/en_rules.bin
gzip storage/de_tokenizer.bin
gzip storage/de_rules.bin
- name: Update version
run: |
bash scripts/set_version.sh ${{ github.event.release.tag_name }}
- name: Publish on crates.io
run: | # --allow-dirty is only needed b/c of the README.md, we can be sure it is clean otherwise anyway because it is freshly checked out
cargo login $CARGO_KEY
cp README.md nlprule/README.md
cd nlprule
cargo publish --allow-dirty
rm README.md
env:
CARGO_KEY: ${{ secrets.CARGO_KEY }}
- name: Publish on PyPI
run: |
pip install twine==3.3
twine upload python-wheel/*
env:
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
- name: Upload release binaries
uses: alexellis/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
asset_paths: '["./storage/*"]'
- run: |
rm -r python-wheel
rm -r storage
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: v${{ github.event.release.tag_name }}
branch: master