Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
215 lines (200 loc) · 6.87 KB
/
Copy pathaction.yml
File metadata and controls
215 lines (200 loc) · 6.87 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: "lintdiff"
description: "Filter Rust diagnostics to lines changed in a PR and post annotations."
branding:
icon: "check-circle"
color: "orange"
inputs:
base:
description: "Base ref for diff (default: auto-detect from PR context)"
required: false
head:
description: "Head ref for diff (default: auto-detect from PR context)"
required: false
config:
description: "Path to lintdiff.toml config file"
required: false
fail_on:
description: "Override fail_on policy (error, warn, never)"
required: false
diagnostics:
description: "Path to diagnostics JSONL file (cargo clippy --message-format=json output)"
required: false
upstream_exit_code:
description: "Exact exit code from the upstream diagnostics command"
required: false
upstream_build_finished:
description: "Whether the upstream Cargo stream contained build-finished"
required: false
upstream_build_success:
description: "Success value from the upstream Cargo build-finished message"
required: false
upstream_command:
description: "Upstream command as a JSON string array"
required: false
version:
description: "Exact lintdiff release version; defaults to the invoked exact Action tag"
required: false
artifact_name:
description: "Name for the uploaded report artifact"
required: false
default: "lintdiff-report"
working_directory:
description: "Working directory for lintdiff"
required: false
default: "."
root:
description: "Repository root used for diff and Git metadata"
required: false
outputs:
verdict:
description: "Verdict status (pass, warn, fail, skip)"
value: ${{ steps.run.outputs.verdict }}
report_path:
description: "Path to the report JSON file"
value: ${{ steps.run.outputs.report_path }}
exit_code:
description: "Exit code from lintdiff"
value: ${{ steps.run.outputs.exit_code }}
resolved_version:
description: "Verified lintdiff release version"
value: ${{ steps.version.outputs.version }}
runs:
using: "composite"
steps:
- name: Determine version
id: version
shell: bash
env:
INPUT_VERSION: ${{ inputs.version }}
ACTION_REF: ${{ github.action_ref }}
ACTION_PATH: ${{ github.action_path }}
run: |
VERSION=$("$ACTION_PATH/scripts/action/resolve-version.sh" "$ACTION_REF" "$INPUT_VERSION")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Download lintdiff
shell: bash
env:
VERSION: ${{ steps.version.outputs.version }}
ACTION_PATH: ${{ github.action_path }}
RUNNER_TEMP: ${{ runner.temp }}
run: |
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case "$OS" in
linux)
case "$ARCH" in
x86_64)
TARGET="x86_64-unknown-linux-gnu"
EXT="tar.gz"
;;
*)
echo "::error::Unsupported platform: ${OS}-${ARCH}"
exit 1
;;
esac
;;
darwin)
case "$ARCH" in
x86_64)
TARGET="x86_64-apple-darwin"
EXT="tar.gz"
;;
arm64|aarch64)
TARGET="aarch64-apple-darwin"
EXT="tar.gz"
;;
*)
echo "::error::Unsupported platform: ${OS}-${ARCH}"
exit 1
;;
esac
;;
mingw*|msys*|cygwin*)
TARGET="x86_64-pc-windows-msvc"
EXT="zip"
;;
*)
echo "::error::Unsupported platform: ${OS}-${ARCH}"
exit 1
;;
esac
if command -v cygpath >/dev/null 2>&1; then
RUNNER_TEMP="$(cygpath -u "$RUNNER_TEMP")"
export RUNNER_TEMP
fi
BINARY_PATH=$(LINTDIFF_TARGET="$TARGET" LINTDIFF_EXTENSION="$EXT" \
"$ACTION_PATH/scripts/action/install.sh" --version "$VERSION")
path_entry="$(dirname "$BINARY_PATH")"
if command -v cygpath >/dev/null 2>&1; then
path_entry="$(cygpath -w "$path_entry")"
fi
echo "$path_entry" >> "$GITHUB_PATH"
- name: Run lintdiff
id: run
shell: bash
working-directory: ${{ inputs.working_directory }}
env:
INPUT_BASE: ${{ inputs.base }}
INPUT_HEAD: ${{ inputs.head }}
INPUT_CONFIG: ${{ inputs.config }}
INPUT_FAIL_ON: ${{ inputs.fail_on }}
INPUT_DIAGNOSTICS: ${{ inputs.diagnostics }}
INPUT_UPSTREAM_EXIT_CODE: ${{ inputs.upstream_exit_code }}
INPUT_UPSTREAM_BUILD_FINISHED: ${{ inputs.upstream_build_finished }}
INPUT_UPSTREAM_BUILD_SUCCESS: ${{ inputs.upstream_build_success }}
INPUT_UPSTREAM_COMMAND: ${{ inputs.upstream_command }}
INPUT_ROOT: ${{ inputs.root }}
ACTION_PATH: ${{ github.action_path }}
run: |
ARGS=(ci github)
if [ -n "$INPUT_BASE" ]; then
ARGS+=(--base "$INPUT_BASE")
fi
if [ -n "$INPUT_HEAD" ]; then
ARGS+=(--head "$INPUT_HEAD")
fi
if [ -n "$INPUT_CONFIG" ]; then
ARGS+=(--config "$INPUT_CONFIG")
fi
if [ -n "$INPUT_FAIL_ON" ]; then
ARGS+=(--fail-on "$INPUT_FAIL_ON")
fi
if [ -n "$INPUT_DIAGNOSTICS" ]; then
ARGS+=(--diagnostics "$INPUT_DIAGNOSTICS")
fi
if [ -n "$INPUT_UPSTREAM_EXIT_CODE" ]; then
ARGS+=(--upstream-exit-code "$INPUT_UPSTREAM_EXIT_CODE")
fi
if [ -n "$INPUT_UPSTREAM_BUILD_FINISHED" ]; then
ARGS+=(--upstream-build-finished "$INPUT_UPSTREAM_BUILD_FINISHED")
fi
if [ -n "$INPUT_UPSTREAM_BUILD_SUCCESS" ]; then
ARGS+=(--upstream-build-success "$INPUT_UPSTREAM_BUILD_SUCCESS")
fi
if [ -n "$INPUT_UPSTREAM_COMMAND" ]; then
ARGS+=(--upstream-command "$INPUT_UPSTREAM_COMMAND")
fi
if [ -n "$INPUT_ROOT" ]; then
ARGS+=(--root "$INPUT_ROOT")
fi
REPORT_PATH="artifacts/lintdiff/report.json"
echo "report_path=$REPORT_PATH" >> "$GITHUB_OUTPUT"
set +e
ARGS+=(--out "$REPORT_PATH" --annotations github)
"$ACTION_PATH/scripts/action/run.sh" "${ARGS[@]}"
EXIT_CODE=$?
set -e
echo "exit_code=$EXIT_CODE" >> "$GITHUB_OUTPUT"
# Extract verdict from report using jq for cross-platform compatibility
if [ -f "$REPORT_PATH" ]; then
VERDICT=$(jq -r '.verdict.status' "$REPORT_PATH" 2>/dev/null || echo "unknown")
echo "verdict=$VERDICT" >> "$GITHUB_OUTPUT"
fi
exit $EXIT_CODE
- name: Upload report artifact
if: always()
uses: actions/upload-artifact@v7
with:
name: ${{ inputs.artifact_name }}
path: ${{ inputs.working_directory }}/artifacts/lintdiff/
if-no-files-found: ignore