Move completed books checkmark on left, line up titles #306
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: ci | |
on: | |
push: | |
# A branch github-ci-updates can be created and used for ci | |
# experiments and tweaks. | |
branches: [ "develop", "master", "github-ci-updates" ] | |
pull_request: | |
branches: [ "develop", "master" ] | |
permissions: | |
contents: read | |
jobs: | |
# Lint, format check, and all tests. | |
base-ci: | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
strategy: | |
matrix: | |
python_version: [ '3.8', '3.9', '3.10', '3.11' ] | |
steps: | |
- name: Install Dependencies | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -y mecab mecab-ipadic-utf8 | |
# Helper checks to find the mecab library path, | |
# so it can be exported before running tests. | |
# Without the export, natto-py fails on github. | |
# echo FIND THE LIB: | |
# which mecab | |
# actual=`readlink -f /usr/bin/mecab` | |
# ldd $actual | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python_version }} | |
cache: 'pip' # caching pip dependencies | |
- run: pip install -r requirements.txt | |
- name: Setup config | |
run: | | |
mkdir ${{ github.workspace }}/data | |
echo "ENV: dev" > ${{ github.workspace }}/lute/config/config.yml | |
echo "DATAPATH: ${{ github.workspace }}/data" >> ${{ github.workspace }}/lute/config/config.yml | |
echo "DBNAME: test_lute.db" >> ${{ github.workspace }}/lute/config/config.yml | |
ls ${{ github.workspace }} | |
cat ${{ github.workspace }}/lute/config/config.yml | |
# Playwright tests were hanging far too often on github ci, | |
# but not consistently. No idea what was going wrong. | |
# TODO github ci: fix playwright hanging. | |
## - name: Playwright install | |
## run: playwright install | |
## - name: Playwright smoke test | |
## run: | | |
## set -x | |
## inv playwright | |
- name: Test | |
run: | | |
# Have to explicitly set MECAB_PATH for natto-py. | |
export MECAB_PATH=/lib/x86_64-linux-gnu/libmecab.so.2 | |
pytest | |
# Note that these seem to *pass* even if an acceptance | |
# test fails in GitHub actions ... which is annoying, | |
# because everything passes/fails correctly locally. | |
- name: Acceptance testing | |
run: | | |
export MECAB_PATH=/lib/x86_64-linux-gnu/libmecab.so.2 | |
inv accept --headless -s | |
# Code style etc checks after functionality verified. | |
- name: Lint | |
run: inv lint | |
- name: Coding style | |
run: | | |
black --check . | |
- name: Remove mecab for smoke test without mecab | |
run: | | |
sudo apt-get remove -y mecab mecab-ipadic-utf8 | |
# Run one particular sanity check. | |
# | |
# Note this isn't _completely_ valid because the test loads | |
# only supported language stories, whereas a prod release | |
# comes with _all_ stories pre-loaded and the invalid ones | |
# are deleted ... | |
- name: Smoke test no mecab | |
run: inv accept --headless -s -k test_unsupported_language_not_shown | |
- name: Check flit package | |
run: | | |
mkdir ${{ github.workspace }}/../lute_flit | |
cd ${{ github.workspace }}/../lute_flit | |
flit -f ${{ github.workspace }}/pyproject.toml install | |
python -m lute.main & # Start in background process | |
sleep 2 | |
# Verify with utils script back in the workspace | |
# (verify.py is not included in flit install) | |
pushd ${{ github.workspace }} | |
python -m utils.verify 5000 | |
popd | |
pkill -f "python -m lute.main" # Kill that process. | |
# Test build docker container and try running. | |
# Slightly wasteful re-setup of node. | |
docker-build: | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
needs: base-ci | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
cache: 'pip' # caching pip dependencies | |
- run: pip install -r requirements.txt | |
- name: Test docker build | |
run: | | |
docker build -f docker/Dockerfile --build-arg INSTALL_MECAB=false -t lute3 . | |
# Run container in the background, and check. | |
docker run -d -p 5000:5000 -v ./my_data:/lute_data -v ./my_backups:/lute_backup --name my-lute lute3:latest | |
sleep 10 # Give it a moment to start. | |
python -m utils.verify 5000 | |
docker stop my-lute | |
docker rm my-lute | |
# Generate a coverage badge, don't worry if it fails. | |
# Uses https://github.com/Schneegans/dynamic-badges-action to update a secret gist | |
# (ID a15001ec2ff889f7be0b553df9881566) and an API token, per notes at | |
# https://nedbatchelder.com/blog/202209/making_a_coverage_badge.html. | |
# Slightly wasteful in that it re-runs the tests, but it's fastest. | |
coverage: | |
needs: base-ci | |
continue-on-error: true | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- name: Install Dependencies | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -y mecab mecab-ipadic-utf8 | |
# Helper checks to find the mecab library path, | |
# so it can be exported before running tests. | |
# Without the export, natto-py fails on github. | |
# echo FIND THE LIB: | |
# which mecab | |
# actual=`readlink -f /usr/bin/mecab` | |
# ldd $actual | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.8' | |
cache: 'pip' # caching pip dependencies | |
- run: pip install -r requirements.txt | |
- name: Setup config | |
run: | | |
mkdir ${{ github.workspace }}/data | |
echo "ENV: dev" > ${{ github.workspace }}/lute/config/config.yml | |
echo "DATAPATH: ${{ github.workspace }}/data" >> ${{ github.workspace }}/lute/config/config.yml | |
echo "DBNAME: test_lute.db" >> ${{ github.workspace }}/lute/config/config.yml | |
ls ${{ github.workspace }} | |
cat ${{ github.workspace }}/lute/config/config.yml | |
- name: Generate coverage | |
run: | | |
# Have to explicitly set MECAB_PATH for natto-py. | |
export MECAB_PATH=/lib/x86_64-linux-gnu/libmecab.so.2 | |
coverage run -m pytest tests/ | |
coverage json --omit="tests/*" | |
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])") | |
echo "total=$TOTAL" >> $GITHUB_ENV | |
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY | |
- name: "Make badge" | |
uses: schneegans/[email protected] | |
with: | |
# GIST_TOKEN is a GitHub personal access token with scope "gist". | |
auth: ${{ secrets.GIST_TOKEN }} | |
gistID: a15001ec2ff889f7be0b553df9881566 | |
filename: covbadge.json | |
label: coverage | |
message: ${{ env.total }}% | |
valColorRange: ${{ env.total }} | |
minColorRange: 50 | |
maxColorRange: 80 | |
# Ensure that basic things work correctly on Windows, | |
# particularly PlatformDirs package. | |
windows-ci: | |
runs-on: windows-latest | |
timeout-minutes: 30 | |
strategy: | |
matrix: | |
python_version: [ '3.8', '3.9', '3.10', '3.11' ] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python_version }} | |
cache: 'pip' # caching pip dependencies | |
- name: Setup config | |
run: | | |
mkdir ${{ github.workspace }}\data | |
echo ENV: dev > ${{ github.workspace }}\lute\config\config.yml | |
echo DATAPATH: ${{ github.workspace }}\data >> ${{ github.workspace }}\lute\config\config.yml | |
echo DBNAME: test_lute.db >> ${{ github.workspace }}\lute\config\config.yml | |
shell: cmd | |
- name: Replace config slashes. | |
run: | | |
$content = [System.IO.File]::ReadAllText("${{ github.workspace }}\lute\config\config.yml").Replace('\','/') | |
[System.IO.File]::WriteAllText("${{ github.workspace }}\lute\config\config.yml", $content) | |
Get-Content -Path "${{ github.workspace }}\lute\config\config.yml" | |
- run: pip install -r requirements.txt | |
# Run one particular sanity check. | |
- name: Smoke test no mecab | |
run: inv accept --headless -s -k test_unsupported_language_not_shown | |
- name: Remove config to force using prod config | |
run: del ${{ github.workspace }}\lute\config\config.yml | |
shell: cmd | |
- name: Install prod-like flit package | |
run: | | |
mkdir ${{ github.workspace }}\..\lute_flit | |
cd ${{ github.workspace }}\..\lute_flit | |
flit -f ${{ github.workspace }}\pyproject.toml install | |
shell: cmd | |
- name: Run Lute application | |
run: | | |
echo "python -m lute.main" > run-server.bat | |
cmd /c "START /b run-server.bat" | |
- name: Wait for application to start | |
run: Start-Sleep -Seconds 10 | |
- name: Verify flit install | |
run: | | |
cd ${{ github.workspace }} | |
python -m utils.verify 5000 |