[KNW-225] Do not report media sync errors caused by stale DB entries #6885
This file contains hidden or 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 | |
| env: | |
| COMPOSE_DOCKER_CLI_BUILD: 1 | |
| WEBAPP_COMPOSE_FILE: ${{ github.workspace }}/ankihub_web/compose.yml | |
| AWS_REGION: us-east-1 | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| QTWEBENGINE_CHROMIUM_FLAGS: --no-sandbox | |
| DISABLE_QT5_COMPAT: 1 | |
| DEPLOYMENT_ENVIRONMENT: local | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| pull_request: | |
| jobs: | |
| test-addon: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: | |
| - aqt_dependency_group: aqt | |
| qt_package: pyqt6 | |
| python_version: 3.13.5 | |
| - aqt_dependency_group: aqt_legacy | |
| qt_package: pyqt5 | |
| python_version: 3.9 | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout ankihub_addon | |
| uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python_version }} | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: lts/* | |
| - name: Setup addon | |
| uses: ./.github/actions/setup-addon | |
| with: | |
| google_api_key: ${{ secrets.GOOGLE_API_KEY }} | |
| ankihub_ssh_key: ${{ secrets.ANKIHUB_SSH_PRIVATE_KEY }} | |
| install_qt: true | |
| aqt_dependency_group: ${{ matrix.aqt_dependency_group }} | |
| qt_package: ${{ matrix.qt_package }} | |
| # Only this lane has an Anki-on-3.9 environment. Its own process, because under pytest the | |
| # bundle is shadowed by the development environment - see scripts/check_addon_import.py. | |
| - name: Check the built add-on imports inside Anki on Python 3.9 | |
| if: ${{ matrix.python_version == '3.9' }} | |
| run: | | |
| xvfb-run -a uv run --exact --group ${{ matrix.aqt_dependency_group }} --python ${{ matrix.python_version }} python scripts/check_addon_import.py | |
| - name: Run pytest with coverage | |
| run: | | |
| xvfb-run uv run --exact --group ${{ matrix.aqt_dependency_group }} --python ${{ matrix.python_version }} pytest ./tests/addon -n 0 -m sequential --cov --cov-report=xml | |
| xvfb-run uv run --exact --group ${{ matrix.aqt_dependency_group }} --python ${{ matrix.python_version }} pytest ./tests/addon -n 4 -m "not sequential and not performance" --cov --cov-report=xml --cov-append | |
| xvfb-run uv run --exact --group ${{ matrix.aqt_dependency_group }} --python ${{ matrix.python_version }} pytest ./tests/addon -n 0 -m performance --cov-report=xml --cov-append | |
| - name: Upload coverage | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage_addon_${{ matrix.aqt_dependency_group }} | |
| path: .coverage | |
| include-hidden-files: true | |
| test-client: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| group: [1, 2] | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout ankihub_addon | |
| uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: ".python-version" | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: lts/* | |
| - name: Setup addon | |
| uses: ./.github/actions/setup-addon | |
| with: | |
| google_api_key: ${{ secrets.GOOGLE_API_KEY }} | |
| ankihub_ssh_key: ${{ secrets.ANKIHUB_SSH_PRIVATE_KEY }} | |
| install_qt: true | |
| aqt_dependency_group: aqt | |
| qt_package: pyqt6 | |
| - name: Enable cloning webapp repo | |
| uses: webfactory/ssh-agent@v0.5.4 | |
| with: | |
| ssh-private-key: ${{ secrets.ANKIHUB_SSH_PRIVATE_KEY }} | |
| - name: Checkout AnkiHubSoftware/ankihub web app repo | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: AnkiHubSoftware/ankihub | |
| ref: dev | |
| path: ankihub_web | |
| - name: Set up AnkiHub env | |
| run: | | |
| mv ${{ github.workspace }}/ankihub_web/.env.dev ${{ github.workspace }}/ankihub_web/.env | |
| - uses: taiki-e/install-action@just | |
| - name: Setup AnkiHub | |
| working-directory: ${{ github.workspace }}/ankihub_web | |
| run: | | |
| just pull-all-images | |
| docker compose run --rm django bash release.sh | |
| just up | |
| - name: Run pytest with coverage | |
| run: | | |
| uv run --exact --group aqt pytest ./tests/client --disable-vcr --cov --cov-report=xml \ | |
| --splits 2 --group ${{ matrix.group }} --durations-path=tests/.test_durations | |
| - name: Upload coverage | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage_client_${{ matrix.group }} | |
| path: .coverage | |
| include-hidden-files: true | |
| coverage-and-static-checks: | |
| needs: ["test-addon", "test-client"] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout ankihub_addon | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: ".python-version" | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: lts/* | |
| - name: Setup addon | |
| uses: ./.github/actions/setup-addon | |
| with: | |
| google_api_key: ${{ secrets.GOOGLE_API_KEY }} | |
| ankihub_ssh_key: ${{ secrets.ANKIHUB_SSH_PRIVATE_KEY }} | |
| install_qt: false | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| - name: Run coverage | |
| run: | | |
| uv run coverage combine coverage_*/.coverage | |
| uv run coverage html --fail-under=76 | |
| - name: Upload coverage report with smokeshow | |
| run: uv run --with smokeshow -- smokeshow upload coverage_html_report | |
| if: always() | |
| env: | |
| SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Add-on Test Coverage {coverage-percentage} | |
| SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 66 | |
| SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| - name: Upload coverage to Codecov | |
| if: always() | |
| env: | |
| CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}" | |
| uses: codecov/codecov-action@v1 | |
| with: | |
| fail_ci_if_error: false | |
| - name: Install deps | |
| run: | | |
| uv sync --locked --dev --group aqt | |
| - name: Create ankiaddon file | |
| run: | | |
| bash ./scripts/release.sh | |
| env: | |
| GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }} | |
| - name: Archive .ankiaddon | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ankihub_addon_${{ github.sha }} | |
| path: ankihub.ankiaddon | |
| - name: Run pre-commit | |
| run: uv run pre-commit run --all | |
| - name: Run mypy | |
| run: uv run mypy |