python-build.yml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 - Unit Test
  21. run: |
  22. pytest .
  23. - name: Test - Translate a PDF file with plain text only
  24. run:
  25. pdf2zh ./test/file/translate.cli.plain.text.pdf -o ./test/file
  26. - name: Test - Translate a PDF file figure
  27. run:
  28. pdf2zh ./test/file/translate.cli.text.with.figure.pdf -o ./test/file
  29. # - name: Test - Translate a PDF file with unknown font
  30. # run:
  31. # pdf2zh ./test/file/translate.cli.font.unknown.pdf
  32. - name: Test - Start GUI and exit
  33. run:
  34. timeout 10 pdf2zh -i || code=$?; if [[ $code -ne 124 && $code -ne 0 ]]; then exit $code; fi
  35. - name: Build as a package
  36. run: python -m build
  37. - name: Upload test results
  38. uses: actions/upload-artifact@v4
  39. with:
  40. name: test-results
  41. path: ./test/file/