python-build.yml 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. name: Test and Build Python Package
  2. on:
  3. push:
  4. branches:
  5. - main
  6. pull_request:
  7. jobs:
  8. build:
  9. runs-on: ubuntu-latest
  10. steps:
  11. - uses: actions/checkout@v4
  12. - name: Set up Python
  13. uses: actions/setup-python@v3
  14. with:
  15. python-version: '3.x'
  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
  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