Repository navigation
63 lines (58 loc) · 2.57 KB
/
Copy pathcode-analyzer.yml
File metadata and controls
63 lines (58 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: 'Code Analyzer PR Review'
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
pull_request_review:
types: [submitted]
workflow_dispatch:
inputs:
pr-number:
description: 'PR number to analyze'
required: true
# **The write scopes are on the job that writes.** `analyze` posts the review comment, opens check runs and files
# issues; `summary` reads a job result and prints one line. The workflow-level grant used to hand all three writes to
# both, which is a wider grant than any single job asks for.
permissions:
contents: read
jobs:
analyze:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: write
checks: write
# Skip for draft PRs and only run on approved review submissions
if: |
(github.event_name != 'pull_request' || github.event.pull_request.draft == false) &&
(github.event_name != 'pull_request_review' || github.event.review.state == 'approved')
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: ./.github/actions/code-analyzer-action
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
summary:
runs-on: ubuntu-latest
needs: analyze
if: always()
# **No token at all.** This job reads `needs.analyze.result` and prints a line; an empty permission map is what says
# so, and it fails loudly if a step is ever added here that expects one.
permissions: {}
steps:
- name: Check Analysis Status
#
# **A failed review is reported, not enforced.** The action runs advisory (`fail-on: off`) because iteration 110
# measured the reviewer's precision at 0.04 behind the competitor with 45 % of findings false, and the first
# pull request it ran on produced 44 critical findings that were all test fixtures. Failing the job here would
# have turned that precision gap into a blocked merge, and this step would have been deleted within a week.
# A hard failure now means the analysis could not run at all, which is what `failure` still has to say.
#
run: |
if [ "${{ needs.analyze.result }}" == "success" ]; then
echo "Code Analyzer review completed; findings are on the pull request."
elif [ "${{ needs.analyze.result }}" == "failure" ]; then
echo "::error::Code Analyzer could not complete. Check the analyze job for a build or configuration failure."
exit 1
else
echo "Code Analyzer review was skipped or cancelled"
fi