seitime-frappe/.github/workflows/_base-server-tests.yml
Ankush Menat 098a0851c6
ci: Fix coverage reporting (again) (#38849)
* chore: remove _decorate_all_methods_and_functions_with_type_checker

No one understands this runtime magic anymore.

* build: Bump coverage.py to latest

* test: Skip github in coverage reporting

* test: Print traceback from all threads when test is stuck

* ci: Enable coverage in server side tests

* ci: Always enable coverage

It's cheap in recent python versions, our reasons for selectively
disabling aren't valid anymore.

* ci: Disable stderr capturing

* ci: Use default buffer behaviour in unittest runner

* ci(coverage): Set concurrency to multiprocessing

We do use multiprocessing, perhaps the patches aren't concurrectly
handled?

* ci(coverage): Try parallel run

* fix: Apply subprocess patch

* ci: Don't start web server with coverage

Causes deadlock for some reason. We don't actually report it either.

* ci: only submit UI coverage if ran

* test: remove aggresive stuck test checking

* ci: disable UI coverage

(for now)
2026-04-24 16:05:14 +05:30

167 lines
4.9 KiB
YAML

name: Server Base
on:
workflow_call:
inputs:
fake-success:
required: false
type: boolean
default: false
python-version:
required: false
type: string
default: '3.14'
node-version:
required: false
type: number
default: 24
parallel-runs:
required: false
type: number
default: 2
enable-sqlite:
required: false
type: boolean
default: false
enable-postgres:
required: false
type: boolean
default: true
enable-coverage:
required: false
type: boolean
default: true
jobs:
unit-test:
name: Unit
runs-on: ubuntu-latest
steps:
- id: placeholder
run: |
echo "Evolution towards a set of (fast) unit tests which run without a DB connection is being planned"
gen-idx-integration:
name: Gen Integration Test Matrix
runs-on: ubuntu-latest
if: ${{ inputs.fake-success == false }}
outputs:
indices: ${{ steps.set-indices.outputs.indices }}
steps:
- id: set-indices
run: |
indices=$(seq -s ',' 1 ${{ inputs.parallel-runs }}); echo "indices=[${indices}]" >> $GITHUB_OUTPUT
integration-test:
needs: gen-idx-integration
name: Integration
runs-on: ubuntu-latest
if: ${{ inputs.fake-success == false }}
timeout-minutes: 30
env:
NODE_ENV: "production"
# noisy 3rd party library warnings
PYTHONWARNINGS: "module,ignore:::babel.messages.extract"
DB_ROOT_PASSWORD: db_root
strategy:
fail-fast: false
matrix:
db: ${{ fromJson(inputs.enable-sqlite && (inputs.enable-postgres && '["mariadb", "postgres", "sqlite"]' || '["mariadb", "sqlite"]') || (inputs.enable-postgres && '["mariadb", "postgres"]' || '["mariadb"]')) }}
index: ${{ fromJson(needs.gen-idx-integration.outputs.indices) }}
services:
postgres:
image: postgres:18.0
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: travis
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 3
mariadb:
image: mariadb:11.8
ports:
- 3306:3306
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=5s --health-timeout=2s --health-retries=3
env:
MARIADB_ROOT_PASSWORD: ${{ env.DB_ROOT_PASSWORD }}
smtp_server:
image: rnwood/smtp4dev:3.7.1
ports:
- 2525:25
- 3000:80
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup
name: Environment Setup
with:
python-version: ${{ inputs.python-version }}
node-version: ${{ inputs.node-version }}
disable-socketio: true
db-root-password: ${{ env.DB_ROOT_PASSWORD }}
db: ${{ matrix.db }}
env:
PYTHONWARNINGS: "ignore:Unimplemented abstract methods {'locate_file'}:DeprecationWarning"
- name: Run Tests
run: |
bench --site test_site \
run-parallel-tests \
--with-coverage \
--app "${{ github.event.repository.name }}" \
--total-builds ${{ inputs.parallel-runs }} \
--build-number ${{ matrix.index }}
env:
DB: ${{ matrix.db }}
# consumed by bench run-parallel-tests
CAPTURE_COVERAGE: ${{ inputs.enable-coverage }}
FRAPPE_SENTRY_DSN: ${{ secrets.SENTRY_DSN || '' }}
- name: Upload coverage data
uses: actions/upload-artifact@v7
if: inputs.enable-coverage
with:
name: coverage-${{ matrix.db }}-${{ matrix.index }}
path: ./sites/*coverage*.xml
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ failure() && contains( github.event.pull_request.labels.*.name, 'debug-gha') }}
- name: Show bench output
if: ${{ always() }}
run: |
cat bench_start.log || true
cd logs
for f in ${GITHUB_WORKSPACE}/*.log*; do
echo "Printing log: $f";
cat $f
done
# TIP: Use these for checks, e.g. Server / Tests / Success
success:
name: Success
needs: [unit-test, integration-test]
if: always()
runs-on: ubuntu-latest
steps:
- name: Unit '${{ needs.unit-test.result }}' / Integration '${{ needs.integration-test.result }}'
shell: python
run: |
stati = [
'${{ needs.unit-test.result }}',
'${{ needs.integration-test.result }}',
]
nopass = ["failure", "cancelled"]
dopass = ["success", "skipped"]
if any(r in nopass for r in stati):
exit(1)
if all(r in dopass for r in stati):
exit(0)
exit(1)