blob: 4d955190be1ac8f87468e78998d228bb0b6994aa [file] [log] [blame]
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +05301name: CI
2
Suraj Shetty85dd5d22021-05-06 13:05:03 +05303on: [pull_request, workflow_dispatch]
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +05304
5jobs:
6 test:
Mohammad Hasnain Mohsin Rajan192ab052021-03-18 17:12:12 +05307 runs-on: ubuntu-18.04
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +05308
9 strategy:
10 fail-fast: false
Mohammad Hasnain Mohsin Rajan46d54312021-03-15 11:17:19 +053011
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053012 matrix:
13 include:
14 - TYPE: "server"
Suraj Shetty3b69aa82021-05-07 00:32:00 +053015 JOB_NAME: "Server.1"
Suraj Shetty591f3f02021-05-04 18:36:45 +053016 RUN_COMMAND: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --with-coverage --ci-build-id $GITHUB_RUN_ID --app erpnext
17 - TYPE: "server"
Suraj Shetty3b69aa82021-05-07 00:32:00 +053018 JOB_NAME: "Server.2"
Suraj Shetty591f3f02021-05-04 18:36:45 +053019 RUN_COMMAND: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --with-coverage --ci-build-id $GITHUB_RUN_ID --app erpnext
Suraj Shetty0f3d8622021-05-06 15:13:09 +053020 - TYPE: "server"
Suraj Shetty3b69aa82021-05-07 00:32:00 +053021 JOB_NAME: "Server.3"
Suraj Shetty0f3d8622021-05-06 15:13:09 +053022 RUN_COMMAND: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --with-coverage --ci-build-id $GITHUB_RUN_ID --app erpnext
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053023 - TYPE: "patch"
24 JOB_NAME: "Patch"
Mohammad Hasnain Mohsin Rajan46d54312021-03-15 11:17:19 +053025 RUN_COMMAND: cd ~/frappe-bench/ && wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz && bench --site test_site --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz && bench --site test_site migrate
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053026
27 name: ${{ matrix.JOB_NAME }}
28
29 services:
30 mysql:
31 image: mariadb:10.3
32 env:
33 MYSQL_ALLOW_EMPTY_PASSWORD: YES
34 ports:
35 - 3306:3306
36 options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
37
38 steps:
39 - name: Clone
40 uses: actions/checkout@v2
41
42 - name: Setup Python
43 uses: actions/setup-python@v2
44 with:
45 python-version: 3.6
46
47 - name: Add to Hosts
48 run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts
49
50 - name: Cache pip
51 uses: actions/cache@v2
52 with:
53 path: ~/.cache/pip
54 key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
55 restore-keys: |
56 ${{ runner.os }}-pip-
57 ${{ runner.os }}-
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053058 - name: Cache node modules
59 uses: actions/cache@v2
60 env:
61 cache-name: cache-node-modules
62 with:
63 path: ~/.npm
64 key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
65 restore-keys: |
66 ${{ runner.os }}-build-${{ env.cache-name }}-
67 ${{ runner.os }}-build-
68 ${{ runner.os }}-
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053069 - name: Get yarn cache directory path
70 id: yarn-cache-dir-path
71 run: echo "::set-output name=dir::$(yarn cache dir)"
72
73 - uses: actions/cache@v2
74 id: yarn-cache
75 with:
76 path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
77 key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
78 restore-keys: |
79 ${{ runner.os }}-yarn-
80
81 - name: Install
82 run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
83
84 - name: Run Tests
Mohammad Hasnain Mohsin Rajan46d54312021-03-15 11:17:19 +053085 run: ${{ matrix.RUN_COMMAND }}
Mohammad Hasnain Mohsin Rajan0f60f082021-03-12 14:09:52 +053086 env:
87 TYPE: ${{ matrix.TYPE }}
88
Suraj Shetty3b69aa82021-05-07 00:32:00 +053089 - name: Upload Coverage Data
90 if: matrix.TYPE == 'server'
91 run: |
92 cp ~/frappe-bench/sites/.coverage ${GITHUB_WORKSPACE}
93 cd ${GITHUB_WORKSPACE}
94 pip3 install coverage==5.5
95 pip3 install coveralls==3.0.1
96 coveralls --service=github-actions
97 env:
98 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99 COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
100 COVERALLS_FLAG_NAME: run-${{ matrix.container }}
101 COVERALLS_SERVICE_NAME: github-actions
102 COVERALLS_PARALLEL: true
Suraj Shetty591f3f02021-05-04 18:36:45 +0530103
Suraj Shetty3b69aa82021-05-07 00:32:00 +0530104 coveralls:
105 name: Coverage Wrap Up
106 needs: test
107 container: python:3-slim
108 runs-on: ubuntu-18.04
109 steps:
110 - name: Clone
111 uses: actions/checkout@v2
112
113 - name: Coveralls Finished
114 run: |
115 cd ${GITHUB_WORKSPACE}
116 ls -al
117 pip3 install coverage==5.5
118 pip3 install coveralls==3.0.1
119 coveralls --finish
120 env:
121 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Mohammad Hasnain Mohsin Rajan0dc00212021-04-29 15:21:16 +0530122