Suraj Shetty | 490aed2 | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 1 | name: Patch |
| 2 | |
Ankush Menat | 8a6b82b | 2021-08-13 12:59:27 +0530 | [diff] [blame] | 3 | on: |
| 4 | pull_request: |
| 5 | paths-ignore: |
| 6 | - '**.js' |
Ankush Menat | f1a7e3b | 2022-03-14 18:19:52 +0530 | [diff] [blame] | 7 | - '**.css' |
Ankush Menat | 8a6b82b | 2021-08-13 12:59:27 +0530 | [diff] [blame] | 8 | - '**.md' |
Ankush Menat | f1a7e3b | 2022-03-14 18:19:52 +0530 | [diff] [blame] | 9 | - '**.html' |
| 10 | - '**.csv' |
Ankush Menat | 8a6b82b | 2021-08-13 12:59:27 +0530 | [diff] [blame] | 11 | workflow_dispatch: |
| 12 | |
Ankush Menat | 9de0f75 | 2021-08-30 14:07:13 +0530 | [diff] [blame] | 13 | concurrency: |
Sagar Vora | a2252c9 | 2022-08-09 11:49:48 +0000 | [diff] [blame] | 14 | group: patch-develop-${{ github.event_name }}-${{ github.event.number || github.event_name == 'workflow_dispatch' && github.run_id || '' }} |
Ankush Menat | 9de0f75 | 2021-08-30 14:07:13 +0530 | [diff] [blame] | 15 | cancel-in-progress: true |
Suraj Shetty | 490aed2 | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 16 | |
| 17 | jobs: |
| 18 | test: |
Ankush Menat | 602374a | 2021-08-30 18:24:48 +0530 | [diff] [blame] | 19 | runs-on: ubuntu-latest |
Ankush | 0bb60b3 | 2021-07-29 17:15:12 +0530 | [diff] [blame] | 20 | timeout-minutes: 60 |
Suraj Shetty | 490aed2 | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 21 | |
| 22 | name: Patch Test |
| 23 | |
| 24 | services: |
| 25 | mysql: |
| 26 | image: mariadb:10.3 |
| 27 | env: |
Ankush Menat | d23b5d8 | 2022-12-06 12:58:07 +0530 | [diff] [blame] | 28 | MARIADB_ROOT_PASSWORD: 'root' |
Suraj Shetty | 490aed2 | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 29 | ports: |
| 30 | - 3306:3306 |
| 31 | options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3 |
| 32 | |
| 33 | steps: |
| 34 | - name: Clone |
| 35 | uses: actions/checkout@v2 |
| 36 | |
Gavin D'souza | b07dd10 | 2022-07-04 11:11:14 +0530 | [diff] [blame] | 37 | - name: Check for valid Python & Merge Conflicts |
| 38 | run: | |
| 39 | python -m compileall -f "${GITHUB_WORKSPACE}" |
| 40 | if grep -lr --exclude-dir=node_modules "^<<<<<<< " "${GITHUB_WORKSPACE}" |
| 41 | then echo "Found merge conflicts" |
| 42 | exit 1 |
| 43 | fi |
| 44 | |
Suraj Shetty | 490aed2 | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 45 | - name: Setup Python |
Deepesh Garg | 56e81ad | 2023-06-22 19:57:23 +0530 | [diff] [blame] | 46 | uses: "actions/setup-python@v4" |
Suraj Shetty | 490aed2 | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 47 | with: |
Deepesh Garg | 56e81ad | 2023-06-22 19:57:23 +0530 | [diff] [blame] | 48 | python-version: | |
| 49 | 3.7 |
| 50 | 3.10 |
Ankush Menat | e5e0070 | 2021-08-30 12:07:11 +0530 | [diff] [blame] | 51 | |
| 52 | - name: Setup Node |
| 53 | uses: actions/setup-node@v2 |
| 54 | with: |
Suraj Shetty | 881e95b | 2023-06-26 13:02:08 +0530 | [diff] [blame] | 55 | node-version: 18 |
Ankush Menat | e5e0070 | 2021-08-30 12:07:11 +0530 | [diff] [blame] | 56 | check-latest: true |
Suraj Shetty | 490aed2 | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 57 | |
| 58 | - name: Add to Hosts |
| 59 | run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts |
| 60 | |
| 61 | - name: Cache pip |
| 62 | uses: actions/cache@v2 |
| 63 | with: |
| 64 | path: ~/.cache/pip |
Ankush Menat | 20f8519 | 2022-06-29 12:23:17 +0530 | [diff] [blame] | 65 | key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml') }} |
Suraj Shetty | 490aed2 | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 66 | restore-keys: | |
| 67 | ${{ runner.os }}-pip- |
| 68 | ${{ runner.os }}- |
| 69 | |
| 70 | - name: Cache node modules |
| 71 | uses: actions/cache@v2 |
| 72 | env: |
| 73 | cache-name: cache-node-modules |
| 74 | with: |
| 75 | path: ~/.npm |
| 76 | key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} |
| 77 | restore-keys: | |
| 78 | ${{ runner.os }}-build-${{ env.cache-name }}- |
| 79 | ${{ runner.os }}-build- |
| 80 | ${{ runner.os }}- |
| 81 | |
| 82 | - name: Get yarn cache directory path |
| 83 | id: yarn-cache-dir-path |
| 84 | run: echo "::set-output name=dir::$(yarn cache dir)" |
| 85 | |
| 86 | - uses: actions/cache@v2 |
| 87 | id: yarn-cache |
| 88 | with: |
| 89 | path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 90 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 91 | restore-keys: | |
| 92 | ${{ runner.os }}-yarn- |
| 93 | |
| 94 | - name: Install |
Ankush Menat | b9f394a | 2022-06-30 16:20:59 +0530 | [diff] [blame] | 95 | run: | |
| 96 | pip install frappe-bench |
Ankush Menat | b9f394a | 2022-06-30 16:20:59 +0530 | [diff] [blame] | 97 | bash ${GITHUB_WORKSPACE}/.github/helper/install.sh |
Conor | d2074b1 | 2022-01-02 12:03:10 -0600 | [diff] [blame] | 98 | env: |
| 99 | DB: mariadb |
| 100 | TYPE: server |
Suraj Shetty | 490aed2 | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 101 | |
| 102 | - name: Run Patch Tests |
Gavin D'souza | c68006b | 2021-06-03 20:05:00 +0530 | [diff] [blame] | 103 | run: | |
| 104 | cd ~/frappe-bench/ |
| 105 | wget https://erpnext.com/files/v10-erpnext.sql.gz |
| 106 | bench --site test_site --force restore ~/frappe-bench/v10-erpnext.sql.gz |
Ankush Menat | 27cbeb9 | 2021-09-26 14:10:52 +0530 | [diff] [blame] | 107 | |
| 108 | git -C "apps/frappe" remote set-url upstream https://github.com/frappe/frappe.git |
| 109 | git -C "apps/erpnext" remote set-url upstream https://github.com/frappe/erpnext.git |
| 110 | |
| 111 | for version in $(seq 12 13) |
| 112 | do |
| 113 | echo "Updating to v$version" |
Ankush Menat | b728597 | 2021-11-10 17:59:07 +0530 | [diff] [blame] | 114 | branch_name="version-$version-hotfix" |
Ankush Menat | 27cbeb9 | 2021-09-26 14:10:52 +0530 | [diff] [blame] | 115 | |
| 116 | git -C "apps/frappe" fetch --depth 1 upstream $branch_name:$branch_name |
| 117 | git -C "apps/erpnext" fetch --depth 1 upstream $branch_name:$branch_name |
| 118 | |
| 119 | git -C "apps/frappe" checkout -q -f $branch_name |
| 120 | git -C "apps/erpnext" checkout -q -f $branch_name |
| 121 | |
Ankush Menat | b9f394a | 2022-06-30 16:20:59 +0530 | [diff] [blame] | 122 | rm -rf ~/frappe-bench/env |
Deepesh Garg | 56e81ad | 2023-06-22 19:57:23 +0530 | [diff] [blame] | 123 | bench setup env --python python3.7 |
phot0n | 76493e9 | 2022-07-25 10:56:04 +0530 | [diff] [blame] | 124 | bench pip install -e ./apps/payments |
Ankush Menat | b9f394a | 2022-06-30 16:20:59 +0530 | [diff] [blame] | 125 | bench pip install -e ./apps/erpnext |
| 126 | |
Ankush Menat | 27cbeb9 | 2021-09-26 14:10:52 +0530 | [diff] [blame] | 127 | bench --site test_site migrate |
| 128 | done |
| 129 | |
| 130 | |
| 131 | echo "Updating to latest version" |
| 132 | git -C "apps/frappe" checkout -q -f "${GITHUB_BASE_REF:-${GITHUB_REF##*/}}" |
| 133 | git -C "apps/erpnext" checkout -q -f "$GITHUB_SHA" |
Ankush Menat | b9f394a | 2022-06-30 16:20:59 +0530 | [diff] [blame] | 134 | |
Ankush Menat | b9f394a | 2022-06-30 16:20:59 +0530 | [diff] [blame] | 135 | rm -rf ~/frappe-bench/env |
Deepesh Garg | 56e81ad | 2023-06-22 19:57:23 +0530 | [diff] [blame] | 136 | bench -v setup env --python python3.10 |
phot0n | 76493e9 | 2022-07-25 10:56:04 +0530 | [diff] [blame] | 137 | bench pip install -e ./apps/payments |
Ankush Menat | b9f394a | 2022-06-30 16:20:59 +0530 | [diff] [blame] | 138 | bench pip install -e ./apps/erpnext |
| 139 | |
Gavin D'souza | c68006b | 2021-06-03 20:05:00 +0530 | [diff] [blame] | 140 | bench --site test_site migrate |
phot0n | 76493e9 | 2022-07-25 10:56:04 +0530 | [diff] [blame] | 141 | bench --site test_site install-app payments |