233 lines (218 loc) · 7.32 KB
/
python.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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# Infos on current github runners:
# https://docs.github.com/en/free-pro-team@latest/actions/reference/specifications-for-github-hosted-runners#about-github-hosted-runners
name: Build
on: [pull_request, push]
concurrency:
group: cicd-${{ github.ref }}
cancel-in-progress: true
jobs:
# Run tests on all pull requests or when triggered via [test] tag
test:
name: Run tests, build test packages & draft test release
runs-on: ${{ matrix.os }}
if: |
github.event_name == 'pull_request'
|| contains(github.event.head_commit.message, '[test]')
|| startsWith(github.ref, 'refs/tags/v')
strategy:
fail-fast: false
matrix:
os: [macos-11, windows-2019, ubuntu-22.04]
steps:
# SETUP ENVIRONMENT
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: abatilo/actions-poetry@v2.1.6
with:
poetry-version: "1.2.2"
- name: Prepare Linux
if: ${{ matrix.os == 'ubuntu-22.04' }}
run: |
sudo apt-get update
sudo apt-get install \
python3-pil \
tesseract-ocr \
tesseract-ocr-eng \
tesseract-ocr-jpn \
tesseract-ocr-chi-sim
sudo apt-get install \
xvfb \
libxkbcommon-x11-0 \
libxcb-icccm4 \
libxcb-image0 \
libxcb-keysyms1 \
libxcb-randr0 \
libxcb-render-util0 \
libxcb-xinerama0 \
libxcb-xfixes0 \
libxcb-shape0 \
libegl1 \
libegl1-mesa
echo "XDG_SESSION_TYPE=gnome" >> $GITHUB_ENV
- name: Prepare macOS
if: ${{ matrix.os == 'macos-11' }}
run: |
brew install pkg-config tesseract tesseract-lang dylibbundler
brew info tesseract
"/Library/Application Support/VMware Tools/vmware-resolutionSet" 1920 1080
- name: Prepare Windows
if: ${{ matrix.os == 'windows-2019' }}
run: |
$url = "https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-w64-setup-v5.0.1.20220118.exe"
Invoke-WebRequest -Uri $url -OutFile "tesseract_installer.exe"
7z x tesseract_installer.exe -O"C:\Program Files\Tesseract-OCR"
$tesseract = "C:\Program Files\Tesseract-OCR\"
echo "$tesseract" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "TESSDATA_PREFIX=$tesseract" >> $env:GITHUB_ENV
Set-DisplayResolution -Width 1920 -Height 1080 -Force
- name: Test tesseract
run: |
tesseract --version
tesseract --list-langs
- name: Poetry install
run: poetry install
# PERFORM TESTS
- name: Pylint
if: always()
run: poetry run pylint src/normcap src/tests/
- name: Mypy
if: always()
run: poetry run mypy .
- name: Black
if: always()
run: poetry run black --check --diff .
- name: Isort
if: always()
run: poetry run isort --check .
- name: Pydocstyle
if: always()
run: poetry run pydocstyle
- name: Safety
if: always()
run: poetry run safety check
- name: Bandit
if: always()
run: poetry run bandit --quiet --severity-level medium -r src/normcap
- name: Pytest
run: |
poetry run pytest -vv -m "not skip_on_gh" --cov --cov-report=xml
poetry run coverage lcov
- name: Coveralls Parallel
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: ${{ matrix.os }}
path-to-lcov: coverage.lcov
parallel: true
- name: SonarCloud
if:
${{ matrix.os == 'ubuntu-22.04' && github.repository
=='dynobo/normcap' }}
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# Build test packages
- name: Build test package briefcase
shell: bash -l {0}
run: poetry run python package/build.py --framework=briefcase --dev
- name: Build test package nuitka
continue-on-error: true
shell: bash -l {0}
run: poetry run python package/build.py --framework=nuitka --dev
- name: List files
shell: bash -l {0}
run: ls -la ./package
# Release test package
- name: Set current date as env variable
shell: bash -l {0}
run: echo "NOW=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV
- name: Draft internal release
uses: ncipollo/release-action@v1
if: ${{ github.repository == 'dynobo/normcap' }}
with:
name: Internal
body:
"Only for internal tests. Should not be published. [${{ env.NOW }}]"
artifacts: "*/*.+(dmg|AppImage|msi|zip)"
artifactErrorsFailBuild: false
allowUpdates: true
draft: true
prerelease: true
token: ${{ secrets.GITHUB_TOKEN }}
tag: "internal"
coveralls-upload:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
build-python:
name: Build Python package & publish release
needs: test
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: abatilo/actions-poetry@v2.1.6
with:
poetry-version: "1.2.2"
- name: Poetry publish
run: |
echo "skip"
# poetry publish --build --username __token__ --password ${{ secrets.PYPI_TOKEN }}
build-packages:
name: Build prebuild packages & draft release
needs: test
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-11, windows-2019]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: abatilo/actions-poetry@v2.1.6
with:
poetry-version: "1.2.2"
- name: Install dependencies
shell: bash -l {0}
run: poetry install
- name: Build package briefcase
shell: bash -l {0}
run: poetry run python package/build.py --framework=briefcase
- name: Draft release
uses: ncipollo/release-action@v1
with:
body:
See
[CHANGELOG](https://github.com/dynobo/normcap/blob/main/CHANGELOG.md)
for details.
artifacts: "*/*.+(dmg|AppImage|msi|zip)"
artifactErrorsFailBuild: false
allowUpdates: true
draft: true
token: ${{ secrets.GITHUB_TOKEN }}
deploy-pages:
name: Deploy github pages
needs: build-packages
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Deploy pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs