-
Notifications
You must be signed in to change notification settings - Fork 39
101 lines (92 loc) · 3.07 KB
/
Copy pathdiffguard.yml
File metadata and controls
101 lines (92 loc) · 3.07 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: diffguard
on:
pull_request:
branches:
- '**'
types: [opened, synchronize, reopened]
jobs:
diffguard:
name: Quality metrics
runs-on: ubuntu-latest
timeout-minutes: 20
concurrency:
group: diffguard-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: read
steps:
- uses: actions/checkout@v6
with:
# diffguard needs full history for merge-base and file history checks.
fetch-depth: 0
- name: Fetch base branch ref
env:
BASE_REF: ${{ github.base_ref }}
run: git fetch --no-tags origin "refs/heads/$BASE_REF:refs/remotes/origin/$BASE_REF"
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-diffguard-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-diffguard-
- name: Install diffguard
run: go install github.com/0xPolygon/diffguard/cmd/diffguard@527d7fd753dce9312cd8a16d71cea1c30c2f2396
- name: Run diffguard
id: diffguard
shell: bash
env:
BASE_REF: ${{ github.base_ref }}
run: |
# Keep diffguard's exit code when tee writes the step summary.
set -o pipefail
diffguard \
--base "origin/$BASE_REF" \
--complexity-threshold 15 \
--complexity-delta-tolerance 5 \
--function-size-threshold 80 \
--function-size-delta-tolerance 15 \
--file-size-threshold 800 \
--file-size-delta-tolerance-pct 10 \
--file-size-delta-tolerance-floor 20 \
--tier1-threshold 80 \
--tier2-threshold 60 \
--mutation-sample-rate 100 \
--test-timeout 5m \
--output text \
--fail-on all \
. | tee "$GITHUB_STEP_SUMMARY"
- name: Upload JSON report
# The text report above contains mutation results; this second run is
# only for a cheap machine-readable shape report.
if: always()
continue-on-error: true
env:
BASE_REF: ${{ github.base_ref }}
run: |
diffguard \
--base "origin/$BASE_REF" \
--complexity-threshold 15 \
--complexity-delta-tolerance 5 \
--function-size-threshold 80 \
--function-size-delta-tolerance 15 \
--file-size-threshold 800 \
--file-size-delta-tolerance-pct 10 \
--file-size-delta-tolerance-floor 20 \
--tier1-threshold 80 \
--tier2-threshold 60 \
--skip-mutation \
--output json \
--fail-on none \
. > diffguard-report.json
- uses: actions/upload-artifact@v6
if: always()
continue-on-error: true
with:
name: diffguard-report
path: diffguard-report.json
retention-days: 14
if-no-files-found: ignore