| @@ -0,0 +1,73 @@ | |||
| 1 | +#!/bin/bash | ||
| 2 | +# ----------------------------------------------------------------------------------------------------------- | ||
| 3 | +# Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 4 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 5 | +# CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 6 | +# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 7 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 8 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 9 | +# See LICENSE in the root of the software repository for the full text of the License. | ||
| 10 | +# ----------------------------------------------------------------------------------------------------------- | ||
| 11 | +set -e | ||
| 12 | + | ||
| 13 | +REPOSITORY_NAME="ops-ras" | ||
| 14 | +echo $(grep -E "^VERSION_ID=" /etc/os-release | cut -d'"' -f2) | ||
| 15 | +export PATH=/opt/buildtools/python-3.10.2/bin:$PATH | ||
| 16 | +if [[ "${task_name}" == *ubuntu24* ]]; then | ||
| 17 | + sudo update-alternatives --set gcc /usr/bin/gcc-14 | ||
| 18 | +else | ||
| 19 | + if [[ -f "/opt/rh/devtoolset-7/enable" ]]; then | ||
| 20 | + echo "source devtoolset" | ||
| 21 | + source /opt/rh/devtoolset-7/enable | ||
| 22 | + fi | ||
| 23 | +fi | ||
| 24 | +gcc --version | ||
| 25 | + | ||
| 26 | +if [ -z "${ASCEND_3RD_LIB_PATH}" ]; then | ||
| 27 | + export ASCEND_3RD_LIB_PATH=/home/jenkins/opensource | ||
| 28 | +fi | ||
| 29 | + | ||
| 30 | +if [ -z "${OS_TYPE}" ]; then | ||
| 31 | + OS_TYPE=$(uname -m) | ||
| 32 | +fi | ||
| 33 | + | ||
| 34 | +if [ -f /home/jenkins/Ascend/cann/bin/setenv.bash ]; then | ||
| 35 | + source /home/jenkins/Ascend/cann/bin/setenv.bash | ||
| 36 | +fi | ||
| 37 | + | ||
| 38 | +LOG_HEAD() | ||
| 39 | +{ | ||
| 40 | + echo "========================================" | ||
| 41 | + echo " $1" | ||
| 42 | + echo "========================================" | ||
| 43 | +} | ||
| 44 | + | ||
| 45 | +LOG_DO() | ||
| 46 | +{ | ||
| 47 | + echo "[LOG_DO] $*" | ||
| 48 | + "$@" | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +DP_ASSERT_EQUAL() | ||
| 52 | +{ | ||
| 53 | + local actual="$1" | ||
| 54 | + local expected="$2" | ||
| 55 | + local msg="$3" | ||
| 56 | + if [ "${actual}" != "${expected}" ]; then | ||
| 57 | + echo "::error::ASSERT FAILED: ${msg} (expected=${expected}, actual=${actual})" | ||
| 58 | + exit 1 | ||
| 59 | + fi | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | +if [[ "${task_name}" =~ Compile_Ascend_X86_ubuntu24 ]]; then | ||
| 63 | + sed -i "1i set(CMAKE_EXPORT_COMPILE_COMMANDS ON)" "CMakeLists.txt" | ||
| 64 | + echo "api-check=compile" >> "${ATOMGIT_OUTPUT}" | ||
| 65 | +else | ||
| 66 | + echo "api-check=continue" >> "${ATOMGIT_OUTPUT}" | ||
| 67 | +fi | ||
| 68 | + | ||
| 69 | +LOG_HEAD "Build ${REPOSITORY_NAME}." | ||
| 70 | +cd ${WORKSPACE}/ || exit 1 | ||
| 71 | +LOG_DO bash build.sh --pkg --soc=ascend950 | ||
| 72 | +DP_ASSERT_EQUAL "$?" "0" "exec cmd: [bash build.sh --pkg --soc=ascend950]" | ||
| 73 | +exit 0 | ||
| @@ -0,0 +1,68 @@ | |||
| 1 | +#!/bin/bash | ||
| 2 | +# ----------------------------------------------------------------------------------------------------------- | ||
| 3 | +# Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 4 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 5 | +# CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 6 | +# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 7 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 8 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 9 | +# See LICENSE in the root of the software repository for the full text of the License. | ||
| 10 | +# ----------------------------------------------------------------------------------------------------------- | ||
| 11 | + | ||
| 12 | +set -e | ||
| 13 | +set -o pipefail | ||
| 14 | + | ||
| 15 | +echo "ge_st_rt2: ${ge_st_rt2}" | ||
| 16 | +echo "GIT_TARGET_BRANCH: ${GIT_TARGET_BRANCH}" | ||
| 17 | +echo "ut_type: ${ut_type}" | ||
| 18 | + | ||
| 19 | +######## | ||
| 20 | +# Init # | ||
| 21 | +######## | ||
| 22 | + | ||
| 23 | +function LOG_HEAD() { | ||
| 24 | + local assert_msg=${1} | ||
| 25 | + date_time=$(date +%Y%m%d-%H%M%S) | ||
| 26 | + echo -e "[INFO] ${date_time} ${assert_msg}" | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +function LOG_DO() { | ||
| 30 | + local cmd="$*" | ||
| 31 | + date_time=$(date +%Y%m%d-%H%M%S) | ||
| 32 | + echo -e "[Command] ${date_time} ${cmd}" | ||
| 33 | + ${cmd} | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +function DP_ASSERT_EQUAL() { | ||
| 37 | + local actual_value=${1} | ||
| 38 | + local expect_value=${2} | ||
| 39 | + local assert_msg=${3} | ||
| 40 | + local log_flag=${4:-"true"} | ||
| 41 | + local log_path=${5} | ||
| 42 | + if [ "${actual_value}" != "${expect_value}" ]; then | ||
| 43 | + if [ -n "${log_path}" ] && [ -f "${log_path}" ]; then | ||
| 44 | + cat ${log_path} | ||
| 45 | + fi | ||
| 46 | + echo "${assert_msg} is failed." | ||
| 47 | + exit 1 | ||
| 48 | + else | ||
| 49 | + if [ "${log_flag}" = "true" ]; then | ||
| 50 | + echo "${assert_msg} is success." | ||
| 51 | + fi | ||
| 52 | + fi | ||
| 53 | +} | ||
| 54 | + | ||
| 55 | +REPOSITORY_NAME="ops-math" | ||
| 56 | + | ||
| 57 | +echo $(grep -E "^VERSION_ID=" /etc/os-release | cut -d'"' -f2) | ||
| 58 | +sudo update-alternatives --set gcc /usr/bin/gcc-14 | ||
| 59 | +gcc --version | ||
| 60 | +rm -rf /home/jenkins/opensource/json | ||
| 61 | +source /home/jenkins/Ascend/cann/bin/setenv.bash | ||
| 62 | +main(){ | ||
| 63 | + LOG_HEAD "Start run c++ testcase" | ||
| 64 | + LOG_DO sh build.sh --opkernel -u | ||
| 65 | + DP_ASSERT_EQUAL "$?" "0" "exec cmd: [sh build.sh -u --opkernel -u]" | ||
🟡 Medium Priority
对比 变更行: 建议:二选一:(1) 去掉 ![]() ![]() | |||
| 66 | +} | ||
| 67 | +main_param=$@ | ||
| 68 | +main $main_param | ||
🟡 Medium Priority
变更行: 建议:将 ![]() ![]() | |||
| @@ -0,0 +1,109 @@ | |||
| 1 | +name: compile_action | ||
| 2 | + | ||
| 3 | +on: | ||
| 4 | + workflow_call: | ||
| 5 | + inputs: | ||
| 6 | + task_name: | ||
| 7 | + required: true | ||
| 8 | + type: string | ||
| 9 | + image_version: | ||
| 10 | + required: true | ||
| 11 | + type: string | ||
| 12 | + ge_st_rt2: | ||
| 13 | + required: false | ||
| 14 | + type: string | ||
| 15 | + arch: | ||
| 16 | + required: false | ||
| 17 | + type: string | ||
| 18 | + default: 'x64' | ||
| 19 | + package_name: | ||
| 20 | + required: false | ||
| 21 | + type: string | ||
| 22 | + default: '' | ||
| 23 | + spec: | ||
| 24 | + required: false | ||
| 25 | + type: string | ||
| 26 | + default: 'xlarge' | ||
| 27 | + | ||
| 28 | +jobs: | ||
| 29 | + JOB_compile: | ||
| 30 | + name: Compile | ||
| 31 | + needs: [] | ||
| 32 | + steps: | ||
| 33 | + - | ||
| 34 | + name: Checkout | ||
| 35 | + identifier: process_checkout | ||
| 36 | + uses: checkout | ||
| 37 | + with: | ||
| 38 | + ref: ${{ atomgit.event.pull_request.merge_commit_sha }} | ||
🟡 Medium Priority
变更行: 建议:添加回退值: ![]() ![]() | |||
| 39 | + token: ${{ secrets.GIT_TOKEN }} | ||
| 40 | + - | ||
| 41 | + name: download | ||
| 42 | + uses: obs-download | ||
| 43 | + with: | ||
| 44 | + endpoint: "https://obs.cn-north-4.myhuaweicloud.com" | ||
| 45 | + bucket: "ascend-ci" | ||
| 46 | + access-key: ${{ secrets.AK }} | ||
| 47 | + secret-key: ${{ secrets.SK }} | ||
| 48 | + key: | | ||
| 49 | + ${{ env.obs_path }}/pr_filelist.txt | ||
| 50 | + ${{ env.obs_path }}/pr_filelist_mod.txt | ||
| 51 | + ${{ env.obs_path }}/update_file_detail.txt | ||
| 52 | + ${{ env.obs_path }}/compile.sh | ||
| 53 | + path: ${{ steps.process_checkout.outputs.path }} | ||
| 54 | + - | ||
| 55 | + name: compile_acc | ||
| 56 | + identifier: compile | ||
| 57 | + uses: build-accelerate | ||
| 58 | + with: | ||
| 59 | + command: | | ||
| 60 | + export WORKSPACE=${{ steps.process_checkout.outputs.path }} | ||
| 61 | + cd ${{ steps.process_checkout.outputs.path }} | ||
| 62 | + export task_name=${{ inputs.task_name }} | ||
| 63 | + export ge_st_rt2=${{ inputs.ge_st_rt2 }} | ||
| 64 | + export GIT_TARGET_BRANCH=${{ env.TARGET_BRANCH }} | ||
| 65 | + export OS_TYPE=${{ inputs.arch == 'arm64' && 'aarch64' || 'x86_64' }} | ||
| 66 | + echo "${ge_st_rt2}" | ||
| 67 | + BuildAccelerate bash compile.sh | ||
| 68 | + AC_SERVER_IP: ${{ vars.AC_SERVER_IP }} | ||
| 69 | + - | ||
| 70 | + name: rename_package | ||
| 71 | + if: ${{ inputs.package_name != '' }} | ||
| 72 | + run: | | ||
| 73 | + cd ${{ steps.process_checkout.outputs.path }} | ||
| 74 | + if [[ "${{ inputs.task_name }}" == *single* ]]; then | ||
| 75 | + mv ../single.tar.gz ${{ inputs.package_name }} | ||
| 76 | + echo "mv: ../single.tar.gz -> ${{ inputs.package_name }}" | ||
| 77 | + else | ||
| 78 | + cd ./build_out | ||
| 79 | + for f in *.run; do | ||
| 80 | + [ -f "$f" ] || continue | ||
| 81 | + [ "$f" = "${{ inputs.package_name }}" ] && continue | ||
| 82 | + mv "$f" "${{ inputs.package_name }}" | ||
| 83 | + echo "Renamed: $f -> ${{ inputs.package_name }}" | ||
| 84 | + break | ||
| 85 | + done | ||
| 86 | + fi | ||
| 87 | + - | ||
| 88 | + name: verify_package | ||
| 89 | + uses: cann/.gitcode/actions/verify-package@master | ||
| 90 | + with: | ||
| 91 | + workspace: ${{ steps.process_checkout.outputs.path }} | ||
| 92 | + - | ||
| 93 | + name: upload | ||
| 94 | + uses: obs-upload | ||
| 95 | + with: | ||
| 96 | + endpoint: "https://obs.cn-north-4.myhuaweicloud.com" | ||
| 97 | + bucket: "ascend-ci" | ||
| 98 | + access-key: ${{ secrets.AK }} | ||
| 99 | + secret-key: ${{ secrets.SK }} | ||
| 100 | + artifact-path: | | ||
| 101 | + ${{ steps.process_checkout.outputs.path }}/build_out/${{ inputs.package_name != '' && inputs.package_name || '*.tar.gz' }} | ||
| 102 | + object-prefix: ${{ env.obs_path }}/ | ||
| 103 | + if: "${{ default() }}" | ||
| 104 | + runs-on: | ||
| 105 | + - dedicate-hosted | ||
| 106 | + - ${{ inputs.arch }} | ||
| 107 | + - ${{ inputs.spec }} | ||
| 108 | + container: | ||
| 109 | + image: swr.cn-north-4.myhuaweicloud.com/ci_cann/${{ inputs.image_version }} | ||
| @@ -0,0 +1,78 @@ | |||
| 1 | +name: llt_action | ||
| 2 | + | ||
| 3 | +on: | ||
| 4 | + workflow_call: | ||
| 5 | + inputs: | ||
| 6 | + ut_type: | ||
| 7 | + required: true | ||
| 8 | + type: string | ||
| 9 | + ut_package: | ||
| 10 | + type: string | ||
| 11 | + default: 'ut_cov_*.tar.gz' | ||
| 12 | + ge_st_rt2: | ||
| 13 | + required: false | ||
| 14 | + type: string | ||
| 15 | + image_version: | ||
| 16 | + required: true | ||
| 17 | + type: string | ||
| 18 | + | ||
| 19 | +jobs: | ||
| 20 | + JOB_ut: | ||
| 21 | + name: UT | ||
| 22 | + steps: | ||
| 23 | + - | ||
| 24 | + name: Checkout | ||
| 25 | + identifier: process_checkout | ||
| 26 | + uses: checkout | ||
| 27 | + with: | ||
| 28 | + ref: ${{ atomgit.event.pull_request.merge_commit_sha }} | ||
🟡 Medium Priority 与 建议:添加回退值: ![]() ![]() | |||
| 29 | + token: ${{secrets.GIT_TOKEN}} | ||
| 30 | + - | ||
| 31 | + name: download | ||
| 32 | + uses: obs-download | ||
| 33 | + with: | ||
| 34 | + endpoint: "https://obs.cn-north-4.myhuaweicloud.com" | ||
| 35 | + bucket: "ascend-ci" | ||
| 36 | + key: | | ||
| 37 | + ${{ env.obs_path }}/pr_filelist.txt | ||
| 38 | + ${{ env.obs_path }}/pr_filelist_mod.txt | ||
| 39 | + ${{ env.obs_path }}/ut.sh | ||
| 40 | + path: ${{ steps.process_checkout.outputs.path }} | ||
| 41 | + - | ||
| 42 | + name: redis-cache | ||
| 43 | + uses: cann/.gitcode/actions/redis-cache@master | ||
| 44 | + - | ||
| 45 | + name: ut_acc | ||
| 46 | + identifier: ut | ||
| 47 | + run: | | ||
| 48 | + export WORKSPACE=${{ steps.process_checkout.outputs.path }} | ||
| 49 | + cd ${{ steps.process_checkout.outputs.path }} | ||
| 50 | + export ut_type=${{ inputs.ut_type }} | ||
| 51 | + export ge_st_rt2=${{ inputs.ge_st_rt2 }} | ||
| 52 | + export GIT_TARGET_BRANCH=${{ env.TARGET_BRANCH }} | ||
| 53 | + bash ut.sh | ||
| 54 | + - | ||
| 55 | + name: ut_cov | ||
| 56 | + identifier: ut_cov | ||
| 57 | + uses: cann/.gitcode/actions/ut-cov-report@master | ||
| 58 | + with: | ||
| 59 | + ut_process: ${{ steps.ut.outputs.ut_process }} | ||
🟡 Medium Priority
变更行: 建议:确认 ![]() ![]() | |||
| 60 | + workspace: ${{ steps.process_checkout.outputs.path }} | ||
| 61 | + ut_type: ${{ inputs.ut_type }} | ||
| 62 | + target_branch: ${{ env.TARGET_BRANCH }} | ||
| 63 | + git_token: ${{secrets.GIT_TOKEN}} | ||
| 64 | + - | ||
| 65 | + name: upload | ||
| 66 | + uses: obs-upload | ||
| 67 | + with: | ||
| 68 | + endpoint: "https://obs.cn-north-4.myhuaweicloud.com" | ||
| 69 | + bucket: "ascend-ci" | ||
| 70 | + access-key: ${{secrets.AK}} | ||
| 71 | + secret-key: ${{secrets.SK}} | ||
| 72 | + artifact-path: | | ||
| 73 | + ${{ steps.process_checkout.outputs.path }}/${{ inputs.ut_package }} | ||
| 74 | + object-prefix: ${{ env.obs_path }}/ | ||
| 75 | + if: "${{ default() }}" | ||
| 76 | + runs-on: [dedicate-hosted, x64, xlarge] | ||
| 77 | + container: | ||
| 78 | + image: swr.cn-north-4.myhuaweicloud.com/ci_cann/${{ inputs.image_version }} | ||
| @@ -0,0 +1,141 @@ | |||
| 1 | +name: PR-pipeline_ops-tensor | ||
| 2 | + | ||
| 3 | +concurrency: | ||
| 4 | + max: 5 | ||
| 5 | + exceed-action: QUEUE | ||
| 6 | + enable: true | ||
| 7 | + preemption: | ||
| 8 | + enable: true | ||
| 9 | + events: [mr_id] | ||
| 10 | + | ||
| 11 | +on: | ||
| 12 | + workflow_dispatch: | ||
| 13 | + pull_request_comment: | ||
| 14 | + types: [created] | ||
| 15 | + branches: [ '*' ] | ||
| 16 | + comments: [ '^(?:\/)?compile*' ] | ||
| 17 | + pr_comment: | ||
| 18 | + types: [ created ] | ||
| 19 | + keyword: '^(?:\/)?compile*' | ||
| 20 | + | ||
| 21 | +env: | ||
| 22 | + org_name: ${{ vars.ORG_NAME }} | ||
| 23 | + repo_name: "ops-tensor" | ||
| 24 | + MERGE_ID: ${{ atomgit.event.pull_request.number }} | ||
| 25 | + TARGET_BRANCH: ${{ atomgit.base_ref }} | ||
| 26 | + SOURCE_BRANCH: ${{ atomgit.head_ref }} | ||
| 27 | + obs_path: "${{ vars.OBS_PATH }}/${{ env.MERGE_ID }}" | ||
| 28 | + obs_smoke_path: "${{ env.obs_path }}/presmoke/2" | ||
🟡 Medium Priority
变更行: 建议:避免在 ![]() ![]() | |||
| 29 | + online: ${{ vars.APPLY_LABEL }} | ||
| 30 | + | ||
| 31 | +stages: | ||
| 32 | + stage1: | ||
| 33 | + name: PreBuild | ||
| 34 | + jobs: | ||
| 35 | + JOB_image: | ||
| 36 | + name: Test_image | ||
| 37 | + steps: | ||
| 38 | + - name: revise_image | ||
| 39 | + identifier: revise_image | ||
| 40 | + uses: cann/.gitcode/actions/revise-img@master | ||
| 41 | + with: | ||
| 42 | + repo_name: 'ops-tensor' | ||
| 43 | + target_branch: ${{ env.TARGET_BRANCH }} | ||
| 44 | + repo_url: ${{ vars.CI_PATH }} | ||
| 45 | + - | ||
| 46 | + name: show_output | ||
| 47 | + run: | | ||
| 48 | + echo "Compile_Ascend_X86: ${{ steps.revise_image.outputs.Compile_Ascend_X86 }}" | ||
| 49 | + if: "${{ default() }}" | ||
| 50 | + runs-on: [dedicate-hosted, x64, small] | ||
| 51 | + container: | ||
| 52 | + image: swr.cn-north-4.myhuaweicloud.com/ci_cann/ubuntu20.04.05_x86:k8s_v1.1006 | ||
| 53 | + JOB_pre: | ||
| 54 | + name: Test_PreBuild | ||
| 55 | + uses: cann/.gitcode/.gitcode/workflows/pre_action.yml@master | ||
| 56 | + pre: | ||
| 57 | + - type: auto | ||
| 58 | + fail-fast: true | ||
| 59 | + stage2: | ||
| 60 | + name: Compile | ||
| 61 | + jobs: | ||
| 62 | + JOB_x86_compile: | ||
| 63 | + name: Compile_x86 | ||
| 64 | + uses: .gitcode/workflows/compile_action.yml | ||
| 65 | + with: | ||
| 66 | + task_name: 'Compile_Ascend_X86' | ||
| 67 | + image_version: ${{ jobs.JOB_image.outputs.Compile_Ascend_X86 }} | ||
| 68 | + arch: 'x64' | ||
| 69 | + package_name: 'cann-ops-tensor_linux-x86_64.run' | ||
| 70 | + JOB_arm_compile: | ||
| 71 | + name: Compile_arm | ||
| 72 | + uses: .gitcode/workflows/compile_action.yml | ||
| 73 | + with: | ||
| 74 | + task_name: 'Compile_Ascend_ARM' | ||
| 75 | + image_version: ${{ jobs.JOB_image.outputs.Compile_Ascend_ARM }} | ||
| 76 | + arch: 'arm64' | ||
| 77 | + package_name: 'cann-ops-tensor_linux-aarch64.run' | ||
| 78 | + JOB_x86_compile_ubuntu24: | ||
| 79 | + name: Compile_x86_ubuntu24 | ||
| 80 | + uses: .gitcode/workflows/compile_action.yml | ||
| 81 | + with: | ||
| 82 | + task_name: 'Compile_Ascend_X86_ubuntu24' | ||
| 83 | + image_version: ${{ jobs.JOB_image.outputs.Compile_Ascend_X86 }} | ||
| 84 | + arch: 'x64' | ||
| 85 | + package_name: 'cann-ops-tensor_linux-x86_64_ubuntu24.run' | ||
| 86 | + JOB_arm_compile_ubuntu24: | ||
| 87 | + name: Compile_arm_ubuntu24 | ||
| 88 | + uses: .gitcode/workflows/compile_action.yml | ||
| 89 | + with: | ||
| 90 | + task_name: 'Compile_Ascend_ARM_ubuntu24' | ||
| 91 | + image_version: ${{ jobs.JOB_image.outputs.Compile_Ascend_ARM }} | ||
| 92 | + arch: 'arm64' | ||
| 93 | + package_name: 'cann-ops-tensor_linux-aarch64_ubuntu24.run' | ||
| 94 | + JOB_codecheck: | ||
| 95 | + name: CodeCheck | ||
| 96 | + uses: cann/.gitcode/.gitcode/workflows/codecheck_action.yml@master | ||
| 97 | + with: | ||
| 98 | + precommit_image_version: ${{ jobs.JOB_image.outputs.precommit }} | ||
| 99 | + codecheck_image_version: ${{ jobs.JOB_image.outputs.codecheck }} | ||
| 100 | + JOB_staticcheck_md_check: | ||
| 101 | + name: staticcheck_md_check | ||
| 102 | + uses: .gitcode/workflows/staticcheck_action.yml | ||
| 103 | + with: | ||
| 104 | + check_type: 'md_check' | ||
| 105 | + image_version: ${{ jobs.JOB_image.outputs.staticcheck }} | ||
| 106 | + pre: | ||
| 107 | + - type: auto | ||
| 108 | + fail-fast: false | ||
| 109 | + stage3: | ||
| 110 | + name: UT | ||
| 111 | + jobs: | ||
| 112 | + JOB_api_check: | ||
| 113 | + name: API_Check | ||
| 114 | + steps: | ||
| 115 | + - | ||
| 116 | + name: api-check | ||
| 117 | + identifier: api-check | ||
| 118 | + uses: cann/.gitcode/actions/api-check@master | ||
| 119 | + with: | ||
| 120 | + org_name: ${{ env.org_name }} | ||
| 121 | + mode: check | ||
| 122 | + repo_name: ${{ env.repo_name }} | ||
| 123 | + merge_id: ${{ env.MERGE_ID }} | ||
| 124 | + if: env.TARGET_BRANCH == 'master' | ||
| 125 | + runs-on: [dedicate-hosted, x64, small] | ||
| 126 | + container: | ||
| 127 | + image: swr.cn-north-4.myhuaweicloud.com/ci_cann/${{ jobs.JOB_image.outputs.API_Check }} | ||
| 128 | + JOB_UT_Test: | ||
| 129 | + name: UT_Test | ||
| 130 | + uses: .gitcode/workflows/llt_action.yml | ||
| 131 | + with: | ||
| 132 | + ut_type: 'UT_Test' | ||
| 133 | + image_version: ${{ jobs.JOB_image.outputs.UT_Test }} | ||
| 134 | + pre: | ||
| 135 | + - type: auto | ||
| 136 | + fail-fast: false | ||
| 137 | +post: | ||
| 138 | + jobs: | ||
| 139 | + job_post: | ||
| 140 | + name: Test_post | ||
| 141 | + uses: cann/.gitcode/.gitcode/workflows/post_action.yml@master | ||
| @@ -0,0 +1,66 @@ | |||||||
| 1 | +name: staticheck_action | ||||||
🟡 Medium Priority
变更行: 建议:将 workflow name 修正为 改动建议
![]() ![]() | |||||||
| 2 | + | ||||||
| 3 | +on: | ||||||
| 4 | + workflow_call: | ||||||
| 5 | + inputs: | ||||||
| 6 | + check_type: | ||||||
| 7 | + required: true | ||||||
| 8 | + type: string | ||||||
| 9 | + image_version: | ||||||
| 10 | + required: true | ||||||
| 11 | + type: string | ||||||
| 12 | + | ||||||
| 13 | +jobs: | ||||||
| 14 | + JOB_staticcheck: | ||||||
| 15 | + name: CodeCheck_staticcheck | ||||||
| 16 | + steps: | ||||||
| 17 | + - | ||||||
| 18 | + name: Checkout | ||||||
| 19 | + identifier: process_checkout | ||||||
| 20 | + uses: checkout | ||||||
| 21 | + with: | ||||||
| 22 | + ref: ${{ atomgit.event.pull_request.merge_commit_sha || atomgit.sha }} | ||||||
| 23 | + token: ${{secrets.GIT_TOKEN}} | ||||||
| 24 | + - | ||||||
| 25 | + name: download | ||||||
| 26 | + uses: obs-download | ||||||
| 27 | + with: | ||||||
| 28 | + endpoint: "https://obs.cn-north-4.myhuaweicloud.com" | ||||||
| 29 | + bucket: "ascend-ci" | ||||||
| 30 | + access-key: ${{ secrets.AK }} | ||||||
| 31 | + secret-key: ${{ secrets.SK }} | ||||||
| 32 | + key: | | ||||||
| 33 | + ${{ env.obs_path }}/pr_filelist.txt | ||||||
| 34 | + ${{ env.obs_path }}/pr_filelist_mod.txt | ||||||
| 35 | + ${{ env.obs_path }}/update_file_detail.txt | ||||||
| 36 | + ${{ env.obs_path }}/gitdiff.txt | ||||||
| 37 | + path: ${{ steps.process_checkout.outputs.path }} | ||||||
| 38 | + - | ||||||
| 39 | + name: staticcheck | ||||||
| 40 | + identifier: staticcheck | ||||||
| 41 | + uses: cann/.gitcode/actions/staticcheck@master | ||||||
| 42 | + with: | ||||||
| 43 | + check_type: ${{ inputs.check_type }} | ||||||
| 44 | + target_branch: ${{ env.TARGET_BRANCH }} | ||||||
| 45 | + repo_name: ${{ env.repo_name }} | ||||||
| 46 | + merge_id: ${{ env.MERGE_ID }} | ||||||
| 47 | + commit_id: '0' | ||||||
| 48 | + workspace: ${{ steps.process_checkout.outputs.path }} | ||||||
| 49 | + org_name: ${{ env.org_name }} | ||||||
| 50 | + - | ||||||
| 51 | + name: upload | ||||||
| 52 | + if: ${{ always() }} | ||||||
| 53 | + uses: obs-upload | ||||||
| 54 | + with: | ||||||
| 55 | + endpoint: "https://obs.cn-north-4.myhuaweicloud.com" | ||||||
| 56 | + bucket: "ascend-ci" | ||||||
| 57 | + access-key: ${{secrets.AK}} | ||||||
| 58 | + secret-key: ${{secrets.SK}} | ||||||
| 59 | + artifact-path: | | ||||||
| 60 | + ${{ steps.process_checkout.outputs.path }}/*.csv | ||||||
| 61 | + ${{ steps.process_checkout.outputs.path }}/StaticCheck_*.json | ||||||
| 62 | + object-prefix: ${{ env.obs_path }}/ | ||||||
| 63 | + if: "${{ default() }}" | ||||||
| 64 | + runs-on: [dedicate-hosted, x64, small] | ||||||
| 65 | + container: | ||||||
| 66 | + image: swr.cn-north-4.myhuaweicloud.com/static_check/${{ inputs.image_version }} | ||||||


🟡 Medium Priority
ut.sh第 29-34 行的LOG_DO函数将参数拼接为字符串cmd="$*"然后执行${cmd}(未加引号)。这会经过 shell 的单词拆分和 glob 展开,如果命令参数中含有空格、特殊字符或 glob 模式,命令行为将不可预期。对比
compile.sh第 45-49 行的LOG_DO使用"$@"正确保留了参数结构。变更行:
ut.sh:33—${cmd}失败模式:当构建命令参数含空格或特殊字符时,命令会被错误拆分执行,可能导致构建失败或意外行为。建议:使用
eval "${cmd}"或改为与 compile.sh 一致的"$@"模式来正确执行带参数的命令。