From 46d5431bad31bb1953d361117bb8014f27e6da2c Mon Sep 17 00:00:00 2001 From: Mohammad Hasnain Mohsin Rajan Date: Mon, 15 Mar 2021 11:17:19 +0530 Subject: [PATCH] fix: Github Action not failing when tests fail (#24867) Co-authored-by: Sagar Vora --- .github/helper/install.sh | 6 +++++- .github/helper/run_tests.sh | 14 -------------- .github/workflows/ci-tests.yml | 8 +++++--- .../doctype/salary_slip/test_salary_slip.py | 2 +- 4 files changed, 11 insertions(+), 19 deletions(-) delete mode 100644 .github/helper/run_tests.sh diff --git a/.github/helper/install.sh b/.github/helper/install.sh index 8c87f23896..253ad70198 100644 --- a/.github/helper/install.sh +++ b/.github/helper/install.sh @@ -1,10 +1,14 @@ #!/bin/bash +set -e + cd ~ || exit sudo apt-get install redis-server -nvm install 10 +sudo apt install nodejs + +sudo apt install npm pip install frappe-bench diff --git a/.github/helper/run_tests.sh b/.github/helper/run_tests.sh deleted file mode 100644 index 4574ac222c..0000000000 --- a/.github/helper/run_tests.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/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 diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index f2cf423bcb..2a1db14d95 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -10,12 +10,15 @@ jobs: strategy: fail-fast: false + matrix: include: - TYPE: "server" JOB_NAME: "Server" + RUN_COMMAND: cd ~/frappe-bench/ && bench --site test_site run-tests --app erpnext --coverage - TYPE: "patch" JOB_NAME: "Patch" + RUN_COMMAND: cd ~/frappe-bench/ && 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 name: ${{ matrix.JOB_NAME }} @@ -48,7 +51,6 @@ jobs: restore-keys: | ${{ runner.os }}-pip- ${{ runner.os }}- - - name: Cache node modules uses: actions/cache@v2 env: @@ -60,7 +62,6 @@ jobs: ${{ 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)" @@ -77,7 +78,7 @@ jobs: run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh - name: Run Tests - run: bash ${GITHUB_WORKSPACE}/.github/helper/run_tests.sh + run: ${{ matrix.RUN_COMMAND }} env: TYPE: ${{ matrix.TYPE }} @@ -92,3 +93,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} + diff --git a/erpnext/payroll/doctype/salary_slip/test_salary_slip.py b/erpnext/payroll/doctype/salary_slip/test_salary_slip.py index 7289933d99..143a306eb3 100644 --- a/erpnext/payroll/doctype/salary_slip/test_salary_slip.py +++ b/erpnext/payroll/doctype/salary_slip/test_salary_slip.py @@ -246,7 +246,7 @@ class TestSalarySlip(unittest.TestCase): make_salary_structure("Test Loan Repayment Salary Structure", "Monthly", employee=applicant, currency='INR', payroll_period=payroll_period) - frappe.db.sql("""delete from `tabLoan""") + frappe.db.sql("delete from tabLoan") loan = create_loan(applicant, "Car Loan", 11000, "Repay Over Number of Periods", 20, posting_date=add_months(nowdate(), -1)) loan.repay_from_salary = 1 loan.submit()