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: |
Ankush Menat | 2f7b3bb | 2023-09-14 14:46:45 +0530 | [diff] [blame] | 26 | image: mariadb:10.6 |
Suraj Shetty | 490aed2 | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 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 |
Akhil Narang | 4a6108e | 2023-10-11 11:17:47 +0530 | [diff] [blame] | 31 | options: --health-cmd="mariadb-admin ping" --health-interval=5s --health-timeout=2s --health-retries=3 |
Suraj Shetty | 490aed2 | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 32 | |
| 33 | steps: |
| 34 | - name: Clone |
Akhil Narang | 89b5e06 | 2024-03-27 12:55:46 +0530 | [diff] [blame] | 35 | uses: actions/checkout@v4 |
Suraj Shetty | 490aed2 | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 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 |
Akhil Narang | 89b5e06 | 2024-03-27 12:55:46 +0530 | [diff] [blame] | 46 | uses: actions/setup-python@v5 |
Suraj Shetty | 490aed2 | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 47 | with: |
Akhil Narang | 89b5e06 | 2024-03-27 12:55:46 +0530 | [diff] [blame] | 48 | python-version: '3.11' |
Ankush Menat | e5e0070 | 2021-08-30 12:07:11 +0530 | [diff] [blame] | 49 | |
| 50 | - name: Setup Node |
Akhil Narang | 89b5e06 | 2024-03-27 12:55:46 +0530 | [diff] [blame] | 51 | uses: actions/setup-node@v4 |
Ankush Menat | e5e0070 | 2021-08-30 12:07:11 +0530 | [diff] [blame] | 52 | with: |
Suraj Shetty | 881e95b | 2023-06-26 13:02:08 +0530 | [diff] [blame] | 53 | node-version: 18 |
Ankush Menat | e5e0070 | 2021-08-30 12:07:11 +0530 | [diff] [blame] | 54 | check-latest: true |
Suraj Shetty | 490aed2 | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 55 | |
| 56 | - name: Add to Hosts |
| 57 | run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts |
| 58 | |
| 59 | - name: Cache pip |
Akhil Narang | 89b5e06 | 2024-03-27 12:55:46 +0530 | [diff] [blame] | 60 | uses: actions/cache@v4 |
Suraj Shetty | 490aed2 | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 61 | with: |
| 62 | path: ~/.cache/pip |
Ankush Menat | 20f8519 | 2022-06-29 12:23:17 +0530 | [diff] [blame] | 63 | key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml') }} |
Suraj Shetty | 490aed2 | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 64 | restore-keys: | |
| 65 | ${{ runner.os }}-pip- |
| 66 | ${{ runner.os }}- |
| 67 | |
| 68 | - name: Cache node modules |
Akhil Narang | 89b5e06 | 2024-03-27 12:55:46 +0530 | [diff] [blame] | 69 | uses: actions/cache@v4 |
Suraj Shetty | 490aed2 | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 70 | env: |
| 71 | cache-name: cache-node-modules |
| 72 | with: |
| 73 | path: ~/.npm |
| 74 | key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} |
| 75 | restore-keys: | |
| 76 | ${{ runner.os }}-build-${{ env.cache-name }}- |
| 77 | ${{ runner.os }}-build- |
| 78 | ${{ runner.os }}- |
| 79 | |
| 80 | - name: Get yarn cache directory path |
| 81 | id: yarn-cache-dir-path |
| 82 | run: echo "::set-output name=dir::$(yarn cache dir)" |
| 83 | |
Akhil Narang | 89b5e06 | 2024-03-27 12:55:46 +0530 | [diff] [blame] | 84 | - uses: actions/cache@v4 |
Suraj Shetty | 490aed2 | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 85 | id: yarn-cache |
| 86 | with: |
| 87 | path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 88 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 89 | restore-keys: | |
| 90 | ${{ runner.os }}-yarn- |
| 91 | |
| 92 | - name: Install |
Ankush Menat | b9f394a | 2022-06-30 16:20:59 +0530 | [diff] [blame] | 93 | run: | |
| 94 | pip install frappe-bench |
Ankush Menat | b9f394a | 2022-06-30 16:20:59 +0530 | [diff] [blame] | 95 | bash ${GITHUB_WORKSPACE}/.github/helper/install.sh |
Conor | d2074b1 | 2022-01-02 12:03:10 -0600 | [diff] [blame] | 96 | env: |
| 97 | DB: mariadb |
| 98 | TYPE: server |
Suraj Shetty | 490aed2 | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 99 | |
| 100 | - name: Run Patch Tests |
Gavin D'souza | c68006b | 2021-06-03 20:05:00 +0530 | [diff] [blame] | 101 | run: | |
| 102 | cd ~/frappe-bench/ |
Ankush Menat | 2f7b3bb | 2023-09-14 14:46:45 +0530 | [diff] [blame] | 103 | bench remove-app payments --force |
| 104 | jq 'del(.install_apps)' ~/frappe-bench/sites/test_site/site_config.json > tmp.json |
| 105 | mv tmp.json ~/frappe-bench/sites/test_site/site_config.json |
| 106 | |
| 107 | wget https://erpnext.com/files/v13-erpnext.sql.gz |
| 108 | bench --site test_site --force restore ~/frappe-bench/v13-erpnext.sql.gz |
Ankush Menat | 27cbeb9 | 2021-09-26 14:10:52 +0530 | [diff] [blame] | 109 | |
| 110 | git -C "apps/frappe" remote set-url upstream https://github.com/frappe/frappe.git |
| 111 | git -C "apps/erpnext" remote set-url upstream https://github.com/frappe/erpnext.git |
| 112 | |
Ankush Menat | 27cbeb9 | 2021-09-26 14:10:52 +0530 | [diff] [blame] | 113 | |
Ankush Menat | 2f7b3bb | 2023-09-14 14:46:45 +0530 | [diff] [blame] | 114 | function update_to_version() { |
| 115 | version=$1 |
Ankush Menat | 27cbeb9 | 2021-09-26 14:10:52 +0530 | [diff] [blame] | 116 | |
Ankush Menat | 2f7b3bb | 2023-09-14 14:46:45 +0530 | [diff] [blame] | 117 | branch_name="version-$version-hotfix" |
| 118 | echo "Updating to v$version" |
Ankush Menat | 27cbeb9 | 2021-09-26 14:10:52 +0530 | [diff] [blame] | 119 | |
Ankush Menat | 2f7b3bb | 2023-09-14 14:46:45 +0530 | [diff] [blame] | 120 | # Fetch and checkout branches |
| 121 | git -C "apps/frappe" fetch --depth 1 upstream $branch_name:$branch_name |
| 122 | git -C "apps/erpnext" fetch --depth 1 upstream $branch_name:$branch_name |
| 123 | git -C "apps/frappe" checkout -q -f $branch_name |
| 124 | git -C "apps/erpnext" checkout -q -f $branch_name |
Ankush Menat | b9f394a | 2022-06-30 16:20:59 +0530 | [diff] [blame] | 125 | |
Ankush Menat | 2f7b3bb | 2023-09-14 14:46:45 +0530 | [diff] [blame] | 126 | # Resetup env and install apps |
| 127 | pgrep honcho | xargs kill |
| 128 | rm -rf ~/frappe-bench/env |
| 129 | bench -v setup env |
| 130 | bench pip install -e ./apps/erpnext |
| 131 | bench start &>> ~/frappe-bench/bench_start.log & |
Ankush Menat | 27cbeb9 | 2021-09-26 14:10:52 +0530 | [diff] [blame] | 132 | |
Ankush Menat | 2f7b3bb | 2023-09-14 14:46:45 +0530 | [diff] [blame] | 133 | bench --site test_site migrate |
| 134 | } |
| 135 | |
| 136 | update_to_version 14 |
Ankush Menat | 40cdde8 | 2023-10-19 15:52:53 +0530 | [diff] [blame] | 137 | update_to_version 15 |
Ankush Menat | 27cbeb9 | 2021-09-26 14:10:52 +0530 | [diff] [blame] | 138 | |
| 139 | echo "Updating to latest version" |
| 140 | git -C "apps/frappe" checkout -q -f "${GITHUB_BASE_REF:-${GITHUB_REF##*/}}" |
| 141 | git -C "apps/erpnext" checkout -q -f "$GITHUB_SHA" |
Ankush Menat | b9f394a | 2022-06-30 16:20:59 +0530 | [diff] [blame] | 142 | |
Ankush Menat | 61778d5 | 2023-09-15 16:51:56 +0530 | [diff] [blame] | 143 | pgrep honcho | xargs kill |
Ankush Menat | b9f394a | 2022-06-30 16:20:59 +0530 | [diff] [blame] | 144 | rm -rf ~/frappe-bench/env |
Ankush Menat | 2f7b3bb | 2023-09-14 14:46:45 +0530 | [diff] [blame] | 145 | bench -v setup env |
Ankush Menat | b9f394a | 2022-06-30 16:20:59 +0530 | [diff] [blame] | 146 | bench pip install -e ./apps/erpnext |
Ankush Menat | 61778d5 | 2023-09-15 16:51:56 +0530 | [diff] [blame] | 147 | bench start &>> ~/frappe-bench/bench_start.log & |
Ankush Menat | b9f394a | 2022-06-30 16:20:59 +0530 | [diff] [blame] | 148 | |
Gavin D'souza | c68006b | 2021-06-03 20:05:00 +0530 | [diff] [blame] | 149 | bench --site test_site migrate |
Ankush Menat | 2f7b3bb | 2023-09-14 14:46:45 +0530 | [diff] [blame] | 150 | |
| 151 | - name: Show bench output |
| 152 | if: ${{ always() }} |
| 153 | run: | |
| 154 | cd ~/frappe-bench |
| 155 | cat bench_start.log || true |
| 156 | cd logs |
| 157 | for f in ./*.log*; do |
| 158 | echo "Printing log: $f"; |
| 159 | cat $f |
| 160 | done |