python-build.yml 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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@v5
  12. with:
  13. python-version: '3.11' # avoid bugs in new versions
  14. cache: 'pip'
  15. cache-dependency-path: pyproject.toml
  16. - name: Install dependencies
  17. run: |
  18. pip3 install -U pip
  19. pip3 install -e .[dev]
  20. - name: Test - Code format
  21. run: |
  22. black --check --diff --color pdf2zh/*.py test/*.py
  23. flake8 --ignore E203,E261,E501,W503,E741
  24. - name: Test - Unit Test
  25. run: |
  26. pytest .
  27. - name: Test - Translate a PDF file with plain text only
  28. run:
  29. pdf2zh ./test/file/translate.cli.plain.text.pdf
  30. - name: Test - Translate a PDF file figure
  31. run:
  32. pdf2zh ./test/file/translate.cli.text.with.figure.pdf
  33. # - name: Test - Translate a PDF file with unknown font
  34. # run:
  35. # pdf2zh ./test/file/translate.cli.font.unknown.pdf
  36. - name: Test - Start GUI and exit
  37. run:
  38. timeout 10 pdf2zh -i || code=$?; if [[ $code -ne 124 && $code -ne 0 ]]; then exit $code; fi
  39. - name: Build as a package
  40. run: python -m build