blob: 67f58564342a77c46ca615902b654473c2dd4ab5 [file] [log] [blame]
Conord2074b12022-01-02 12:03:10 -06001name: Server (Mariadb)
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +05302
Suraj Shetty97687832021-05-28 13:39:53 +05303on:
4 pull_request:
Ankush Menat8a6b82b2021-08-13 12:59:27 +05305 paths-ignore:
6 - '**.js'
Ankush Menatf1a7e3b2022-03-14 18:19:52 +05307 - '**.css'
Ankush Menat8a6b82b2021-08-13 12:59:27 +05308 - '**.md'
Conord2074b12022-01-02 12:03:10 -06009 - '**.html'
Ankush Menat0218f112023-07-19 12:17:32 +053010 schedule:
11 # Run everday at midnight UTC / 5:30 IST
12 - cron: "0 0 * * *"
Ankush Menat6f2c9c62022-02-03 17:30:42 +053013 workflow_dispatch:
14 inputs:
15 user:
Ankush Menat7ee15182023-01-09 18:16:04 +053016 description: 'Frappe Framework repository user (add your username for forks)'
Ankush Menat6f2c9c62022-02-03 17:30:42 +053017 required: true
18 default: 'frappe'
19 type: string
20 branch:
Ankush Menat7ee15182023-01-09 18:16:04 +053021 description: 'Frappe Framework branch'
Ankush Menat6f2c9c62022-02-03 17:30:42 +053022 default: 'develop'
23 required: false
24 type: string
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053025
Ankush Menat9de0f752021-08-30 14:07:13 +053026concurrency:
Sagar Voraa2252c92022-08-09 11:49:48 +000027 group: server-mariadb-develop-${{ github.event_name }}-${{ github.event.number || github.event_name == 'workflow_dispatch' && github.run_id || '' }}
Ankush Menat9de0f752021-08-30 14:07:13 +053028 cancel-in-progress: true
29
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053030jobs:
31 test:
Ankush Menat602374a2021-08-30 18:24:48 +053032 runs-on: ubuntu-latest
Ankush0bb60b32021-07-29 17:15:12 +053033 timeout-minutes: 60
Ankush Menat96364582024-02-06 15:51:46 +053034 env:
35 NODE_ENV: "production"
36 WITH_COVERAGE: ${{ github.event_name != 'pull_request' }}
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053037
38 strategy:
Suraj Shetty622bf072021-05-08 13:51:34 +053039 fail-fast: false
Mohammad Hasnain Mohsin Rajan46d54312021-03-15 11:17:19 +053040
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053041 matrix:
Ankush Menat56c6a702022-06-30 11:35:45 +053042 container: [1, 2, 3, 4]
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053043
Suraj Shetty1f025a82021-05-12 18:14:22 +053044 name: Python Unit Tests
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053045
46 services:
47 mysql:
Ankush Menatd23b5d82022-12-06 12:58:07 +053048 image: mariadb:10.6
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053049 env:
Ankush Menatd23b5d82022-12-06 12:58:07 +053050 MARIADB_ROOT_PASSWORD: 'root'
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053051 ports:
52 - 3306:3306
Akhil Narang4a6108e2023-10-11 11:17:47 +053053 options: --health-cmd="mariadb-admin ping" --health-interval=5s --health-timeout=2s --health-retries=3
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053054
55 steps:
56 - name: Clone
Akhil Narang89b5e062024-03-27 12:55:46 +053057 uses: actions/checkout@v4
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053058
59 - name: Setup Python
Akhil Narang89b5e062024-03-27 12:55:46 +053060 uses: actions/setup-python@v5
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053061 with:
Akhil Narang89b5e062024-03-27 12:55:46 +053062 python-version: '3.12'
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053063
Gavin D'souzab07dd102022-07-04 11:11:14 +053064 - name: Check for valid Python & Merge Conflicts
65 run: |
66 python -m compileall -f "${GITHUB_WORKSPACE}"
67 if grep -lr --exclude-dir=node_modules "^<<<<<<< " "${GITHUB_WORKSPACE}"
68 then echo "Found merge conflicts"
69 exit 1
70 fi
71
Ankush Menate5e00702021-08-30 12:07:11 +053072 - name: Setup Node
Akhil Narang89b5e062024-03-27 12:55:46 +053073 uses: actions/setup-node@v4
Ankush Menate5e00702021-08-30 12:07:11 +053074 with:
Suraj Shetty881e95b2023-06-26 13:02:08 +053075 node-version: 18
Ankush Menate5e00702021-08-30 12:07:11 +053076 check-latest: true
77
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053078 - name: Add to Hosts
79 run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts
80
81 - name: Cache pip
Akhil Narang89b5e062024-03-27 12:55:46 +053082 uses: actions/cache@v4
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053083 with:
84 path: ~/.cache/pip
Ankush Menat20f85192022-06-29 12:23:17 +053085 key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml') }}
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053086 restore-keys: |
87 ${{ runner.os }}-pip-
88 ${{ runner.os }}-
Suraj Shetty490aed22021-05-08 00:04:34 +053089
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053090 - name: Cache node modules
Akhil Narang89b5e062024-03-27 12:55:46 +053091 uses: actions/cache@v4
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053092 env:
93 cache-name: cache-node-modules
94 with:
95 path: ~/.npm
96 key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
97 restore-keys: |
98 ${{ runner.os }}-build-${{ env.cache-name }}-
99 ${{ runner.os }}-build-
100 ${{ runner.os }}-
Suraj Shetty490aed22021-05-08 00:04:34 +0530101
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +0530102 - name: Get yarn cache directory path
103 id: yarn-cache-dir-path
104 run: echo "::set-output name=dir::$(yarn cache dir)"
105
Akhil Narang89b5e062024-03-27 12:55:46 +0530106 - uses: actions/cache@v4
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +0530107 id: yarn-cache
108 with:
109 path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
110 key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
111 restore-keys: |
112 ${{ runner.os }}-yarn-
113
114 - name: Install
115 run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
Ankush Menat92c0dcc2021-10-20 14:43:39 +0530116 env:
Conord2074b12022-01-02 12:03:10 -0600117 DB: mariadb
Ankush Menat92c0dcc2021-10-20 14:43:39 +0530118 TYPE: server
Ankush Menat6f2c9c62022-02-03 17:30:42 +0530119 FRAPPE_USER: ${{ github.event.inputs.user }}
120 FRAPPE_BRANCH: ${{ github.event.inputs.branch }}
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +0530121
122 - name: Run Tests
Ankush Menat96364582024-02-06 15:51:46 +0530123 run: 'cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --app erpnext --total-builds 4 --build-number ${{ matrix.container }}'
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +0530124 env:
Suraj Shetty490aed22021-05-08 00:04:34 +0530125 TYPE: server
Ankush Menat96364582024-02-06 15:51:46 +0530126 CAPTURE_COVERAGE: ${{ github.event_name != 'pull_request' }}
127
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +0530128
Ankush Menat2f7b3bb2023-09-14 14:46:45 +0530129 - name: Show bench output
130 if: ${{ always() }}
131 run: cat ~/frappe-bench/bench_start.log || true
132
Suraj Shetty1fc8fcc2021-09-10 08:08:00 +0530133 - name: Upload coverage data
Ankush Menatc14c5132022-04-10 15:06:38 +0530134 uses: actions/upload-artifact@v3
Ankush Menat96364582024-02-06 15:51:46 +0530135 if: github.event_name != 'pull_request'
Ankush Menatc14c5132022-04-10 15:06:38 +0530136 with:
137 name: coverage-${{ matrix.container }}
138 path: /home/runner/frappe-bench/sites/coverage.xml
139
140 coverage:
141 name: Coverage Wrap Up
142 needs: test
143 runs-on: ubuntu-latest
Ankush Menat96364582024-02-06 15:51:46 +0530144 if: ${{ github.event_name != 'pull_request' }}
Ankush Menatc14c5132022-04-10 15:06:38 +0530145 steps:
Ankush Menat71de7542022-04-13 18:23:22 +0530146 - name: Clone
Akhil Narang89b5e062024-03-27 12:55:46 +0530147 uses: actions/checkout@v4
Ankush Menat71de7542022-04-13 18:23:22 +0530148
Ankush Menatc14c5132022-04-10 15:06:38 +0530149 - name: Download artifacts
150 uses: actions/download-artifact@v3
151
152 - name: Upload coverage data
Akhil Narang89b5e062024-03-27 12:55:46 +0530153 uses: codecov/codecov-action@v4
Suraj Shetty1fc8fcc2021-09-10 08:08:00 +0530154 with:
155 name: MariaDB
Ankush Menat96364582024-02-06 15:51:46 +0530156 token: ${{ secrets.CODECOV_TOKEN }}
Suraj Shetty1fc8fcc2021-09-10 08:08:00 +0530157 fail_ci_if_error: true
Suraj Shetty1fc8fcc2021-09-10 08:08:00 +0530158 verbose: true