name: Tests Base on: workflow_call: inputs: fake-success: required: false type: boolean default: false python-version: required: false type: string default: '3.12' node-version: required: false type: number default: 20 parallel-runs: required: false type: number default: 2 build-assets: required: false type: boolean default: true enable-postgres: required: false type: boolean default: false enable-coverage: required: false type: boolean default: false enable-watch: required: false type: boolean default: false enable-schedule: required: false type: boolean default: false disable-socketio: required: false type: boolean default: false disable-redis-socketio: required: false type: boolean default: false 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: needs: unit-test name: Gen Integration Test Matrix runs-on: ubuntu-latest outputs: indices: ${{ steps.set-indices.outputs.indices }} steps: - id: set-indices run: | indices=$(seq -s ',' 1 ${{ inputs.parallel-runs }}); echo "indices=[${indices}]" >> $GITHUB_OUTPUT # This satisfies the required checks on pull requests if tests are intentionally skipped integration-test-fake: needs: gen-idx-integration name: Integration runs-on: ubuntu-latest if: ${{ inputs.fake-success != false }} strategy: matrix: db: ${{ fromJson(inputs.enable-postgres && '["mariadb", "postgres"]' || '["mariadb"]') }} index: ${{ fromJson(needs.gen-idx-integration.outputs.indices) }} steps: - name: Pass skipped tests unconditionally run: "echo Skipped" integration-test: needs: gen-idx-integration name: Integration runs-on: ubuntu-latest if: ${{ inputs.fake-success == false }} timeout-minutes: 30 env: NODE_ENV: "production" PYTHONOPTIMIZE: 2 # noisy 3rd party library warnings PYTHONWARNINGS: "module,ignore:::babel.messages.extract" DB_ROOT_PASSWORD: db_root COVERAGE_RCFILE: ~/frappe-bench/apps/frappe/.coveragerc strategy: fail-fast: false matrix: db: ${{ fromJson(inputs.enable-postgres && '["mariadb", "postgres"]' || '["mariadb"]') }} index: ${{ fromJson(needs.gen-idx-integration.outputs.indices) }} services: mariadb: image: mariadb:11.3 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 }} postgres: image: postgres:12.4 options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 ports: - 5432:5432 env: POSTGRES_PASSWORD: ${{ env.DB_ROOT_PASSWORD }} smtp_server: image: rnwood/smtp4dev ports: - 2525:25 - 3000:80 steps: - uses: frappe/frappe/.github/actions/setup@develop name: Environment Setup with: python-version: '3.12' node-version: 20 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: | cd ~/frappe-bench || exit bench --site test_site \ run-parallel-tests \ --app "${{ github.event.repository.name }}" \ --total-builds ${{ inputs.parallel-runs }} \ --build-number ${{ matrix.index }} 2> >(tee -a stderr.log >&2) # Process warnings and create annotations if [ -s stderr.log ] && [ "$DB" == "mariadb" ]; then echo "Processing deprecation warnings..." grep -E "DeprecationWarning" stderr.log | sort -u | while read -r warning; do # Extract file path, line number, and warning type file_info=$(echo "$warning" | grep -oP '^.*?:\d+:') file_path=$(echo "$file_info" | cut -d':' -f1) line_number=$(echo "$file_info" | cut -d':' -f2) warning_type=$(echo "$warning" | grep -oP '\w+Warning') # Extract the actual warning message message=$(echo "$warning" | sed -E "s/^.*$warning_type: //") # Create the annotation echo "::warning file=${file_path},line=${line_number}::${warning_type}: ${message}" done else echo "No deprecation warnings found." fi env: DB: ${{ matrix.db }} # consumed by bench run-parallel-tests CAPTURE_COVERAGE: ${{ inputs.enable-coverage }} - name: Upload coverage data uses: actions/upload-artifact@v3 if: inputs.enable-coverage with: name: coverage-${{ matrix.db }}-${{ matrix.index }} path: ~/frappe-bench/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: | cd ~/frappe-bench || exit cat bench_start.log || true cd logs for f in ./*.log*; do echo "Printing log: $f"; cat $f done