-
Notifications
You must be signed in to change notification settings - Fork 27
108 lines (96 loc) · 3.69 KB
/
Copy pathtest-full.yml
File metadata and controls
108 lines (96 loc) · 3.69 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
102
103
104
105
106
107
108
# Validate Speakeasy Generation (Dry Run) + Zero-Diff Check
#
# This workflow validates that Speakeasy generation can complete successfully
# and that the committed generated code matches what the generation pipeline produces.
#
# Jobs:
# 1. validate: Runs the full generation pipeline in dry-run mode
# 2. zero-diff: Checks for drift using the validate job's outputs (in-place git status).
# If drift is detected, the check fails and posts a comment telling the author to run /generate.
#
# This workflow calls the main generation workflow with dry_run=true to ensure
# both workflows use the same generation logic.
#
# Note: paths-ignore is NOT used at the workflow level because GitHub treats a
# workflow that never runs as "expected" (pending), which blocks required checks.
# Instead, we filter paths at the job level so skipped jobs report as "skipped"
# (equivalent to "passed" for required checks).
name: Test (Full)
on:
pull_request:
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
check-paths:
name: Check Changed Paths
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Filter changed paths
uses: dorny/paths-filter@v4
id: filter
with:
filters: |
generation:
- '**'
- '!README.md'
- '!docs/**'
outputs:
should_run: ${{ github.event_name == 'workflow_dispatch' || steps.filter.outputs.generation == 'true' }}
validate:
name: Validate Generation (Dry Run)
needs: check-paths
if: needs.check-paths.outputs.should_run == 'true'
uses: ./.github/workflows/generate-command.yml
with:
dry_run: true
secrets: inherit
zero-diff:
name: Zero-Diff Check (Generated Code)
needs: [check-paths, validate]
if: needs.check-paths.outputs.should_run == 'true' && github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Check for generation drift
id: drift-check
run: |
if [ "${{ needs.validate.outputs.has_changes }}" = "true" ]; then
echo "has_diff=true" >> $GITHUB_OUTPUT
echo "::warning::Generated code drift detected. The committed code does not match what the generation pipeline produces."
else
echo "has_diff=false" >> $GITHUB_OUTPUT
echo "Zero-diff check passed. Committed code matches generation output."
fi
- name: Find existing drift comment
if: steps.drift-check.outputs.has_diff == 'true'
uses: peter-evans/find-comment@v3
id: find-drift-comment
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: '<!-- zero-diff-check -->'
- name: Post drift comment on PR
if: steps.drift-check.outputs.has_diff == 'true'
uses: peter-evans/create-or-update-comment@v5
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-drift-comment.outputs.comment-id || '' }}
edit-mode: replace
body: |
<!-- zero-diff-check -->
**Generated Code Drift Detected**
The committed code does not match what the generation pipeline produces.
**To fix:** Comment `/generate` on this PR to regenerate.
```
${{ needs.validate.outputs.drift_summary }}
```
- name: Fail if drift detected
if: steps.drift-check.outputs.has_diff == 'true'
run: |
echo "::error::Generated code drift detected. Run /generate on this PR to fix."
exit 1