blob: deca0073b895bae92c731bfb9186e97ddc1d6bf7 [file] [log] [blame]
Suraj Shetty490aed22021-05-08 00:04:34 +05301name: Patch
2
Ankush Menat8a6b82b2021-08-13 12:59:27 +05303on:
4 pull_request:
5 paths-ignore:
6 - '**.js'
Ankush Menatf1a7e3b2022-03-14 18:19:52 +05307 - '**.css'
Ankush Menat8a6b82b2021-08-13 12:59:27 +05308 - '**.md'
Ankush Menatf1a7e3b2022-03-14 18:19:52 +05309 - '**.html'
10 - '**.csv'
Ankush Menat8a6b82b2021-08-13 12:59:27 +053011 workflow_dispatch:
12
Ankush Menat9de0f752021-08-30 14:07:13 +053013concurrency:
Sagar Voraa2252c92022-08-09 11:49:48 +000014 group: patch-develop-${{ github.event_name }}-${{ github.event.number || github.event_name == 'workflow_dispatch' && github.run_id || '' }}
Ankush Menat9de0f752021-08-30 14:07:13 +053015 cancel-in-progress: true
Suraj Shetty490aed22021-05-08 00:04:34 +053016
17jobs:
18 test:
Ankush Menat602374a2021-08-30 18:24:48 +053019 runs-on: ubuntu-latest
Ankush0bb60b32021-07-29 17:15:12 +053020 timeout-minutes: 60
Suraj Shetty490aed22021-05-08 00:04:34 +053021
22 name: Patch Test
23
24 services:
25 mysql:
Ankush Menat2f7b3bb2023-09-14 14:46:45 +053026 image: mariadb:10.6
Suraj Shetty490aed22021-05-08 00:04:34 +053027 env:
Ankush Menatd23b5d82022-12-06 12:58:07 +053028 MARIADB_ROOT_PASSWORD: 'root'
Suraj Shetty490aed22021-05-08 00:04:34 +053029 ports:
30 - 3306:3306
Akhil Narang4a6108e2023-10-11 11:17:47 +053031 options: --health-cmd="mariadb-admin ping" --health-interval=5s --health-timeout=2s --health-retries=3
Suraj Shetty490aed22021-05-08 00:04:34 +053032
33 steps:
34 - name: Clone
Akhil Narang89b5e062024-03-27 12:55:46 +053035 uses: actions/checkout@v4
Suraj Shetty490aed22021-05-08 00:04:34 +053036
Gavin D'souzab07dd102022-07-04 11:11:14 +053037 - 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 Shetty490aed22021-05-08 00:04:34 +053045 - name: Setup Python
Akhil Narang89b5e062024-03-27 12:55:46 +053046 uses: actions/setup-python@v5
Suraj Shetty490aed22021-05-08 00:04:34 +053047 with:
Akhil Narang89b5e062024-03-27 12:55:46 +053048 python-version: '3.11'
Ankush Menate5e00702021-08-30 12:07:11 +053049
50 - name: Setup Node
Akhil Narang89b5e062024-03-27 12:55:46 +053051 uses: actions/setup-node@v4
Ankush Menate5e00702021-08-30 12:07:11 +053052 with:
Suraj Shetty881e95b2023-06-26 13:02:08 +053053 node-version: 18
Ankush Menate5e00702021-08-30 12:07:11 +053054 check-latest: true
Suraj Shetty490aed22021-05-08 00:04:34 +053055
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 Narang89b5e062024-03-27 12:55:46 +053060 uses: actions/cache@v4
Suraj Shetty490aed22021-05-08 00:04:34 +053061 with:
62 path: ~/.cache/pip
Ankush Menat20f85192022-06-29 12:23:17 +053063 key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml') }}
Suraj Shetty490aed22021-05-08 00:04:34 +053064 restore-keys: |
65 ${{ runner.os }}-pip-
66 ${{ runner.os }}-
67
68 - name: Cache node modules
Akhil Narang89b5e062024-03-27 12:55:46 +053069 uses: actions/cache@v4
Suraj Shetty490aed22021-05-08 00:04:34 +053070 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 Narang89b5e062024-03-27 12:55:46 +053084 - uses: actions/cache@v4
Suraj Shetty490aed22021-05-08 00:04:34 +053085 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 Menatb9f394a2022-06-30 16:20:59 +053093 run: |
94 pip install frappe-bench
Ankush Menatb9f394a2022-06-30 16:20:59 +053095 bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
Conord2074b12022-01-02 12:03:10 -060096 env:
97 DB: mariadb
98 TYPE: server
Suraj Shetty490aed22021-05-08 00:04:34 +053099
100 - name: Run Patch Tests
Gavin D'souzac68006b2021-06-03 20:05:00 +0530101 run: |
102 cd ~/frappe-bench/
Ankush Menat2f7b3bb2023-09-14 14:46:45 +0530103 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 Menat27cbeb92021-09-26 14:10:52 +0530109
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 Menat27cbeb92021-09-26 14:10:52 +0530113
Ankush Menat2f7b3bb2023-09-14 14:46:45 +0530114 function update_to_version() {
115 version=$1
Ankush Menat27cbeb92021-09-26 14:10:52 +0530116
Ankush Menat2f7b3bb2023-09-14 14:46:45 +0530117 branch_name="version-$version-hotfix"
118 echo "Updating to v$version"
Ankush Menat27cbeb92021-09-26 14:10:52 +0530119
Ankush Menat2f7b3bb2023-09-14 14:46:45 +0530120 # 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 Menatb9f394a2022-06-30 16:20:59 +0530125
Ankush Menat2f7b3bb2023-09-14 14:46:45 +0530126 # 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 Menat27cbeb92021-09-26 14:10:52 +0530132
Ankush Menat2f7b3bb2023-09-14 14:46:45 +0530133 bench --site test_site migrate
134 }
135
136 update_to_version 14
Ankush Menat40cdde82023-10-19 15:52:53 +0530137 update_to_version 15
Ankush Menat27cbeb92021-09-26 14:10:52 +0530138
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 Menatb9f394a2022-06-30 16:20:59 +0530142
Ankush Menat61778d52023-09-15 16:51:56 +0530143 pgrep honcho | xargs kill
Ankush Menatb9f394a2022-06-30 16:20:59 +0530144 rm -rf ~/frappe-bench/env
Ankush Menat2f7b3bb2023-09-14 14:46:45 +0530145 bench -v setup env
Ankush Menatb9f394a2022-06-30 16:20:59 +0530146 bench pip install -e ./apps/erpnext
Ankush Menat61778d52023-09-15 16:51:56 +0530147 bench start &>> ~/frappe-bench/bench_start.log &
Ankush Menatb9f394a2022-06-30 16:20:59 +0530148
Gavin D'souzac68006b2021-06-03 20:05:00 +0530149 bench --site test_site migrate
Ankush Menat2f7b3bb2023-09-14 14:46:45 +0530150
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