name: citest

on:
  push:
    branches:
      - master
      - "release/**"
    paths-ignore:
      - "setup.*"
      - "requirements.txt"
      - "requirements/**"
      - "docs/**"
      - "tools/**"
      - ".dev_scripts/**"
      - "README.md"
      - "README_zh-CN.md"
      - "NOTICE"
      - ".github/workflows/lint.yaml"
      - ".github/workflows/publish.yaml"

  pull_request:
    paths-ignore:
      - "setup.*"
      - "requirements.txt"
      - "requirements/**"
      - "docs/**"
      - "tools/**"
      - ".dev_scripts/**"
      - "README.md"
      - "README_zh-CN.md"
      - "NOTICE"
      - ".github/workflows/lint.yaml"
      - ".github/workflows/publish.yaml"

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  unittest:
    # The type of runner that the job will run on
    runs-on: [modelscope-self-hosted]
    steps:
      - name: ResetFileMode
        shell: bash
        run: |
          # reset filemode to allow action runner to delete files
          # generated by root in docker
          set -e
          source ~/.bashrc
          sudo chown -R $USER:$USER  $ACTION_RUNNER_DIR

      - name: Checkout
        uses: actions/checkout@v2
        with:
            lfs: 'true'
      - name: Checkout LFS objects
        run: git lfs checkout
      - name: Run unittest
        shell: bash
        run: |
          set -e
          source /mnt/modelscope/ci_env.sh
          bash .dev_scripts/dockerci.sh
