refactor(ocr): explain email regex #2486
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: | |
workflow_dispatch: | |
inputs: | |
refToBuild: | |
description: "Branch, tag or commit SHA1 to build" | |
required: true | |
type: string | |
concurrency: | |
group: cicd-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
# Run tests on all pull requests or when triggered via [test] tag | |
test: | |
name: Test & build | |
runs-on: ${{ matrix.os }} | |
if: | | |
github.event_name == 'pull_request' | |
|| contains(github.event.head_commit.message, '[test]') | |
|| startsWith(github.ref, 'refs/tags/v') | |
|| startsWith(github.ref, 'refs/heads/main') | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [macos-12, windows-2022, ubuntu-22.04] | |
steps: | |
# Setup environment | |
- uses: actions/checkout@v3 | |
if: ${{ github.event_name != 'workflow_dispatch' }} | |
- uses: actions/checkout@v3 | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
with: | |
ref: ${{ inputs.refToBuild }} | |
- name: Install poetry | |
run: pipx install poetry==1.4.2 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
cache: "poetry" | |
- 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 \ | |
libxcb-cursor0 \ | |
libegl1 \ | |
libegl1-mesa | |
sudo apt-get install \ | |
ca-certificates | |
echo "XDG_SESSION_TYPE=gnome" >> $GITHUB_ENV | |
echo "QT_DEBUG_PLUGINS=1" >> $GITHUB_ENV | |
echo "QT_QPA_PLATFORM=xcb" >> $GITHUB_ENV | |
- name: Prepare macOS | |
if: matrix.os == 'macos-12' | |
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-2022' | |
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: Ruff | |
if: always() | |
run: poetry run ruff . | |
- name: Mypy | |
if: always() | |
run: poetry run mypy | |
- name: Black | |
if: always() | |
run: poetry run black --check --diff . | |
- name: Pip-Audit | |
if: matrix.os == 'ubuntu-22.04' | |
run: | |
bash -c "poetry run pip-audit --strict -r <(poetry export -f requirements.txt | |
--with=dev)" | |
# - name: Setup upterm session | |
# if: matrix.os == 'ubuntu-22.04' | |
# uses: lhotari/action-upterm@v1 | |
# TODO: Fix pytest segfault on first run but passes on second run | |
# Probably caused by a leaky implementation of Qt. See: | |
# https://web.archive.org/web/20220619231122/http://enki-editor.org/2014/08/23/Pyqt_mem_mgmt.html | |
- name: Pytest | |
run: poetry run pytest -vv --cov --cov-report=xml | |
- name: Coverage | |
run: 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 | |
# Build test packages | |
- name: Test build briefcase package | |
shell: bash -l {0} | |
run: poetry run python bundle/build.py --framework=briefcase --dev | |
- name: Print briefcase log in case of error | |
if: failure() | |
shell: bash -l {0} | |
run: | | |
(cat logs/briefcase*) || true | |
find build/normcap || true | |
# Build | |
- name: Test build python package | |
run: poetry build | |
# 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-packages: | |
name: Build prebuilt 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-12, windows-2022] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install poetry | |
run: pipx install poetry==1.4.2 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
cache: "poetry" | |
- name: Install dependencies | |
shell: bash -l {0} | |
run: poetry install | |
- name: Build package briefcase | |
shell: bash -l {0} | |
run: poetry run python bundle/build.py --framework=briefcase | |
- name: Draft release | |
if: github.repository == 'dynobo/normcap' | |
uses: ncipollo/release-action@v1 | |
with: | |
body: | |
See [CHANGELOG](https://github.com/dynobo/normcap/blob/main/CHANGELOG) for | |
details. | |
artifacts: "*/*.+(dmg|AppImage|msi|zip)" | |
artifactErrorsFailBuild: false | |
allowUpdates: true | |
draft: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: FTP upload windows package | |
if: matrix.os == 'windows-2022' && github.repository == 'dynobo/normcap' | |
uses: SamKirkland/[email protected] | |
with: | |
server: ${{ secrets.WEBGO_FTP_HOST }} | |
username: ${{ secrets.WEBGO_FTP_USER }} | |
password: ${{ secrets.WEBGO_FTP_PASS }} | |
protocol: ftps | |
local-dir: ./bundle/ | |
exclude: | | |
**/platforms/** | |
**/imgs/** | |
**/*.py | |
**/*.wxs | |
**/*.wxs | |
**/metainfo | |
build-python: | |
name: Build Python package & publish release | |
needs: build-packages | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install poetry | |
run: pipx install poetry==1.4.2 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Poetry publish | |
run: | | |
poetry publish --build --username __token__ --password ${{ secrets.PYPI_TOKEN }} | |
deploy-pages: | |
name: Deploy github pages | |
needs: build-packages | |
if: startsWith(github.ref, 'refs/tags/v') && github.repository == 'dynobo/normcap' | |
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 |