ci.yml 3.9 KB
Newer Older
1 2 3 4 5 6 7 8
name: CI

on:
  push:
    branches: [master, try-import]
  pull_request:
  
jobs:
9 10 11 12 13 14 15
  check-commit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2.3.1
        with:
          fetch-depth: 0
      - uses: actions/setup-node@v2.1.0
16 17 18 19 20
      - name: Check commit
        if: ${{ github.event.pull_request }}
        run: |
          yarn add @commitlint/config-conventional @commitlint/cli
          yarn commitlint --from ${{ github.event.pull_request.base.sha }} --to HEAD
21 22 23 24 25 26 27 28

  check-format:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2.3.1
        with:
          fetch-depth: 0
      - name: Set up Python
29
        if: ${{ github.event.pull_request }}
30 31 32 33
        uses: actions/setup-python@v2
        with:
          python-version: 3.6
      - name: Cache pip
34
        if: ${{ github.event.pull_request }}
35 36 37 38 39 40 41 42 43 44
        uses: actions/cache@v2
        with:
          # This path is specific to Ubuntu
          path: ~/.cache/pip
          # Look to see if there is a cache hit for the corresponding requirements file
          key: ${{ runner.os }}-pip-${{ hashFiles('requires.txt') }}
          restore-keys: |
            ${{ runner.os }}-pip-
            ${{ runner.os }}-
      - name: Install dependencies
45
        if: ${{ github.event.pull_request }}
46 47 48
        run: |
          python -m pip install --upgrade pip
      - name: Check format
49
        if: ${{ github.event.pull_request }}
50 51 52
        run: |
          ./ci/run_format_check.sh

53 54
  cpu-test:
    runs-on: self-hosted
55
    needs: [check-commit, check-format]
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
    container:
      image: localhost:5000/megengine-ci:latest
    steps:
      - name: Checkout MegEngine
        uses: actions/checkout@v2
      - name: Checkout submodules
        run: |
          ./third_party/prepare.sh
          ./third_party/install-mkl.sh
      - name: Build MegEngine
        run: ./ci/cmake.sh cpu
      - name: Python test
        run: ./ci/run_python_test.sh cpu
      - name: C++ test
        run: ./ci/run_cpp_test.sh cpu
  gpu-test:
    runs-on: self-hosted
73
    needs: [check-commit, check-format]
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
    container:
      image: localhost:5000/megengine-ci:latest
      volumes:
        - /usr/local/cuda-10.1-libs:/usr/local/cuda-10.1-libs
      options: --gpus all --shm-size 1g
      env:
        NCCL_LAUNCH_MODE: PARALLEL
    steps:
      - name: Checkout MegEngine
        uses: actions/checkout@v2
      - name: Checkout submodules
        run: |
          ./third_party/prepare.sh
          ./third_party/install-mkl.sh
      - name: Build MegEngine
        run: ./ci/cmake.sh cuda
      - name: Python test
        run: ./ci/run_python_test.sh cuda
      - name: C++ test
        run: ./ci/run_cpp_test.sh cuda
  auto-merge:
    if: ${{ github.ref == 'refs/heads/try-import' }}
    runs-on: ubuntu-latest
    needs: [cpu-test, gpu-test]
    steps:
      - name: Checkout MegEngine
        uses: actions/checkout@v2
        with:
          fetch-depth: '0'
      - name: Merge with master
        run: |
          git config user.name "megvii-mge"
          git config user.email "megengine@megvii.com"
          git fetch origin master
          git checkout -b master origin/master
          git rebase try-import
          git push
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
  send-dingding:
    runs-on: ubuntu-latest
    needs: [cpu-test, gpu-test]
    if: ${{ always() && github.ref == 'refs/heads/try-import' && (needs.cpu-test.result == 'failure' || needs.gpu-test.result == 'failure' ) }}
    steps:
      - name: run
        uses: zcong1993/actions-ding@master
        with:
          dingToken: ${{ secrets.DINGDING_TOKEN }}
          body: |
            {
              "msgtype": "link",
              "link": {
                  "text": "Workflow ${{ github.run_id }} Failed",
                  "title": "Action Alert",
                  "picUrl": "",
                  "messageUrl": "https://github.com/MegEngine/MegEngine/actions/runs/${{ github.run_id }}"
              }
            }