name: staticheck_action

on:
  workflow_call:
    inputs:
      check_type:
        required: true
        type: string
      image_version:
        required: true
        type: string

jobs:
  JOB_staticcheck:
    name: CodeCheck_staticcheck
    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"
          access-key: ${{ secrets.AK }}
          secret-key: ${{ secrets.SK }}
          key: |
            ${{ env.obs_path }}/pr_filelist.txt
            ${{ env.obs_path }}/pr_filelist_mod.txt
            ${{ env.obs_path }}/update_file_detail.txt
          path: ${{ steps.process_checkout.outputs.path }}
      -
        name: staticcheck
        identifier: staticcheck
        uses: cann/.gitcode/actions/staticcheck@master
        with:
          check_type: ${{ inputs.check_type }}
          target_branch: ${{ env.TARGET_BRANCH }}
          repo_name: ${{ env.repo_name }}
          merge_id: ${{ env.MERGE_ID }}
          commit_id: '0'
          workspace: ${{ steps.process_checkout.outputs.path }}
      -
        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 }}/*.csv
            ${{ steps.process_checkout.outputs.path }}/StaticCheck_*.json
          object-prefix: ${{ env.obs_path }}/
    if: "${{ default() }}"
    runs-on: [dedicate-hosted, x64, large]
    container:
      image: swr.cn-north-4.myhuaweicloud.com/static_check/${{ inputs.image_version }}