name: llt_action

on:
  workflow_call:
    inputs:
      ut_type:
        required: true
        type: string
      ut_package:
        type: string
        default: 'ut_cov_*.tar.gz'
      image_version:
        required: true
        type: string
      task_name:
        required: true
        type: string
      ge_st_rt2:
        required: false
        type: string

jobs:
  JOB_ut:
    name: UT
    steps:
      -
        name: Checkout
        identifier: process_checkout
        uses: checkout
        with:
          ref: ${{ atomgit.event.pull_request.merge_commit_sha }}
          token: ${{secrets.GIT_TOKEN}}
      -
        name: download
        uses: obs-download
        with:
          endpoint: "https://obs.cn-north-4.myhuaweicloud.com"
          bucket: "ascend-ci"
          key: |
            ${{ env.obs_path }}/pr_filelist.txt
            ${{ env.obs_path }}/pr_filelist_mod.txt
            ${{ env.obs_path }}/ut.sh
          path: ${{ steps.process_checkout.outputs.path }}
      -
        name: redis-cache
        uses: cann/.gitcode/actions/redis-cache@master
      -
        name: ut_acc
        identifier: ut
        run: |
          export WORKSPACE=${{ steps.process_checkout.outputs.path }}
          cd ${{ steps.process_checkout.outputs.path }}
          export ut_type=${{ inputs.ut_type }}
          export task_name=${{ inputs.task_name }}
          export ge_st_rt2=${{ inputs.ge_st_rt2 }}
          bash ut.sh
      -
        name: upload
        uses: obs-upload
        with:
          endpoint: "https://obs.cn-north-4.myhuaweicloud.com"
          bucket: "ascend-ci"
          access-key: ${{secrets.AK}}
          secret-key: ${{secrets.SK}}
          artifact-path: |
            ${{ steps.process_checkout.outputs.path }}/${{ inputs.ut_package }}
          object-prefix: ${{ env.obs_path }}/
    if: "${{ default() }}"
    runs-on: ["self-hosted", "arch=x64", "spec=xlarge"]
    container:
      image: swr.cn-north-4.myhuaweicloud.com/ci_cann/${{ inputs.image_version }}