已开启
test: validate PR pipeline checks #4
BOCHENGZHANG创建于 9月11日
test: validate PR pipeline checks #4
已开启
共 3 个文件变更+58-7
| @@ -9,10 +9,17 @@ concurrency: | |||
| 9 | events: [mr_id] | 9 | events: [mr_id] |
| 10 | 10 | ||
| 11 | on: | 11 | on: |
| 12 | + pr_comment: | ||
| 13 | + types: [created] | ||
| 14 | + keyword: '^(?:/)?compile*' | ||
| 12 | pull_request_comment: | 15 | pull_request_comment: |
| 13 | types: [created] | 16 | types: [created] |
| 14 | - branches: ['master', '26.1.0'] | 17 | + branches: ['*'] |
| 15 | - comments: ['^compile$'] | 18 | + comments: ['^(?:/)?compile*'] |
| 19 | + | ||
| 20 | +permissions: | ||
| 21 | + repository: read | ||
| 22 | + id-token: write | ||
| 16 | 23 | ||
| 17 | env: | 24 | env: |
| 18 | TARGET_BRANCH: ${{ atomgit.base_ref || 'master' }} | 25 | TARGET_BRANCH: ${{ atomgit.base_ref || 'master' }} |
| @@ -23,6 +30,37 @@ stages: | |||
| 23 | name: CodeCheck | 30 | name: CodeCheck |
| 24 | select: selected_by_default | 31 | select: selected_by_default |
| 25 | jobs: | 32 | jobs: |
| 33 | + SCA: | ||
| 34 | + name: SCA | ||
| 35 | + runs-on: [self-hosted, x86, cpu=32] | ||
| 36 | + steps: | ||
| 37 | + - name: checkout | ||
| 38 | + uses: checkout | ||
| 39 | + with: | ||
| 40 | + allow-unsafe-pr-checkout: true | ||
| 41 | + ref: refs/merge-requests/${{ env.pr_id }}/merge | ||
| 42 | + - name: run SCA PR scan | ||
| 43 | + uses: openlibing/sca-action/sca-pr-action@v1.0.0 | ||
| 44 | + with: | ||
| 45 | + project-name: MindSpeed | ||
| 46 | + | ||
| 47 | + Antipoison: | ||
| 48 | + name: Antipoison | ||
| 49 | + runs-on: [self-hosted, x86, cpu=32] | ||
| 50 | + steps: | ||
| 51 | + - name: checkout | ||
| 52 | + uses: checkout | ||
| 53 | + with: | ||
| 54 | + allow-unsafe-pr-checkout: true | ||
| 55 | + ref: refs/merge-requests/${{ env.pr_id }}/merge | ||
| 56 | + - name: run malicious code scan | ||
| 57 | + uses: openlibing/malicious-code-scan-action/malicious-code-pr-scan-action@v1.0.0 | ||
| 58 | + with: | ||
| 59 | + repository-name: ${{ atomgit.repository }} | ||
| 60 | + pr-id: ${{ env.pr_id }} | ||
| 61 | + project-name: MindSpeed | ||
| 62 | + rule: Python | ||
| 63 | + | ||
| 26 | CodeCheck_pre_commit: | 64 | CodeCheck_pre_commit: |
| 27 | name: CodeCheck_pre_commit | 65 | name: CodeCheck_pre_commit |
| 28 | runs-on: [self-hosted, x86, cpu=32] | 66 | runs-on: [self-hosted, x86, cpu=32] |
| @@ -32,18 +70,24 @@ stages: | |||
| 32 | - name: checkout | 70 | - name: checkout |
| 33 | uses: checkout | 71 | uses: checkout |
| 34 | with: | 72 | with: |
| 73 | + allow-unsafe-pr-checkout: true | ||
| 35 | ref: refs/merge-requests/${{ env.pr_id }}/merge | 74 | ref: refs/merge-requests/${{ env.pr_id }}/merge |
| 36 | - - name: setup-python310 | 75 | + - name: setup-python311 |
| 37 | - uses: setup-python | 76 | + run: | |
| 38 | - with: | 77 | + set -eu |
| 39 | - python-version: "3.10.20" | 78 | + PYTHON311_BIN=$(dirname "$(command -v python3.11)") |
| 79 | + ln -sf "$(command -v python3.11)" "$PYTHON311_BIN/python" | ||
| 80 | + echo "$PYTHON311_BIN" >> "$ATOMGIT_PATH" | ||
| 81 | + "$PYTHON311_BIN/python" --version | ||
| 40 | - name: install gitleaks | 82 | - name: install gitleaks |
| 41 | run: | | 83 | run: | |
| 84 | + set -eu | ||
| 42 | cd "${ATOMGIT_WORKSPACE}" | 85 | cd "${ATOMGIT_WORKSPACE}" |
| 43 | wget --no-host-directories -c --no-check-certificate https://pytorch-package.obs.cn-north-4.myhuaweicloud.com/pta-codecheck/gitleaks | 86 | wget --no-host-directories -c --no-check-certificate https://pytorch-package.obs.cn-north-4.myhuaweicloud.com/pta-codecheck/gitleaks |
| 44 | chmod +x gitleaks | 87 | chmod +x gitleaks |
| 88 | + cd - | ||
| 45 | - name: pre-commit | 89 | - name: pre-commit |
| 46 | - uses: openlibing-pre-commit-action | 90 | + uses: openlibing/pre-commit-action@v1.0.0 |
| 47 | 91 | ||
| 48 | Detect_file_changes: | 92 | Detect_file_changes: |
| 49 | name: Detect_file_changes | 93 | name: Detect_file_changes |
| @@ -56,6 +100,7 @@ stages: | |||
| 56 | - name: checkout | 100 | - name: checkout |
| 57 | uses: checkout | 101 | uses: checkout |
| 58 | with: | 102 | with: |
| 103 | + allow-unsafe-pr-checkout: true | ||
| 59 | ref: refs/merge-requests/${{ env.pr_id }}/merge | 104 | ref: refs/merge-requests/${{ env.pr_id }}/merge |
| 60 | fetch-depth: 0 | 105 | fetch-depth: 0 |
| 61 | - name: Only_doc_commit | 106 | - name: Only_doc_commit |
| @@ -107,6 +152,7 @@ stages: | |||
| 107 | - name: checkout | 152 | - name: checkout |
| 108 | uses: checkout | 153 | uses: checkout |
| 109 | with: | 154 | with: |
| 155 | + allow-unsafe-pr-checkout: true | ||
| 110 | ref: refs/merge-requests/${{ env.pr_id }}/merge | 156 | ref: refs/merge-requests/${{ env.pr_id }}/merge |
| 111 | path: CODE | 157 | path: CODE |
| 112 | fetch-depth: 0 | 158 | fetch-depth: 0 |
| @@ -126,6 +172,7 @@ stages: | |||
| 126 | - name: checkout | 172 | - name: checkout |
| 127 | uses: checkout | 173 | uses: checkout |
| 128 | with: | 174 | with: |
| 175 | + allow-unsafe-pr-checkout: true | ||
| 129 | ref: refs/merge-requests/${{ env.pr_id }}/merge | 176 | ref: refs/merge-requests/${{ env.pr_id }}/merge |
| 130 | path: CODE | 177 | path: CODE |
| 131 | fetch-depth: 0 | 178 | fetch-depth: 0 |
| @@ -145,6 +192,7 @@ stages: | |||
| 145 | - name: checkout | 192 | - name: checkout |
| 146 | uses: checkout | 193 | uses: checkout |
| 147 | with: | 194 | with: |
| 195 | + allow-unsafe-pr-checkout: true | ||
| 148 | ref: refs/merge-requests/${{ env.pr_id }}/merge | 196 | ref: refs/merge-requests/${{ env.pr_id }}/merge |
| 149 | path: CODE | 197 | path: CODE |
| 150 | fetch-depth: 0 | 198 | fetch-depth: 0 |
| @@ -164,6 +212,7 @@ stages: | |||
| 164 | - name: checkout | 212 | - name: checkout |
| 165 | uses: checkout | 213 | uses: checkout |
| 166 | with: | 214 | with: |
| 215 | + allow-unsafe-pr-checkout: true | ||
| 167 | ref: refs/merge-requests/${{ env.pr_id }}/merge | 216 | ref: refs/merge-requests/${{ env.pr_id }}/merge |
| 168 | path: CODE | 217 | path: CODE |
| 169 | fetch-depth: 0 | 218 | fetch-depth: 0 |
| @@ -5,6 +5,7 @@ import argparse | |||
| 5 | 5 | ||
| 6 | 6 | ||
| 7 | def read_files_from_txt(txt_file): | 7 | def read_files_from_txt(txt_file): |
| 8 | + # Branch-only marker for validating SCA and Antipoison PR checks. | ||
| 8 | with open(txt_file, "r", encoding='utf-8') as f: | 9 | with open(txt_file, "r", encoding='utf-8') as f: |
| 9 | return [line.strip() for line in f.readlines()] | 10 | return [line.strip() for line in f.readlines()] |
| 10 | 11 | ||