python-build.yml 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. name: Test and Build Python Package
  2. on:
  3. push:
  4. pull_request:
  5. jobs:
  6. build:
  7. runs-on: ubuntu-latest
  8. steps:
  9. - uses: actions/checkout@v4
  10. - name: Set up Python
  11. uses: actions/setup-python@v3
  12. with:
  13. python-version: '3.x'
  14. - name: Install dependencies
  15. run: |
  16. pip3 install -U pip
  17. pip3 install -e .[dev]
  18. - name: Test - Code format
  19. run: |
  20. black --check --diff --color pdf2zh/*.py test/*.py
  21. flake8 --ignore E203,E261,E501,W503,E741
  22. - name: Test - Unit Test
  23. run: |
  24. pytest .
  25. - name: Test - Translate a PDF file with plain text only
  26. run:
  27. pdf2zh ./test/file/translate.cli.plain.text.pdf
  28. - name: Test - Translate a PDF file figure
  29. run:
  30. pdf2zh ./test/file/translate.cli.text.with.figure.pdf
  31. # - name: Test - Translate a PDF file with unknown font
  32. # run:
  33. # pdf2zh ./test/file/translate.cli.font.unknown.pdf
  34. - name: Test - Start GUI and exit
  35. run:
  36. timeout 10 pdf2zh -i || code=$?; if [[ $code -ne 124 && $code -ne 0 ]]; then exit $code; fi
  37. - name: Build as a package
  38. run: python -m build