mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-18 19:07:55 +00:00
ci: optimize install helper setup
Cc: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
(cherry picked from commit a3e3e1b32c)
This commit is contained in:
51
.github/helper/install.sh
vendored
51
.github/helper/install.sh
vendored
@@ -4,24 +4,46 @@ set -e
|
|||||||
|
|
||||||
cd ~ || exit
|
cd ~ || exit
|
||||||
|
|
||||||
sudo apt update
|
|
||||||
sudo apt remove mysql-server mysql-client
|
|
||||||
sudo apt install libcups2-dev redis-server mariadb-client libmariadb-dev
|
|
||||||
|
|
||||||
pip install frappe-bench
|
|
||||||
|
|
||||||
githubbranch=${GITHUB_BASE_REF:-${GITHUB_REF##*/}}
|
githubbranch=${GITHUB_BASE_REF:-${GITHUB_REF##*/}}
|
||||||
frappeuser=${FRAPPE_USER:-"frappe"}
|
frappeuser=${FRAPPE_USER:-"frappe"}
|
||||||
frappecommitish=${FRAPPE_BRANCH:-$githubbranch}
|
frappecommitish=${FRAPPE_BRANCH:-$githubbranch}
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Phase 1 — parallelise the three slow, independent setup steps:
|
||||||
|
# a) system packages b) frappe-bench pip install c) frappe git fetch
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
sudo apt update
|
||||||
|
|
||||||
|
# apt remove/install must run sequentially but can overlap with pip and git.
|
||||||
|
sudo apt remove mysql-server mysql-client
|
||||||
|
sudo apt install libcups2-dev redis-server mariadb-client libmariadb-dev &
|
||||||
|
apt_pid=$!
|
||||||
|
|
||||||
|
pip install frappe-bench &
|
||||||
|
pip_pid=$!
|
||||||
|
|
||||||
mkdir frappe
|
mkdir frappe
|
||||||
|
(
|
||||||
|
cd frappe
|
||||||
|
git init
|
||||||
|
git remote add origin "https://github.com/${frappeuser}/frappe"
|
||||||
|
git fetch origin "${frappecommitish}" --depth 1
|
||||||
|
) &
|
||||||
|
clone_pid=$!
|
||||||
|
|
||||||
|
wait $apt_pid
|
||||||
|
wait $pip_pid
|
||||||
|
wait $clone_pid
|
||||||
|
|
||||||
pushd frappe
|
pushd frappe
|
||||||
git init
|
|
||||||
git remote add origin "https://github.com/${frappeuser}/frappe"
|
|
||||||
git fetch origin "${frappecommitish}" --depth 1
|
|
||||||
git checkout FETCH_HEAD
|
git checkout FETCH_HEAD
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Phase 2 — bench init and site setup
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
bench init --skip-assets --frappe-path ~/frappe --python "$(which python)" frappe-bench
|
bench init --skip-assets --frappe-path ~/frappe --python "$(which python)" frappe-bench
|
||||||
|
|
||||||
mkdir ~/frappe-bench/sites/test_site
|
mkdir ~/frappe-bench/sites/test_site
|
||||||
@@ -37,6 +59,11 @@ if [ "$DB" == "mariadb" ];then
|
|||||||
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL character_set_server = 'utf8mb4'"
|
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL character_set_server = 'utf8mb4'"
|
||||||
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'"
|
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'"
|
||||||
|
|
||||||
|
# Belt-and-suspenders: also set performance variables at runtime in case
|
||||||
|
# MARIADB_EXTRA_FLAGS was not honoured by the container image.
|
||||||
|
mariadb --host 127.0.0.1 --port 3306 -u root -proot \
|
||||||
|
-e "SET GLOBAL innodb_flush_log_at_trx_commit=0; SET GLOBAL sync_binlog=0;"
|
||||||
|
|
||||||
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'"
|
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'"
|
||||||
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "CREATE DATABASE test_frappe"
|
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "CREATE DATABASE test_frappe"
|
||||||
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'"
|
mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'"
|
||||||
@@ -51,9 +78,11 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
install_whktml() {
|
install_whktml() {
|
||||||
wget -O /tmp/wkhtmltox.deb https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb
|
# Re-use the .deb if the wkhtmltopdf cache step already restored it.
|
||||||
|
if [ ! -f /tmp/wkhtmltox.deb ]; then
|
||||||
|
wget -O /tmp/wkhtmltox.deb https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb
|
||||||
|
fi
|
||||||
sudo apt install /tmp/wkhtmltox.deb
|
sudo apt install /tmp/wkhtmltox.deb
|
||||||
|
|
||||||
}
|
}
|
||||||
install_whktml &
|
install_whktml &
|
||||||
wkpid=$!
|
wkpid=$!
|
||||||
|
|||||||
21
.github/workflows/server-tests-mariadb.yml
vendored
21
.github/workflows/server-tests-mariadb.yml
vendored
@@ -59,6 +59,10 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
TZ: 'Asia/Kolkata'
|
TZ: 'Asia/Kolkata'
|
||||||
MARIADB_ROOT_PASSWORD: 'root'
|
MARIADB_ROOT_PASSWORD: 'root'
|
||||||
|
# Disable durability guarantees that are unnecessary in a throwaway CI container.
|
||||||
|
# innodb_flush_log_at_trx_commit=0 avoids an fsync on every commit (biggest win).
|
||||||
|
# sync_binlog=0 skips binary-log syncs; innodb_doublewrite=0 skips the doublewrite buffer.
|
||||||
|
MARIADB_EXTRA_FLAGS: --innodb-flush-log-at-trx-commit=0 --sync-binlog=0 --innodb-doublewrite=0
|
||||||
ports:
|
ports:
|
||||||
- 3306:3306
|
- 3306:3306
|
||||||
options: --health-cmd="mariadb-admin ping" --health-interval=5s --health-timeout=2s --health-retries=3
|
options: --health-cmd="mariadb-admin ping" --health-interval=5s --health-timeout=2s --health-retries=3
|
||||||
@@ -122,6 +126,12 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-yarn-
|
${{ 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
|
- name: Install
|
||||||
run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
|
run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
|
||||||
env:
|
env:
|
||||||
@@ -131,7 +141,14 @@ jobs:
|
|||||||
FRAPPE_BRANCH: ${{ github.event.client_payload.sha || github.event.inputs.branch }}
|
FRAPPE_BRANCH: ${{ github.event.client_payload.sha || github.event.inputs.branch }}
|
||||||
|
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: 'cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --lightmode --app erpnext --total-builds ${{ strategy.job-total }} --build-number ${{ matrix.container }} --with-coverage'
|
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:
|
env:
|
||||||
TYPE: server
|
TYPE: server
|
||||||
|
|
||||||
@@ -141,6 +158,7 @@ jobs:
|
|||||||
run: cat ~/frappe-bench/bench_start.log || true
|
run: cat ~/frappe-bench/bench_start.log || true
|
||||||
|
|
||||||
- name: Upload coverage data
|
- name: Upload coverage data
|
||||||
|
if: ${{ env.WITH_COVERAGE == 'true' }}
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: coverage-${{ matrix.container }}
|
name: coverage-${{ matrix.container }}
|
||||||
@@ -149,6 +167,7 @@ jobs:
|
|||||||
coverage:
|
coverage:
|
||||||
name: Coverage Wrap Up
|
name: Coverage Wrap Up
|
||||||
needs: test
|
needs: test
|
||||||
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Clone
|
- name: Clone
|
||||||
|
|||||||
Reference in New Issue
Block a user