diff --git a/.github/helper/install.sh b/.github/helper/install.sh index 85f146d35193..903196847dcb 100644 --- a/.github/helper/install.sh +++ b/.github/helper/install.sh @@ -12,17 +12,30 @@ git clone https://github.com/frappe/frappe --branch "${GITHUB_BASE_REF:-${GITHUB 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'" +if [ "$DB" == "mariadb" ];then + cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config_mariadb.json" ~/frappe-bench/sites/test_site/site_config.json +else + cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config_postgres.json" ~/frappe-bench/sites/test_site/site_config.json +fi -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" +if [ "$DB" == "mariadb" ];then + 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" +fi + +if [ "$DB" == "postgres" ];then + echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE DATABASE test_frappe" -U postgres; + echo "travis" | psql -h 127.0.0.1 -p 5432 -c "CREATE USER test_frappe WITH PASSWORD 'test_frappe'" -U postgres; +fi 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 diff --git a/.github/helper/site_config.json b/.github/helper/site_config_mariadb.json similarity index 99% rename from .github/helper/site_config.json rename to .github/helper/site_config_mariadb.json index 60ef80cbad59..948ad08babd0 100644 --- a/.github/helper/site_config.json +++ b/.github/helper/site_config_mariadb.json @@ -13,4 +13,4 @@ "host_name": "http://test_site:8000", "install_apps": ["erpnext"], "throttle_user_limit": 100 -} \ No newline at end of file +} diff --git a/.github/helper/site_config_postgres.json b/.github/helper/site_config_postgres.json new file mode 100644 index 000000000000..c82905fea02f --- /dev/null +++ b/.github/helper/site_config_postgres.json @@ -0,0 +1,18 @@ +{ + "db_host": "127.0.0.1", + "db_port": 5432, + "db_name": "test_frappe", + "db_password": "test_frappe", + "db_type": "postgres", + "allow_tests": true, + "auto_email_id": "test@example.com", + "mail_server": "smtp.example.com", + "mail_login": "test@example.com", + "mail_password": "test", + "admin_password": "admin", + "root_login": "postgres", + "root_password": "travis", + "host_name": "http://test_site:8000", + "install_apps": ["erpnext"], + "throttle_user_limit": 100 +} diff --git a/.github/workflows/patch.yml b/.github/workflows/patch.yml index 97bccf5d56a7..33a28ac9bbd3 100644 --- a/.github/workflows/patch.yml +++ b/.github/workflows/patch.yml @@ -80,6 +80,9 @@ jobs: - name: Install run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh + env: + DB: mariadb + TYPE: server - name: Run Patch Tests run: | diff --git a/.github/workflows/server-tests.yml b/.github/workflows/server-tests-mariadb.yml similarity index 95% rename from .github/workflows/server-tests.yml rename to .github/workflows/server-tests-mariadb.yml index 77c0aee195b0..186f95e6ec60 100644 --- a/.github/workflows/server-tests.yml +++ b/.github/workflows/server-tests-mariadb.yml @@ -1,10 +1,11 @@ -name: Server +name: Server (Mariadb) on: pull_request: paths-ignore: - '**.js' - '**.md' + - '**.html' workflow_dispatch: push: branches: [ develop ] @@ -13,7 +14,7 @@ on: - '**.md' concurrency: - group: server-develop-${{ github.event.number }} + group: server-mariadb-develop-${{ github.event.number }} cancel-in-progress: true jobs: @@ -92,6 +93,7 @@ jobs: - name: Install run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh env: + DB: mariadb TYPE: server - name: Run Tests diff --git a/.github/workflows/server-tests-postgres.yml b/.github/workflows/server-tests-postgres.yml new file mode 100644 index 000000000000..3bbf6a91f549 --- /dev/null +++ b/.github/workflows/server-tests-postgres.yml @@ -0,0 +1,105 @@ +name: Server (Postgres) + +on: + pull_request: + paths-ignore: + - '**.js' + - '**.md' + - '**.html' + types: [opened, labelled, synchronize, reopened] + +concurrency: + group: server-postgres-develop-${{ github.event.number }} + cancel-in-progress: true + +jobs: + test: + if: ${{ contains(github.event.pull_request.labels.*.name, 'postgres') }} + runs-on: ubuntu-latest + timeout-minutes: 60 + + strategy: + fail-fast: false + matrix: + container: [1, 2, 3] + + name: Python Unit Tests + + services: + postgres: + image: postgres:13.3 + env: + POSTGRES_PASSWORD: travis + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + steps: + + - name: Clone + uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + + - name: Setup Node + uses: actions/setup-node@v2 + with: + node-version: 14 + 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@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 + env: + DB: postgres + TYPE: server + + - name: Run Tests + run: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --app erpnext --use-orchestrator + env: + TYPE: server + CI_BUILD_ID: ${{ github.run_id }} + ORCHESTRATOR_URL: http://test-orchestrator.frappe.io