-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
153 lines (145 loc) · 5.3 KB
/
Copy pathaction.yml
File metadata and controls
153 lines (145 loc) · 5.3 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: "RuleProbe: Detect Config Drift"
description: >
Detect drift between instruction files (CLAUDE.md, AGENTS.md, .cursorrules)
and ESLint config on every PR. Posts results as a PR comment and optionally
opens a follow-up PR with the regenerated config. Deterministic checks,
no LLM calls, no API keys beyond GITHUB_TOKEN.
branding:
icon: check-circle
color: blue
inputs:
mode:
description: "Run mode: drift (default) or verify (legacy)"
required: false
default: "drift"
instruction-file:
description: "Path to instruction file (CLAUDE.md, AGENTS.md, .cursorrules, etc)"
required: true
eslint-file:
description: "Path to ESLint config (auto-detected if not specified)"
required: false
regenerate-on-drift:
description: "Open a follow-up PR with regenerated config when drift is detected"
required: false
default: "false"
comment-on-pr:
description: "Post drift results as a PR comment"
required: false
default: "true"
fail-on-drift:
description: "Fail the action if drift is detected"
required: false
default: "false"
# Legacy verify-mode inputs
output-dir:
description: "Directory containing code to verify (verify mode only)"
required: false
default: "src"
agent:
description: "Agent identifier for the report (verify mode only)"
required: false
default: "ci"
model:
description: "Model identifier for the report (verify mode only)"
required: false
default: "unknown"
format:
description: "Report format: text, json, or markdown"
required: false
default: "text"
severity:
description: "Minimum severity to report (verify mode only)"
required: false
default: "all"
fail-on-violation:
description: "Fail the action if any violations are found (verify mode only)"
required: false
default: "true"
reviewdog-format:
description: "Also output in reviewdog rdjson format (verify mode only)"
required: false
default: "false"
post-comment:
description: "Post results as a PR comment (verify mode only)"
required: false
default: "true"
changed-since:
description: "Only verify files changed relative to the given git ref (verify mode only)"
required: false
outputs:
drift-count:
description: "Number of drift issues detected"
value: ${{ steps.drift.outputs.drift-count }}
has-drift:
description: "Whether drift was detected"
value: ${{ steps.drift.outputs.has-drift }}
# Legacy verify outputs
score:
description: "Adherence score as a percentage (verify mode only)"
value: ${{ steps.verify.outputs.score }}
passed:
description: "Number of rules that passed (verify mode only)"
value: ${{ steps.verify.outputs.passed }}
failed:
description: "Number of rules that failed (verify mode only)"
value: ${{ steps.verify.outputs.failed }}
total:
description: "Total number of rules checked (verify mode only)"
value: ${{ steps.verify.outputs.total }}
runs:
using: "composite"
steps:
- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: "22"
- name: Install ruleprobe
shell: bash
run: |
cd "${{ github.action_path }}"
npm ci --ignore-scripts
npm run build
- name: Run drift detection
if: inputs.mode != 'verify'
id: drift
shell: bash
env:
INPUT_MODE: ${{ inputs.mode }}
INPUT_INSTRUCTION_FILE: ${{ inputs.instruction-file }}
INPUT_ESLINT_FILE: ${{ inputs.eslint-file }}
INPUT_REGENERATE_ON_DRIFT: ${{ inputs.regenerate-on-drift }}
INPUT_COMMENT_ON_PR: ${{ inputs.comment-on-pr }}
INPUT_FAIL_ON_DRIFT: ${{ inputs.fail-on-drift }}
GITHUB_TOKEN: ${{ github.token }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_API_URL: ${{ github.api_url }}
GITHUB_EVENT_PATH: ${{ github.event_path }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_WORKSPACE: ${{ github.workspace }}
GITHUB_OUTPUT: ${{ github.output_file }}
RULEPROBE_BIN: ${{ github.action_path }}/dist/cli.js
run: node "${{ github.action_path }}/dist/action/main.js"
- name: Run ruleprobe verify
if: inputs.mode == 'verify'
id: verify
shell: bash
env:
INPUT_INSTRUCTION_FILE: ${{ inputs.instruction-file }}
INPUT_OUTPUT_DIR: ${{ inputs.output-dir }}
INPUT_AGENT: ${{ inputs.agent }}
INPUT_MODEL: ${{ inputs.model }}
INPUT_FORMAT: ${{ inputs.format }}
INPUT_SEVERITY: ${{ inputs.severity }}
INPUT_FAIL_ON_VIOLATION: ${{ inputs.fail-on-violation }}
INPUT_REVIEWDOG_FORMAT: ${{ inputs.reviewdog-format }}
INPUT_CHANGED_SINCE: ${{ inputs.changed-since }}
RULEPROBE_BIN: ${{ github.action_path }}/dist/cli.js
run: bash "${{ github.action_path }}/action-scripts/run-verify.sh"
- name: Post PR comment (verify mode)
if: inputs.mode == 'verify' && inputs.post-comment == 'true' && github.event_name == 'pull_request'
shell: bash
env:
GITHUB_TOKEN: ${{ github.token }}
INPUT_FAIL_ON_VIOLATION: ${{ inputs.fail-on-violation }}
RULEPROBE_REPORT_FILE: ${{ github.workspace }}/.ruleprobe-report.txt
run: bash "${{ github.action_path }}/action-scripts/post-comment.sh"