blob: 69afa15187df92fbb08a13fd0ac12172596784ea [file] [log] [blame]
Suraj Shetty490aed22021-05-08 00:04:34 +05301name: Server
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +05302
Suraj Shetty97687832021-05-28 13:39:53 +05303on:
4 pull_request:
5 workflow_dispatch:
6 push:
7 branches: [ develop ]
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +05308
9jobs:
10 test:
Mohammad Hasnain Mohsin Rajan192ab052021-03-18 17:12:12 +053011 runs-on: ubuntu-18.04
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053012
13 strategy:
Suraj Shetty622bf072021-05-08 13:51:34 +053014 fail-fast: false
Mohammad Hasnain Mohsin Rajan46d54312021-03-15 11:17:19 +053015
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053016 matrix:
Suraj Shetty042118a2021-05-11 10:09:06 +053017 container: [1, 2, 3]
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053018
Suraj Shetty1f025a82021-05-12 18:14:22 +053019 name: Python Unit Tests
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053020
21 services:
22 mysql:
23 image: mariadb:10.3
24 env:
25 MYSQL_ALLOW_EMPTY_PASSWORD: YES
26 ports:
27 - 3306:3306
28 options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
29
30 steps:
31 - name: Clone
32 uses: actions/checkout@v2
33
34 - name: Setup Python
35 uses: actions/setup-python@v2
36 with:
Suraj Shetty28fdb2e2021-05-12 23:13:11 +053037 python-version: 3.7
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053038
39 - name: Add to Hosts
40 run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts
41
42 - name: Cache pip
43 uses: actions/cache@v2
44 with:
45 path: ~/.cache/pip
46 key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
47 restore-keys: |
48 ${{ runner.os }}-pip-
49 ${{ runner.os }}-
Suraj Shetty490aed22021-05-08 00:04:34 +053050
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053051 - name: Cache node modules
52 uses: actions/cache@v2
53 env:
54 cache-name: cache-node-modules
55 with:
56 path: ~/.npm
57 key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
58 restore-keys: |
59 ${{ runner.os }}-build-${{ env.cache-name }}-
60 ${{ runner.os }}-build-
61 ${{ runner.os }}-
Suraj Shetty490aed22021-05-08 00:04:34 +053062
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053063 - name: Get yarn cache directory path
64 id: yarn-cache-dir-path
65 run: echo "::set-output name=dir::$(yarn cache dir)"
66
67 - uses: actions/cache@v2
68 id: yarn-cache
69 with:
70 path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
71 key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
72 restore-keys: |
73 ${{ runner.os }}-yarn-
74
75 - name: Install
76 run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
77
78 - name: Run Tests
Suraj Shetty7044bcf2021-05-09 11:29:00 +053079 run: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --app erpnext --use-orchestrator --with-coverage
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053080 env:
Suraj Shetty490aed22021-05-08 00:04:34 +053081 TYPE: server
Suraj Shetty7044bcf2021-05-09 11:29:00 +053082 CI_BUILD_ID: ${{ github.run_id }}
Suraj Shetty64083672021-05-10 23:48:37 +053083 ORCHESTRATOR_URL: http://test-orchestrator.frappe.io
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053084
Suraj Shetty5117cbc2021-05-07 00:32:00 +053085 - name: Upload Coverage Data
Suraj Shetty5117cbc2021-05-07 00:32:00 +053086 run: |
87 cp ~/frappe-bench/sites/.coverage ${GITHUB_WORKSPACE}
88 cd ${GITHUB_WORKSPACE}
89 pip3 install coverage==5.5
90 pip3 install coveralls==3.0.1
Suraj Shettyd27e70a2021-05-08 16:02:40 +053091 coveralls
Suraj Shetty5117cbc2021-05-07 00:32:00 +053092 env:
93 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Suraj Shetty5b17f332021-06-01 08:18:56 +053094 COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
Suraj Shetty5117cbc2021-05-07 00:32:00 +053095 COVERALLS_FLAG_NAME: run-${{ matrix.container }}
Suraj Shettyd27e70a2021-05-08 16:02:40 +053096 COVERALLS_SERVICE_NAME: ${{ github.event_name == 'pull_request' && 'github' || 'github-actions' }}
Suraj Shetty5117cbc2021-05-07 00:32:00 +053097 COVERALLS_PARALLEL: true
Suraj Shettycd8ee8e2021-05-04 18:36:45 +053098
Suraj Shetty5117cbc2021-05-07 00:32:00 +053099 coveralls:
100 name: Coverage Wrap Up
101 needs: test
102 container: python:3-slim
103 runs-on: ubuntu-18.04
104 steps:
105 - name: Clone
106 uses: actions/checkout@v2
107
108 - name: Coveralls Finished
109 run: |
110 cd ${GITHUB_WORKSPACE}
Suraj Shetty5117cbc2021-05-07 00:32:00 +0530111 pip3 install coverage==5.5
112 pip3 install coveralls==3.0.1
113 coveralls --finish
114 env:
115 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}