blob: aae2928bf0db3fc4e37a83e537d8f39217e9515f [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:
26 image: mariadb:10.3
27 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
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'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
Deepesh Garg56e81ad2023-06-22 19:57:23 +053046 uses: "actions/setup-python@v4"
Suraj Shetty490aed22021-05-08 00:04:34 +053047 with:
Deepesh Garg56e81ad2023-06-22 19:57:23 +053048 python-version: |
49 3.7
50 3.10
Ankush Menate5e00702021-08-30 12:07:11 +053051
52 - name: Setup Node
53 uses: actions/setup-node@v2
54 with:
Suraj Shetty881e95b2023-06-26 13:02:08 +053055 node-version: 18
Ankush Menate5e00702021-08-30 12:07:11 +053056 check-latest: true
Suraj Shetty490aed22021-05-08 00:04:34 +053057
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 Menat20f85192022-06-29 12:23:17 +053065 key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml') }}
Suraj Shetty490aed22021-05-08 00:04:34 +053066 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 Menatb9f394a2022-06-30 16:20:59 +053095 run: |
96 pip install frappe-bench
Ankush Menatb9f394a2022-06-30 16:20:59 +053097 bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
Conord2074b12022-01-02 12:03:10 -060098 env:
99 DB: mariadb
100 TYPE: server
Suraj Shetty490aed22021-05-08 00:04:34 +0530101
102 - name: Run Patch Tests
Gavin D'souzac68006b2021-06-03 20:05:00 +0530103 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 Menat27cbeb92021-09-26 14:10:52 +0530107
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 Menatb7285972021-11-10 17:59:07 +0530114 branch_name="version-$version-hotfix"
Ankush Menat27cbeb92021-09-26 14:10:52 +0530115
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 Menatb9f394a2022-06-30 16:20:59 +0530122 rm -rf ~/frappe-bench/env
Deepesh Garg56e81ad2023-06-22 19:57:23 +0530123 bench setup env --python python3.7
phot0n76493e92022-07-25 10:56:04 +0530124 bench pip install -e ./apps/payments
Ankush Menatb9f394a2022-06-30 16:20:59 +0530125 bench pip install -e ./apps/erpnext
126
Ankush Menat27cbeb92021-09-26 14:10:52 +0530127 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 Menatb9f394a2022-06-30 16:20:59 +0530134
Ankush Menatb9f394a2022-06-30 16:20:59 +0530135 rm -rf ~/frappe-bench/env
Deepesh Garg56e81ad2023-06-22 19:57:23 +0530136 bench -v setup env --python python3.10
phot0n76493e92022-07-25 10:56:04 +0530137 bench pip install -e ./apps/payments
Ankush Menatb9f394a2022-06-30 16:20:59 +0530138 bench pip install -e ./apps/erpnext
139
Gavin D'souzac68006b2021-06-03 20:05:00 +0530140 bench --site test_site migrate
phot0n76493e92022-07-25 10:56:04 +0530141 bench --site test_site install-app payments