Version 3.3.2 #810
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", "windows" ] | |
pull_request: | |
branches: [ "develop", "master" ] | |
permissions: | |
contents: read | |
jobs: | |
# Run 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@v4 | |
with: | |
submodules: true | |
- 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 | |
- name: Test | |
run: | | |
set -e | |
# Have to explicitly set MECAB_PATH for natto-py. | |
export MECAB_PATH=/lib/x86_64-linux-gnu/libmecab.so.2 | |
pytest | |
- name: Acceptance testing | |
run: | | |
set -e | |
# Have to explicitly set MECAB_PATH for natto-py. | |
export MECAB_PATH=/lib/x86_64-linux-gnu/libmecab.so.2 | |
inv accept --show --verbose | |
# 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 | |
set -e | |
inv playwright | |
- 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 -s -k disabled_data_is_hidden | |
- 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. | |
code-quality: | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
strategy: | |
matrix: | |
python_version: [ '3.11' ] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python_version }} | |
cache: 'pip' # caching pip dependencies | |
- run: pip install -r requirements.txt | |
- name: Lint | |
run: inv lint | |
- name: Coding style | |
run: | | |
black --check . | |
# 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@v4 | |
with: | |
submodules: true | |
- 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 | |
# 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@v4 | |
with: | |
submodules: true | |
- 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 | |
# Can't get playwright to run reliably on Windows. | |
# - name: Playwright install | |
# run: playwright install | |
# - name: Playwright smoke test | |
# run: inv playwright || exit /b | |
# Run specific sanity check. | |
# Old tests no longer run -- datatables may have timing issues on Windows tests, | |
# tests were far too flaky. | |
# inv accept -s -k test_unsupported_language_not_shown || exit /b | |
# inv accept -s -k import_a_valid_term_file || exit /b | |
- name: Smoke tests | |
run: | | |
inv accept -s -k test_updating_term_status_updates_the_reading_frame || exit /b | |
- 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 |