-
-
Notifications
You must be signed in to change notification settings - Fork 21
154 lines (134 loc) · 4.76 KB
/
tests.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Tests
on:
push:
branches: # ignore pushed tags
- "*"
paths-ignore:
- '**.md'
- '**.rst'
- 'translations/**'
pull_request:
paths-ignore:
- '**.md'
- '**.rst'
- 'translations/**'
permissions:
contents: read
pull-requests: read
jobs:
test:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
env:
PY_VERSION: 3.12
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: 'true'
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PY_VERSION }}
- name: Install calibre on Ubuntu
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt update
sudo apt install libegl1 libopengl0
sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sudo sh /dev/stdin
- name: Install calibre on macOS
if: matrix.os == 'macos-latest'
run: |
wget -nv -O calibre.dmg https://calibre-ebook.com/dist/osx
hdiutil attach -noverify -noautofsck calibre.dmg
cp -R /Volumes/calibre-*/calibre.app /Applications
hdiutil detach /Volumes/calibre-*
rm calibre.dmg
echo /Applications/calibre.app/Contents/MacOS >> $GITHUB_PATH
- name: Install calibre and wget on Windows
if: matrix.os == 'windows-latest'
shell: cmd
run: |
choco install wget
wget -nv -O calibre.msi https://calibre-ebook.com/dist/win64
start /wait msiexec.exe /i calibre.msi /quiet
del calibre.msi
- name: Add calibre directory to Windows PATH
if: matrix.os == 'windows-latest'
run: echo "/C/Program Files/Calibre2" >> $GITHUB_PATH
- name: Install KFX Input plugin
run: |
wget -nv -O KFX_Input.zip https://plugins.calibre-ebook.com/291290.zip
calibre-customize -a KFX_Input.zip
rm KFX_Input.zip
- name: Download books
run: |
wget -nv https://github.com/xxyzz/WordDumb/files/10715466/books.zip
unzip books.zip
- name: Add books to library
run: |
mkdir ~/Calibre\ Library
calibredb add -m ignore --with-library ~/Calibre\ Library *.kfx *.azw3 *.epub
rm *.kfx *.azw3 *.epub books.zip
- name: Compile translation file
run: calibre-debug -c "from calibre.translations.msgfmt import main; main()" translations/*.po
- name: Build plugin(Unix)
if: matrix.os != 'windows-latest'
run: zip -r worddumb-${{ github.sha }}.zip * [email protected]
- name: Build plugin(Windows)
if: matrix.os == 'windows-latest'
run: 7z a [email protected] -x!.* -tzip worddumb-${{ github.sha }}.zip
- name: Add plugin
run: |
calibre-customize -a worddumb-${{ github.sha }}.zip
rm worddumb-${{ github.sha }}.zip
- name: Restore dependencies and Wikipedia cache(Ubuntu)
if: matrix.os == 'ubuntu-latest'
uses: actions/cache@v3
with:
path: |
~/.config/calibre/plugins/worddumb-libs-py*
~/.config/calibre/plugins/worddumb-wikimedia
key: ${{ runner.os }}-${{ hashFiles('data/deps.json') }}-${{ env.PY_VERSION }}
- name: Restore dependencies and Wikipedia cache(macOS)
if: matrix.os == 'macos-latest'
uses: actions/cache@v3
with:
path: |
~/Library/Preferences/calibre/plugins/worddumb-libs-py*
~/Library/Preferences/calibre/plugins/worddumb-wikimedia
key: ${{ runner.os }}-${{ hashFiles('data/deps.json') }}-${{ env.PY_VERSION }}
- name: Restore dependencies and Wikipedia cache(Windows)
if: matrix.os == 'windows-latest'
uses: actions/cache@v3
with:
path: |
~/AppData/Roaming/calibre/plugins/worddumb-libs-py*
~/AppData/Roaming/calibre/plugins/worddumb-wikimedia
key: ${{ runner.os }}-${{ hashFiles('data/deps.json') }}-${{ env.PY_VERSION }}
- name: Run test
run: cd tests && calibre-debug test.py
env:
PYTHONOPTIMIZE: 1
PYTHONWARNINGS: default
CALIBRE_SHOW_DEPRECATION_WARNINGS: 1
- name: Upload plugin
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
# Don't upload the zip file directly cuz GitHub will zip it again
name: worddumb-${{ github.sha }}
path: |
.
!.*
!docs/*
!tests/*
!**/__pycache__/*
!__pycache__/*
!exclude.lst
!translations/*.po
!pyproject.toml