Merge pull request #242 from xxyzz/dependabot/github_actions/crate-ci… #845
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v5 | |
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 libxcb-cursor0 | |
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@v4 | |
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@v4 | |
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@v4 | |
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@v4 | |
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 | |
!__MACOSX |