From 157619fa3a3027ecf70b183b7308a12b0c1014e3 Mon Sep 17 00:00:00 2001 From: RuochenPan Date: Thu, 5 Nov 2026 16:46:37 +0800 Subject: [PATCH 1/2] chore(ci): run coverage in the unit test workflow Move coverage collection into the Ubuntu lane and remove the separate coverage workflow so the full suite runs once per change. --- .github/workflows/coverage_test.yml | 46 ----------------------------- .github/workflows/unit_tests.yml | 14 ++++++++- 2 files changed, 13 insertions(+), 47 deletions(-) delete mode 100644 .github/workflows/coverage_test.yml diff --git a/.github/workflows/coverage_test.yml b/.github/workflows/coverage_test.yml deleted file mode 100644 index 323283c10c2..00000000000 --- a/.github/workflows/coverage_test.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Run tests and upload coverage - -on: - push: - branches: - - master - paths-ignore: - - 'README.md' - - 'changelogs/**' - - 'dashboard/**' - pull_request: - workflow_dispatch: - -jobs: - test: - name: Run tests and collect coverage - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v7 - with: - fetch-depth: 0 - - - name: Set up Python - uses: actions/setup-python@v7 - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pytest pytest-asyncio pytest-cov - pip install --editable . - - - name: Run tests - run: | - mkdir -p data/plugins - mkdir -p data/config - mkdir -p data/temp - export TESTING=true - export ZHIPU_API_KEY=${{ secrets.OPENAI_API_KEY }} - pytest --cov=astrbot -v -o log_cli=true -o log_level=DEBUG - - - name: Upload results to Codecov - if: github.repository == 'AstrBotDevs/AstrBot' - uses: codecov/codecov-action@v7 - with: - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index ef221607276..41584ed561e 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -67,6 +67,18 @@ jobs: run: test -x /usr/bin/sandbox-exec - name: Run tests + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} run: | chmod +x scripts/run_pytests_ci.sh - bash ./scripts/run_pytests_ci.sh ./tests + if [ "${{ runner.os }}" = "Linux" ]; then + bash ./scripts/run_pytests_ci.sh ./tests --cov=astrbot --cov-report=xml + else + bash ./scripts/run_pytests_ci.sh ./tests + fi + + - name: Upload coverage + if: runner.os == 'Linux' && github.repository == 'AstrBotDevs/AstrBot' + uses: codecov/codecov-action@v7 + with: + token: ${{ secrets.CODECOV_TOKEN }} From e09aa1736d1cd63ad033a42cb54168d99f77eec5 Mon Sep 17 00:00:00 2001 From: RuochenPan Date: Thu, 5 Nov 2026 16:46:48 +0800 Subject: [PATCH 2/2] chore(ci): avoid duplicate install script test run Keep the bash syntax check in the install workflow; behavioral coverage comes from the full pytest suite, which already collects the file. --- .github/workflows/install_script_test.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/install_script_test.yml b/.github/workflows/install_script_test.yml index 37d9468992c..9b523118f02 100644 --- a/.github/workflows/install_script_test.yml +++ b/.github/workflows/install_script_test.yml @@ -47,8 +47,6 @@ jobs: - name: Checkout uses: actions/checkout@v7 - - name: Test Bash installer + - name: Check Bash installer syntax shell: bash - run: | - /bin/bash -n docs/public/install.sh - python3 tests/test_install_script.py + run: /bin/bash -n docs/public/install.sh