ci: Port CI test from Travis to Github Actions (#24846)
This commit is contained in:
parent
b5792872e9
commit
0f60f08f3e
42
.github/helper/install.sh
vendored
Normal file
42
.github/helper/install.sh
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cd ~ || exit
|
||||||
|
|
||||||
|
sudo apt-get install redis-server
|
||||||
|
|
||||||
|
nvm install 10
|
||||||
|
|
||||||
|
pip install frappe-bench
|
||||||
|
|
||||||
|
git clone https://github.com/frappe/frappe --branch "${GITHUB_BASE_REF}" --depth 1
|
||||||
|
bench init --skip-assets --frappe-path ~/frappe --python "$(which python)" frappe-bench
|
||||||
|
|
||||||
|
mkdir ~/frappe-bench/sites/test_site
|
||||||
|
cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config.json" ~/frappe-bench/sites/test_site/
|
||||||
|
|
||||||
|
mysql --host 127.0.0.1 --port 3306 -u root -e "SET GLOBAL character_set_server = 'utf8mb4'"
|
||||||
|
mysql --host 127.0.0.1 --port 3306 -u root -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'"
|
||||||
|
|
||||||
|
mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'"
|
||||||
|
mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE DATABASE test_frappe"
|
||||||
|
mysql --host 127.0.0.1 --port 3306 -u root -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'"
|
||||||
|
|
||||||
|
mysql --host 127.0.0.1 --port 3306 -u root -e "UPDATE mysql.user SET Password=PASSWORD('travis') WHERE User='root'"
|
||||||
|
mysql --host 127.0.0.1 --port 3306 -u root -e "FLUSH PRIVILEGES"
|
||||||
|
|
||||||
|
wget -O /tmp/wkhtmltox.tar.xz https://github.com/frappe/wkhtmltopdf/raw/master/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
|
||||||
|
tar -xf /tmp/wkhtmltox.tar.xz -C /tmp
|
||||||
|
sudo mv /tmp/wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
|
||||||
|
sudo chmod o+x /usr/local/bin/wkhtmltopdf
|
||||||
|
sudo apt-get install libcups2-dev
|
||||||
|
|
||||||
|
cd ~/frappe-bench || exit
|
||||||
|
|
||||||
|
sed -i 's/watch:/# watch:/g' Procfile
|
||||||
|
sed -i 's/schedule:/# schedule:/g' Procfile
|
||||||
|
sed -i 's/socketio:/# socketio:/g' Procfile
|
||||||
|
sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile
|
||||||
|
|
||||||
|
bench get-app erpnext "${GITHUB_WORKSPACE}"
|
||||||
|
bench start &
|
||||||
|
bench --site test_site reinstall --yes
|
14
.github/helper/run_tests.sh
vendored
Normal file
14
.github/helper/run_tests.sh
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cd ~/frappe-bench/ || exit
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$TYPE" == "server" ]; then
|
||||||
|
bench --site test_site run-tests --app erpnext --coverage
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$TYPE" == "patch" ]; then
|
||||||
|
wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz
|
||||||
|
bench --site test_site --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz
|
||||||
|
bench --site test_site migrate
|
||||||
|
fi
|
@ -1,4 +1,6 @@
|
|||||||
{
|
{
|
||||||
|
"db_host": "127.0.0.1",
|
||||||
|
"db_port": 3306,
|
||||||
"db_name": "test_frappe",
|
"db_name": "test_frappe",
|
||||||
"db_password": "test_frappe",
|
"db_password": "test_frappe",
|
||||||
"auto_email_id": "test@example.com",
|
"auto_email_id": "test@example.com",
|
94
.github/workflows/ci-tests.yml
vendored
Normal file
94
.github/workflows/ci-tests.yml
vendored
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- TYPE: "server"
|
||||||
|
JOB_NAME: "Server"
|
||||||
|
- TYPE: "patch"
|
||||||
|
JOB_NAME: "Patch"
|
||||||
|
|
||||||
|
name: ${{ matrix.JOB_NAME }}
|
||||||
|
|
||||||
|
services:
|
||||||
|
mysql:
|
||||||
|
image: mariadb:10.3
|
||||||
|
env:
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: YES
|
||||||
|
ports:
|
||||||
|
- 3306:3306
|
||||||
|
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Clone
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: 3.6
|
||||||
|
|
||||||
|
- name: Add to Hosts
|
||||||
|
run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts
|
||||||
|
|
||||||
|
- name: Cache pip
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ~/.cache/pip
|
||||||
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pip-
|
||||||
|
${{ runner.os }}-
|
||||||
|
|
||||||
|
- name: Cache node modules
|
||||||
|
uses: actions/cache@v2
|
||||||
|
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 "::set-output name=dir::$(yarn cache dir)"
|
||||||
|
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
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: Install
|
||||||
|
run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
|
||||||
|
|
||||||
|
- name: Run Tests
|
||||||
|
run: bash ${GITHUB_WORKSPACE}/.github/helper/run_tests.sh
|
||||||
|
env:
|
||||||
|
TYPE: ${{ matrix.TYPE }}
|
||||||
|
|
||||||
|
- name: Coverage
|
||||||
|
if: matrix.TYPE == 'server'
|
||||||
|
run: |
|
||||||
|
cp ~/frappe-bench/sites/.coverage ${GITHUB_WORKSPACE}
|
||||||
|
cd ${GITHUB_WORKSPACE}
|
||||||
|
pip install coveralls==2.2.0
|
||||||
|
pip install coverage==4.5.4
|
||||||
|
coveralls
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
|
69
.travis.yml
69
.travis.yml
@ -1,69 +0,0 @@
|
|||||||
language: python
|
|
||||||
dist: trusty
|
|
||||||
|
|
||||||
git:
|
|
||||||
depth: 1
|
|
||||||
|
|
||||||
cache:
|
|
||||||
- pip
|
|
||||||
|
|
||||||
addons:
|
|
||||||
hosts: test_site
|
|
||||||
mariadb: 10.3
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
include:
|
|
||||||
- name: "Python 3.6 Server Side Test"
|
|
||||||
python: 3.6
|
|
||||||
script: bench --site test_site run-tests --app erpnext --coverage
|
|
||||||
|
|
||||||
- name: "Python 3.6 Patch Test"
|
|
||||||
python: 3.6
|
|
||||||
before_script:
|
|
||||||
- wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz
|
|
||||||
- bench --site test_site --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz
|
|
||||||
script: bench --site test_site migrate
|
|
||||||
|
|
||||||
install:
|
|
||||||
- cd ~
|
|
||||||
- nvm install 10
|
|
||||||
|
|
||||||
- pip install frappe-bench
|
|
||||||
|
|
||||||
- git clone https://github.com/frappe/frappe --branch $TRAVIS_BRANCH --depth 1
|
|
||||||
- bench init --skip-assets --frappe-path ~/frappe --python $(which python) frappe-bench
|
|
||||||
|
|
||||||
- mkdir ~/frappe-bench/sites/test_site
|
|
||||||
- cp -r $TRAVIS_BUILD_DIR/.travis/site_config.json ~/frappe-bench/sites/test_site/
|
|
||||||
|
|
||||||
- mysql -u root -e "SET GLOBAL character_set_server = 'utf8mb4'"
|
|
||||||
- mysql -u root -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'"
|
|
||||||
|
|
||||||
- mysql -u root -e "CREATE DATABASE test_frappe"
|
|
||||||
- mysql -u root -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'"
|
|
||||||
- mysql -u root -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'"
|
|
||||||
|
|
||||||
- mysql -u root -e "UPDATE mysql.user SET Password=PASSWORD('travis') WHERE User='root'"
|
|
||||||
- mysql -u root -e "FLUSH PRIVILEGES"
|
|
||||||
|
|
||||||
- wget -O /tmp/wkhtmltox.tar.xz https://github.com/frappe/wkhtmltopdf/raw/master/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
|
|
||||||
- tar -xf /tmp/wkhtmltox.tar.xz -C /tmp
|
|
||||||
- sudo mv /tmp/wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
|
|
||||||
- sudo chmod o+x /usr/local/bin/wkhtmltopdf
|
|
||||||
- sudo apt-get install libcups2-dev
|
|
||||||
|
|
||||||
- cd ~/frappe-bench
|
|
||||||
|
|
||||||
- sed -i 's/watch:/# watch:/g' Procfile
|
|
||||||
- sed -i 's/schedule:/# schedule:/g' Procfile
|
|
||||||
- sed -i 's/socketio:/# socketio:/g' Procfile
|
|
||||||
- sed -i 's/redis_socketio:/# redis_socketio:/g' Procfile
|
|
||||||
|
|
||||||
- bench get-app erpnext $TRAVIS_BUILD_DIR
|
|
||||||
- bench start &
|
|
||||||
- bench --site test_site reinstall --yes
|
|
||||||
|
|
||||||
after_script:
|
|
||||||
- pip install coverage==4.5.4
|
|
||||||
- pip install python-coveralls
|
|
||||||
- coveralls -b apps/erpnext -d ../../sites/.coverage
|
|
Loading…
x
Reference in New Issue
Block a user