[BUILD-964] fix: Handle read timeout by showing message (#1068) #4984
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 | |
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 | |
on: | |
push: | |
branches: | |
- "main" | |
pull_request: | |
jobs: | |
test-addon: | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
include: | |
- replace_anki_version: false | |
- replace_anki_version: true | |
anki_package_version: 'aqt[qt5]==2.1.56' | |
timeout-minutes: 30 | |
steps: | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
- name: Checkout ankihub_addon | |
uses: actions/checkout@v3 | |
- name: Setup addon | |
uses: ./.github/actions/setup-addon | |
with: | |
google_api_key: ${{ secrets.GOOGLE_API_KEY }} | |
install_qt: true | |
- name: Replace Anki version | |
if: ${{ matrix.replace_anki_version }} | |
run: pip install "${{ matrix.anki_package_version }}" | |
- name: Run pytest with coverage | |
run: | | |
pytest ./tests/addon -n 0 -m sequential --cov --cov-report=xml --retries 2 | |
pytest ./tests/addon -n 4 -m "not sequential and not performance" --cov --cov-report=xml --cov-append --retries 2 | |
pytest ./tests/addon -n 0 -m performance --cov-report=xml --cov-append --retries 2 | |
- name: Upload coverage | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage_addon_${{ matrix.anki_package_version }} | |
path: .coverage | |
include-hidden-files: true | |
test-client: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
group: [1, 2] | |
timeout-minutes: 30 | |
steps: | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
- name: Checkout ankihub_addon | |
uses: actions/checkout@v3 | |
- name: Setup addon | |
uses: ./.github/actions/setup-addon | |
with: | |
google_api_key: ${{ secrets.GOOGLE_API_KEY }} | |
install_qt: false | |
- name: Enable cloning web app repo | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.ANKIHUB_SSH_PRIVATE_KEY }} | |
- name: Checkout ankipalace/ankihub web app repo | |
uses: actions/checkout@v3 | |
with: | |
repository: ankipalace/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: | | |
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: | |
- uses: actions/checkout@v2 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.9" | |
- name: Setup addon | |
uses: ./.github/actions/setup-addon | |
with: | |
google_api_key: ${{ secrets.GOOGLE_API_KEY }} | |
install_qt: false | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
- name: Run coverage | |
run: | | |
coverage combine coverage_*/.coverage | |
coverage html --fail-under=76 | |
- name: Install smokeshow | |
run: | | |
python -m pip install smokeshow | |
- name: Upload coverage report with smokeshow | |
run: 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: 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: pre-commit run --all | |
- name: Run mypy | |
run: mypy |