-
Notifications
You must be signed in to change notification settings - Fork 390
134 lines (104 loc) · 3.65 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Run test when triggering the workflow on push and pull request,
# but only for the master branch
name: test
on:
push:
branches:
- master
pull_request:
branches:
- master
# -----------------------------------------------------------------------------------------------------
# To leverage the benefit of Github Action, the testing process is divided into three jobs:
# 1. pdf2docx: convert sample pdf to docx -> linux runner
# 2. docx2pdf: convert generated docx to pdf for comparing -> specific runner with MS Word installed
# 3. check_quality: convert page to image and compare similarity with python-opencv -> linux runner
# However, keep step 1 only, considering the difficulty to get a specific runner with MS Word installed.
# -----------------------------------------------------------------------------------------------------
jobs:
pdf2docx:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov
python setup.py develop
- name: Run unit test
run: |
pytest -v ./test/test.py::TestConversion --cov=./pdf2docx --cov-report=xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with: # Or as an environment variable
token: ${{ secrets.CODECOV_TOKEN }}
# upload docx for further job
- name: Archive package
uses: actions/upload-artifact@v2
with:
name: outputs
path: ./test/outputs
# docx2pdf:
# # a specific runner with MS Word installed
# runs-on: self-hosted
# needs: pdf2docx
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# # download artifacts from depending job
# - name: Download artifacts
# uses: actions/download-artifact@v2
# with:
# name: outputs
# path: test\outputs
# # convert docx to pdf with OfficeToPDF
# - name: Convert to PDF
# run: |
# cd test\outputs
# $files = Get-ChildItem "."
# for ($i=0; $i -lt $files.Count; $i++) {
# $name = $files[$i].name;
# echo "Converting $name to pdf...";
# OfficeToPDF $files[$i]
# }
# del *.docx
# # upload pdf for further job
# - name: Archive package
# uses: actions/upload-artifact@v2
# with:
# name: outputs
# path: test\outputs
# check_quality:
# runs-on: ubuntu-latest
# needs: docx2pdf
# steps:
# - name: Check out code
# uses: actions/checkout@v2
# # download artifacts from depending job
# - name: Download artifacts
# uses: actions/download-artifact@v2
# with:
# name: outputs
# path: ./test/outputs
# - name: Set up Python 3.x
# uses: actions/setup-python@v1
# with:
# python-version: '3.x'
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install -r requirements.txt
# pip install pytest
# python setup.py develop
# - name: Check converting quality
# run: |
# pytest -sv ./test/test.py::TestQuality