已合并
action上线适配 #375
cui_jiahao创建于 24 天前
action上线适配 #375
已合并
cui_jiahao创建于 24 天前
4 个文件变更+387-0
@@ -0,0 +1,81 @@
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+rm -rf /opt/rh/devtoolset-7
69+LOG_HEAD "Build ${REPOSITORY_NAME}."
70+cd ${WORKSPACE}/ || exit 1
71+if [[ "${task_name}" =~ .*910c.* ]];then
72+ LOG_DO bash .ci/build.sh dav-2201
73+ DP_ASSERT_EQUAL "$?" "0" "exec cmd: [.ci/build.sh dav-2201]"
74+elif [[ "${task_name}" =~ .*950.* ]];then
75+ LOG_DO bash .ci/build.sh dav-3510
76+ DP_ASSERT_EQUAL "$?" "0" "exec cmd: [bash .ci/build.sh dav-3510]"
77+else
78+ LOG_DO bash .ci/build.sh dav-2201
79+ DP_ASSERT_EQUAL "$?" "0" "exec cmd: [bash .ci/build.sh dav-2201]"
80+fi
81+exit 0
@@ -0,0 +1,129 @@
1+name: PR-pipeline_cann-samples
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: "cann-samples"
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"
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: 'cann-samples'
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
atomgit-bot
atomgit-botatomgit-bot24 天前

🟠 High Priority

第 55 行 uses: cann/.gitcode/.gitcode/workflows/pre_action.yml@master 路径中出现了 .gitcode/.gitcode/ 重复。正确路径应为 cann/.gitcode/workflows/pre_action.yml@master。此错误会导致 workflow 无法解析该引用,JOB_pre 任务失败。

建议:移除重复的 .gitcode/,改为 cann/.gitcode/workflows/pre_action.yml@master

改动建议
55
- uses: cann/.gitcode/.gitcode/workflows/pre_action.yml@master
55
+ uses: cann/.gitcode/workflows/pre_action.yml@master
应用建议
likedislike
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_ubuntu24 }}
68+ arch: 'x64'
69+ package_name: 'cann-samples_linux-x86_64.zip'
70+ JOB_x86_compile_910c:
71+ name: Compile_x86_910c
72+ uses: .gitcode/workflows/compile_action.yml
73+ with:
74+ task_name: 'Compile_Ascend_X86_910c'
75+ image_version: ${{ jobs.JOB_image.outputs.Compile_Ascend_X86_910c_ubuntu24 }}
76+ arch: 'x64'
77+ package_name: 'cann-samples_910c_linux-x86_64.zip'
78+ JOB_x86_compile_950:
79+ name: Compile_x86_950
80+ uses: .gitcode/workflows/compile_action.yml
81+ with:
82+ task_name: 'Compile_Ascend_X86_950'
83+ image_version: ${{ jobs.JOB_image.outputs.Compile_Ascend_X86_950_ubuntu24 }}
84+ arch: 'x64'
85+ package_name: 'cann-samples_950_linux-x86_64.zip'
86+ JOB_arm_compile:
87+ name: Compile_arm
88+ uses: .gitcode/workflows/compile_action.yml
89+ with:
90+ task_name: 'Compile_Ascend_ARM'
91+ image_version: ${{ jobs.JOB_image.outputs.Compile_Ascend_ARM_ubuntu24 }}
92+ arch: 'arm64'
93+ package_name: 'cann-samples_linux-aarch64.zip'
94+ JOB_arm_compile_910c:
95+ name: Compile_arm_910c
96+ uses: .gitcode/workflows/compile_action.yml
97+ with:
98+ task_name: 'Compile_Ascend_ARM_910c'
99+ image_version: ${{ jobs.JOB_image.outputs.Compile_Ascend_ARM_910c_ubuntu24 }}
100+ arch: 'arm64'
101+ package_name: 'cann-samples_910c_linux-aarch64.zip'
102+ JOB_arm_compile_950:
103+ name: Compile_arm_950
104+ uses: .gitcode/workflows/compile_action.yml
105+ with:
106+ task_name: 'Compile_Ascend_ARM_950'
107+ image_version: ${{ jobs.JOB_image.outputs.Compile_Ascend_ARM_950_ubuntu24 }}
108+ arch: 'arm64'
109+ package_name: 'cann-samples_950_linux-aarch64.zip'
110+ JOB_codecheck:
111+ name: CodeCheck
112+ uses: cann/.gitcode/.gitcode/workflows/codecheck_action.yml@master
113+ with:
114+ precommit_image_version: ${{ jobs.JOB_image.outputs.precommit }}
115+ codecheck_image_version: ${{ jobs.JOB_image.outputs.codecheck }}
116+ JOB_staticcheck_md_check:
117+ name: staticcheck_md_check
118+ uses: .gitcode/workflows/staticcheck_action.yml
119+ with:
120+ check_type: 'md_check'
121+ image_version: ${{ jobs.JOB_image.outputs.staticcheck }}
122+ pre:
123+ - type: auto
124+ fail-fast: false
125+post:
126+ jobs:
127+ job_post:
128+ name: Test_post
129+ uses: cann/.gitcode/.gitcode/workflows/post_action.yml@master
atomgit-bot
atomgit-botatomgit-bot24 天前

