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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
//! Logging, grouping, masking and command-flow control.
//!
//! Everything here writes to stdout (the runner's command channel).\
//! A failed stdout write inside an action is unrecoverable, so these functions are intentionally
//! **infallible** — mirroring `@actions/core`.\
//! Fallible operations live in [`crate::output`] and [`crate::summary`].
use ;
use ;
use crateWorkflowCommand;
use crateenv;
/// Process-global failure flag, the Rust analogue of `@actions/core`'s `process.exitCode = ExitCode.Failure`.
/// Set by [`set_failed`], read by [`exit_code`] / [`is_failed`].
static FAILED: AtomicBool = new;
/// Write a plain line to the log (no annotation).
/// Equivalent to `println!`, provided for symmetry with the other log functions.
///
/// # Examples
///
/// ```
/// actions_rs::log::info("starting build");
/// ```
/// Emit a `::debug::` message.
/// Only visible when step-debug logging is enabled (the `ACTIONS_STEP_DEBUG` secret, surfaced as `RUNNER_DEBUG=1`).
///
/// # Examples
///
/// ```
/// actions_rs::log::debug("cache key = v2-linux");
/// ```
/// Emit a `::notice::` annotation with no location.
/// For located annotations use [`crate::Annotation`].
///
/// # Examples
///
/// ```
/// actions_rs::log::notice("published 3 artifacts");
/// ```
/// Emit a `::warning::` annotation with no location.
///
/// # Examples
///
/// ```
/// actions_rs::log::warning("deprecated input `path`; use `dir`");
/// ```
/// Emit an `::error::` annotation with no location.
///
/// # Examples
///
/// ```
/// actions_rs::log::error("manifest checksum mismatch");
/// ```
/// Whether step-debug logging is enabled (`RUNNER_DEBUG == "1"`).
///
/// # Examples
///
/// ```
/// if actions_rs::log::is_debug() {
/// actions_rs::log::debug("verbose diagnostics enabled");
/// }
/// ```
/// Mask `value` in all subsequent log output (`::add-mask::`).
///
/// Note this only affects output produced *after* the call;
/// anything already logged is not retroactively masked.
///
/// # Examples
///
/// ```
/// let token = "ghp_example";
/// actions_rs::log::mask(token);
/// // Any later log line containing `ghp_example` is shown as `***`.
/// ```
/// Alias for [`mask`], named after `@actions/core`'s `setSecret`.
///
/// # Examples
///
/// ```
/// actions_rs::log::set_secret(std::env::var("API_KEY").unwrap_or_default());
/// ```
/// Mark the action as failed: emit `message` as an `::error::` annotation and set the process-global failure flag.
///
/// This mirrors `@actions/core`'s `setFailed`, which sets `process.exitCode = 1` *without* exiting — the step runs to completion (allowing cleanup) and then fails.
/// Rust has no settable deferred process exit code, so the deferred part is realised by returning [`exit_code`] from `main`:
///
/// ```no_run
/// use std::process::ExitCode;
/// fn main() -> ExitCode {
/// ghactions_doctest();
/// actions_rs::log::exit_code() // Failure iff set_failed was called
/// }
/// # fn ghactions_doctest() {}
/// ```
///
/// For immediate termination instead, use [`fail_now`].
/// Whether [`set_failed`] has been called in this process.
///
/// # Examples
///
/// ```
/// assert!(!actions_rs::log::is_failed());
/// actions_rs::log::set_failed("step failed");
/// assert!(actions_rs::log::is_failed());
/// ```
/// The process exit code to return from `main`: [`ExitCode::FAILURE`] if [`set_failed`] was called, otherwise [`ExitCode::SUCCESS`].
/// This is the faithful analogue of `@actions/core`'s deferred `process.exitCode`.
///
/// [`ExitCode::FAILURE`]: std::process::ExitCode::FAILURE
/// [`ExitCode::SUCCESS`]: std::process::ExitCode::SUCCESS
///
/// # Examples
///
/// ```no_run
/// use std::process::ExitCode;
/// fn main() -> ExitCode {
/// // ... action body; call `set_failed` on any recoverable failure ...
/// actions_rs::log::exit_code()
/// }
/// ```
/// Emit `message` as an error annotation and immediately exit the process with code `1`.
/// Convenience wrapper around [`set_failed`] that does not wait for `main` to return [`exit_code`].
///
/// # Examples
///
/// ```no_run
/// let Some(input) = std::env::var_os("INPUT_TARGET") else {
/// actions_rs::log::fail_now("required input `target` missing");
/// };
/// ```
!
/// Toggle command echoing (`::echo::on` / `::echo::off`).
///
/// # Examples
///
/// ```
/// actions_rs::log::echo(true); // runner echoes subsequent workflow commands
/// actions_rs::log::echo(false);
/// ```
/// Begin a collapsible log group.
/// Prefer [`group`], which closes the group automatically even on panic.
///
/// # Examples
///
/// ```
/// actions_rs::log::start_group("install");
/// actions_rs::log::info("downloading toolchain");
/// actions_rs::log::end_group();
/// ```
/// End the current collapsible log group.
///
/// # Examples
///
/// ```
/// actions_rs::log::start_group("tests");
/// actions_rs::log::info("running");
/// actions_rs::log::end_group();
/// ```
/// RAII guard returned by [`group_guard`]; emits `::endgroup::` on drop.
///
/// # Examples
///
/// ```
/// {
/// let _g = actions_rs::log::group_guard("lint");
/// actions_rs::log::info("clippy clean");
/// } // `::endgroup::` emitted here
/// ```
);
/// Start a group and return a guard that closes it when dropped (including on panic / early return).
///
/// # Examples
///
/// ```
/// fn step() -> Result<(), &'static str> {
/// let _g = actions_rs::log::group_guard("deploy");
/// // early return still closes the group via the guard's Drop
/// Err("boom")
/// }
/// assert!(step().is_err());
/// ```
/// Run `f` inside a collapsible group, closing the group afterwards even if `f` panics.
/// Returns whatever `f` returns.
///
/// # Examples
///
/// ```no_run
/// let built = actions_rs::log::group("build", || {
/// actions_rs::log::info("compiling...");
/// 6 * 7
/// });
/// assert_eq!(built, 42);
/// ```
/// RAII guard returned by [`stop_commands`];
/// emits the resume token on drop, re-enabling workflow-command processing.
///
/// # Examples
///
/// ```
/// {
/// let _g = actions_rs::log::stop_commands();
/// println!("::not-a-command:: this line is not interpreted");
/// } // command processing resumes here
/// ```
/// Stop the runner from interpreting workflow commands until the returned guard is dropped.
/// Useful when logging untrusted text that might otherwise be parsed as a `::command::`.
///
/// The stop/resume token is randomly generated so untrusted content cannot guess it and resume command processing early.
///
/// # Examples
///
/// ```
/// let untrusted = "::error::spoofed";
/// {
/// let _g = actions_rs::log::stop_commands();
/// actions_rs::log::info(untrusted); // logged literally, not interpreted
/// }
/// ```