mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-04 02:04:37 +00:00
The MariaDB job is named 'Python Unit Tests', and 'Python Unit Tests (1..4)' are the required status checks on develop. Naming the Postgres matrix job the same made its checks report under those required contexts, effectively gating every (labelled) PR on Postgres. Rename it to 'Postgres Unit Tests' so its contexts are distinct and the workflow stays non-required until we deliberately add it to branch protection.
198 lines
5.8 KiB
YAML
198 lines
5.8 KiB
YAML
name: Server (Postgres)
|
|
|
|
on:
|
|
repository_dispatch:
|
|
types: [frappe-framework-change]
|
|
pull_request:
|
|
# 'labeled' is required so adding the 'postgres' label to an open PR triggers this run
|
|
# (the job itself is gated on that label below)
|
|
types: [opened, reopened, synchronize, labeled]
|
|
paths-ignore:
|
|
- '**.js'
|
|
- '**.css'
|
|
- '**.svg'
|
|
- '**.md'
|
|
- '**.html'
|
|
- 'crowdin.yml'
|
|
- '.coderabbit.yml'
|
|
- '.mergify.yml'
|
|
schedule:
|
|
# Run everday at midnight UTC / 5:30 IST
|
|
- cron: "0 0 * * *"
|
|
workflow_dispatch:
|
|
inputs:
|
|
user:
|
|
description: 'Frappe Framework repository user (add your username for forks)'
|
|
required: true
|
|
default: 'frappe'
|
|
type: string
|
|
branch:
|
|
description: 'Frappe Framework branch'
|
|
default: 'develop'
|
|
required: false
|
|
type: string
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: server-postgres-develop-${{ github.event_name }}-${{ github.event.number || github.event_name == 'workflow_dispatch' && github.run_id || '' }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
test:
|
|
# Opt-in on PRs: only runs when the PR carries the 'postgres' label. Scheduled / manual /
|
|
# framework-dispatch runs always execute (no PR labels to gate on).
|
|
if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'postgres') }}
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 60
|
|
env:
|
|
TZ: 'Asia/Kolkata'
|
|
NODE_ENV: "production"
|
|
WITH_COVERAGE: ${{ github.event_name != 'pull_request' }}
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
container: [1, 2, 3, 4]
|
|
|
|
# Distinct from the MariaDB job's "Python Unit Tests" so its check contexts do NOT collide with
|
|
# the required "Python Unit Tests (1..4)" status checks -- this keeps Postgres non-required for now.
|
|
name: Postgres Unit Tests
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:13.3
|
|
env:
|
|
POSTGRES_PASSWORD: travis
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
|
|
steps:
|
|
- name: Clone
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '3.14'
|
|
|
|
- name: Check for valid Python & Merge Conflicts
|
|
run: |
|
|
python -m compileall -fq "${GITHUB_WORKSPACE}"
|
|
if grep -lr --exclude-dir=node_modules "^<<<<<<< " "${GITHUB_WORKSPACE}"
|
|
then echo "Found merge conflicts"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: 24
|
|
check-latest: true
|
|
|
|
- name: Add to Hosts
|
|
run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts
|
|
|
|
- name: Cache pip
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cache/pip
|
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pip-
|
|
${{ runner.os }}-
|
|
|
|
- name: Cache node modules
|
|
uses: actions/cache@v4
|
|
env:
|
|
cache-name: cache-node-modules
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
|
${{ runner.os }}-build-
|
|
${{ runner.os }}-
|
|
|
|
- name: Get yarn cache directory path
|
|
id: yarn-cache-dir-path
|
|
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
|
|
|
|
- uses: actions/cache@v4
|
|
id: yarn-cache
|
|
with:
|
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-yarn-
|
|
|
|
- name: Cache wkhtmltopdf
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: /tmp/wkhtmltox.deb
|
|
key: wkhtmltox-0.12.6.1-2-jammy-amd64
|
|
|
|
- name: Install
|
|
run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
|
|
env:
|
|
DB: postgres
|
|
TYPE: server
|
|
FRAPPE_USER: ${{ github.event.inputs.user }}
|
|
FRAPPE_BRANCH: ${{ github.event.client_payload.sha || github.event.inputs.branch }}
|
|
|
|
- name: Run Tests
|
|
run: |
|
|
cd ~/frappe-bench/
|
|
coverage_flag=""
|
|
if [ "$WITH_COVERAGE" = "true" ]; then coverage_flag="--with-coverage"; fi
|
|
bench --site test_site run-parallel-tests --lightmode --app erpnext \
|
|
--total-builds ${{ strategy.job-total }} \
|
|
--build-number ${{ matrix.container }} \
|
|
$coverage_flag
|
|
env:
|
|
TYPE: server
|
|
|
|
|
|
- name: Show bench output
|
|
if: ${{ always() }}
|
|
run: cat ~/frappe-bench/bench_start.log || true
|
|
|
|
- name: Upload coverage data
|
|
if: ${{ env.WITH_COVERAGE == 'true' }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: coverage-postgres-${{ matrix.container }}
|
|
path: /home/runner/frappe-bench/sites/coverage.xml
|
|
|
|
coverage:
|
|
name: Coverage Wrap Up
|
|
needs: test
|
|
if: ${{ github.event_name != 'pull_request' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Clone
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
pattern: coverage-postgres-*
|
|
|
|
- name: Upload coverage data
|
|
uses: codecov/codecov-action@v4
|
|
with:
|
|
name: Postgres
|
|
flags: postgres
|
|
# explicit glob: download-artifact extracts each shard into its own coverage-postgres-N/ dir
|
|
files: coverage-postgres-*/coverage.xml
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
fail_ci_if_error: true
|
|
verbose: true
|