🟠 High Priority

第 129 行 uses: cann/.gitcode/.gitcode/workflows/post_action.yml@master 路径中出现了 .gitcode/.gitcode/ 重复。正确路径应为 cann/.gitcode/workflows/post_action.yml@master。此错误会导致 post 阶段的 job_post 任务失败。

建议:移除重复的 .gitcode/,改为 cann/.gitcode/workflows/post_action.yml@master

改动建议
129
- uses: cann/.gitcode/.gitcode/workflows/post_action.yml@master
129
+ uses: cann/.gitcode/workflows/post_action.yml@master
应用建议
likedislike
@@ -0,0 +1,111 @@
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 }}
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+ for f in *.zip; do
75+ [ -f "$f" ] || continue
76+ [ "$f" = "${{ inputs.package_name }}" ] && continue
77+ mv "$f" "${{ inputs.package_name }}"
78+ echo "Renamed: $f -> ${{ inputs.package_name }}"
79+ break
80+ done
81+ -
82+ name: api-check
83+ identifier: api-check
84+ if: ${{ inputs.task_name == 'Compile_Ascend_X86' }}
85+ uses: cann/.gitcode/actions/api-check@master
86+ with:
87+ org_name: ${{ env.org_name }}
88+ mode: ${{ steps.compile.outputs.api-check }}
89+ repo_name: ${{ env.repo_name }}
90+ merge_id: ${{ env.MERGE_ID }}
91+ workspace: ${{ steps.process_checkout.outputs.path }}
92+ source_branch: ${{ env.SOURCE_BRANCH }}
93+ target_branch: ${{ env.TARGET_BRANCH }}
94+ -
95+ name: upload
96+ uses: obs-upload
97+ with:
98+ endpoint: "https://obs.cn-north-4.myhuaweicloud.com"
99+ bucket: "ascend-ci"
100+ access-key: ${{ secrets.AK }}
101+ secret-key: ${{ secrets.SK }}
102+ artifact-path: |
103+ ${{ steps.process_checkout.outputs.path }}/${{ inputs.package_name != '' && inputs.package_name || '*.zip' }}
104+ object-prefix: ${{ env.obs_path }}/
105+ if: "${{ default() }}"
106+ runs-on:
107+ - dedicate-hosted
108+ - ${{ inputs.arch }}
109+ - ${{ inputs.spec }}
110+ container:
111+ image: swr.cn-north-4.myhuaweicloud.com/ci_cann/${{ inputs.image_version }}
@@ -0,0 +1,66 @@
1+name: staticheck_action
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'
atomgit-bot
atomgit-botatomgit-bot24 天前

🟡 Medium Priority

第 46 行 commit_id: '0' 将 commit_id 硬编码为字符串 '0',而非使用实际的 PR merge commit SHA。与其他 workflow 中使用 ${{ atomgit.event.pull_request.merge_commit_sha }} 的做法不一致。这会导致 staticcheck 动作无法正确定位需要检查的代码变更范围,可能对所有提交返回全量扫描结果或产生错误的 diff 基线。

建议:将 commit_id 改为实际的 PR merge commit SHA:${{ atomgit.event.pull_request.merge_commit_sha }}

likedislike
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 }}