name: Audiobook Library CI permissions: contents: read on: push: branches: - dev - main paths: - "audiobook_library/**" - "serverlibrary/**" - "testassets/audiobook_library/**" - ".gitea/workflows/audiobook_library.yaml" pull_request: branches: - dev paths: - "audiobook_library/**" - "serverlibrary/**" - "testassets/audiobook_library/**" - ".gitea/workflows/audiobook_library.yaml" jobs: test: runs-on: ubuntu-latest container: image: nikolaik/python-nodejs:python3.12-nodejs20 env: AUDIOBOOK_TEST_ASSETS: ../testassets/audiobook_library AUDIOBOOK_TEST_DATABASE: test/ci-assets/absdatabase.sqlite_test steps: - name: Check out the tested commit uses: actions/checkout@v4 - name: Install FFmpeg run: | apt-get update apt-get install --yes --no-install-recommends ffmpeg - name: Install audiobook_library working-directory: audiobook_library run: | python -m pip install --upgrade pip python -m pip install ../serverlibrary . - name: Generate database fixture working-directory: audiobook_library run: python test/create_ci_fixtures.py test/ci-assets - name: Run tests working-directory: audiobook_library run: python run_tests.py lint: runs-on: ubuntu-latest container: image: nikolaik/python-nodejs:python3.12-nodejs20 steps: - name: Check out the tested commit uses: actions/checkout@v4 - name: Install Ruff run: python -m pip install ruff - name: Lint audiobook_library run: ruff check audiobook_library/src audiobook_library/test audiobook_library/main.py audiobook_library/run_tests.py build: if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} needs: [test, lint] runs-on: ubuntu-latest container: image: nikolaik/python-nodejs:python3.12-nodejs20 steps: - name: Check out the tested commit uses: actions/checkout@v4 - name: Install build dependencies working-directory: audiobook_library run: | python -m pip install --upgrade pip python -m pip install ../serverlibrary . python -m pip install pyinstaller - name: Build one-file executable working-directory: audiobook_library run: python -m PyInstaller --clean --noconfirm --onefile --paths src --name audiobook_library main.py - name: Verify executable working-directory: audiobook_library run: | test -x dist/audiobook_library dist/audiobook_library --help - name: Upload executable uses: https://github.com/christopherHX/gitea-upload-artifact@v4 with: name: audiobook-library-build path: audiobook_library/dist/audiobook_library if-no-files-found: error install: if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} needs: build strategy: fail-fast: false matrix: runner: - vivohost - quiethost - serverhost runs-on: ${{ matrix.runner }} steps: - name: Download executable uses: https://github.com/christopherHX/gitea-download-artifact@v4 with: name: audiobook-library-build path: dist/ - name: Install audiobook_library shell: bash run: | set -euo pipefail install -d -m 755 "$HOME/tools" install -m 755 dist/audiobook_library "$HOME/tools/audiobook_library"