Suraj Shetty | b4c958c | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 1 | name: Server |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 2 | |
Suraj Shetty | 85dd5d2 | 2021-05-06 13:05:03 +0530 | [diff] [blame] | 3 | on: [pull_request, workflow_dispatch] |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 4 | |
| 5 | jobs: |
| 6 | test: |
Mohammad Hasnain Mohsin Rajan | 192ab05 | 2021-03-18 17:12:12 +0530 | [diff] [blame] | 7 | runs-on: ubuntu-18.04 |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 8 | |
| 9 | strategy: |
Suraj Shetty | 6ca8989 | 2021-05-08 13:51:34 +0530 | [diff] [blame] | 10 | fail-fast: false |
Mohammad Hasnain Mohsin Rajan | 46d5431 | 2021-03-15 11:17:19 +0530 | [diff] [blame] | 11 | |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 12 | matrix: |
Suraj Shetty | 77f2686 | 2021-05-11 10:09:06 +0530 | [diff] [blame] | 13 | container: [1, 2, 3] |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 14 | |
Suraj Shetty | 6da2212 | 2021-05-12 18:14:22 +0530 | [diff] [blame] | 15 | name: Python Unit Tests |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 16 | |
| 17 | services: |
| 18 | mysql: |
| 19 | image: mariadb:10.3 |
| 20 | env: |
| 21 | MYSQL_ALLOW_EMPTY_PASSWORD: YES |
| 22 | ports: |
| 23 | - 3306:3306 |
| 24 | options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3 |
| 25 | |
| 26 | steps: |
| 27 | - name: Clone |
| 28 | uses: actions/checkout@v2 |
| 29 | |
| 30 | - name: Setup Python |
| 31 | uses: actions/setup-python@v2 |
| 32 | with: |
Suraj Shetty | 85aeca1 | 2021-05-12 23:13:11 +0530 | [diff] [blame] | 33 | python-version: 3.7 |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 34 | |
| 35 | - name: Add to Hosts |
| 36 | run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts |
| 37 | |
| 38 | - name: Cache pip |
| 39 | uses: actions/cache@v2 |
| 40 | with: |
| 41 | path: ~/.cache/pip |
| 42 | key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} |
| 43 | restore-keys: | |
| 44 | ${{ runner.os }}-pip- |
| 45 | ${{ runner.os }}- |
Suraj Shetty | b4c958c | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 46 | |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 47 | - name: Cache node modules |
| 48 | uses: actions/cache@v2 |
| 49 | env: |
| 50 | cache-name: cache-node-modules |
| 51 | with: |
| 52 | path: ~/.npm |
| 53 | key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} |
| 54 | restore-keys: | |
| 55 | ${{ runner.os }}-build-${{ env.cache-name }}- |
| 56 | ${{ runner.os }}-build- |
| 57 | ${{ runner.os }}- |
Suraj Shetty | b4c958c | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 58 | |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 59 | - name: Get yarn cache directory path |
| 60 | id: yarn-cache-dir-path |
| 61 | run: echo "::set-output name=dir::$(yarn cache dir)" |
| 62 | |
| 63 | - uses: actions/cache@v2 |
| 64 | id: yarn-cache |
| 65 | with: |
| 66 | path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 67 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 68 | restore-keys: | |
| 69 | ${{ runner.os }}-yarn- |
| 70 | |
| 71 | - name: Install |
| 72 | run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh |
| 73 | |
| 74 | - name: Run Tests |
Suraj Shetty | c79f5d7 | 2021-05-09 11:29:00 +0530 | [diff] [blame] | 75 | run: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --app erpnext --use-orchestrator --with-coverage |
Mohammad Hasnain Mohsin Rajan | 0f60f08 | 2021-03-12 14:09:52 +0530 | [diff] [blame] | 76 | env: |
Suraj Shetty | b4c958c | 2021-05-08 00:04:34 +0530 | [diff] [blame] | 77 | TYPE: server |
Suraj Shetty | c79f5d7 | 2021-05-09 11:29:00 +0530 | [diff] [blame] | 78 | CI_BUILD_ID: ${{ github.run_id }} |
Suraj Shetty | b9a8afc | 2021-05-10 23:48:37 +0530 | [diff] [blame] | 79 | ORCHESTRATOR_URL: http://test-orchestrator.frappe.io |
Suraj Shetty | faa2516 | 2021-05-28 11:23:18 +0530 | [diff] [blame] | 80 | |
| 81 | - name: Upload Coverage Data |
| 82 | run: | |
| 83 | cp ~/frappe-bench/sites/.coverage ${GITHUB_WORKSPACE} |
| 84 | cd ${GITHUB_WORKSPACE} |
| 85 | pip3 install coverage==5.5 |
| 86 | pip3 install coveralls==3.0.1 |
| 87 | coveralls |
| 88 | env: |
| 89 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 90 | COVERALLS_FLAG_NAME: run-${{ matrix.container }} |
| 91 | COVERALLS_SERVICE_NAME: ${{ github.event_name == 'pull_request' && 'github' || 'github-actions' }} |
| 92 | COVERALLS_PARALLEL: true |
| 93 | |
| 94 | coveralls: |
| 95 | name: Coverage Wrap Up |
| 96 | needs: test |
| 97 | container: python:3-slim |
| 98 | runs-on: ubuntu-18.04 |
| 99 | steps: |
| 100 | - name: Clone |
| 101 | uses: actions/checkout@v2 |
| 102 | |
| 103 | - name: Coveralls Finished |
| 104 | run: | |
| 105 | cd ${GITHUB_WORKSPACE} |
| 106 | pip3 install coverage==5.5 |
| 107 | pip3 install coveralls==3.0.1 |
| 108 | coveralls --finish |
| 109 | env: |
| 110 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |