Skip to content
Snippets Groups Projects
test.yml 30.47 KiB
name: Build and Test CI
on:
  pull_request:
    types: [review_requested]
    branches:
      - "*"
  workflow_dispatch:
    inputs:
      placeholder:
        description: "placeholder, no effect"
        required: false
jobs:
  cancel_previous:
    name: Cancel previous runs
    runs-on: ubuntu-latest
    steps:
      - name: Cancel previous runs of outdated commit
        uses: styfle/cancel-workflow-action@0.9.0
        with:
          access_token: ${{ github.token }}
          all_but_latest: true

  mirror_third_party:
    name: Mirror third party dependencies
    runs-on: ubuntu-18.04
    if: github.event.pull_request.draft == false && github.base_ref == 'master' && contains(github.event.pull_request.requested_reviewers.*.login, 'oneflow-ci-bot')
    steps:
      - uses: actions/checkout@v2
      - name: Mirror dependencies to aliyun
        env:
          OSS_ACCESS_KEY_ID: ${{ secrets.OSS_ACCESS_KEY_ID }}
          OSS_ACCESS_KEY_SECRET: ${{ secrets.OSS_ACCESS_KEY_SECRET }}
        run: |
          set -x
          if [ -z "$OSS_ACCESS_KEY_ID" ]
          then
            exit 0
          fi
          python3 -m pip install -U pip setuptools wheel
          python3 -m pip install oss2
          python3 tools/package_mirror.py -i cmake

  check_license_and_format:
    name: License and format
    runs-on: ubuntu-18.04
    if: github.event.pull_request.draft == false && contains(github.event.pull_request.requested_reviewers.*.login, 'oneflow-ci-bot')
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.event.pull_request.head.ref }}
          repository: ${{github.event.pull_request.head.repo.full_name}}
      - name: Check license
        id: license_check
        run: |
          python3 ci/check/run_license_format.py -i oneflow -c
      - name: Add license
        id: license_fmt
        if: ${{ failure() }}
        run: |
          python3 ci/check/run_license_format.py -i oneflow --fix
      - name: Check C++/CUDA format
        id: cpp_check
        run: |
          python3 ci/check/run_clang_format.py --clang_format_binary clang-format --source_dir oneflow
      - name: Run C++/CUDA format
        id: cpp_fmt
        if: ${{ failure() }}
        run: |
          python3 ci/check/run_clang_format.py --clang_format_binary clang-format --source_dir oneflow --fix
      - name: Check Python format