Actions: workflow notes say what the cache and artifacts do now
The note on actions/cache still said g1t had no cache and every restore missed; it has had one for a while. Cache and artifact steps now get an info note with how long g1t keeps them and the size limit. A setup-* action given a `cache:` input gets the warning instead: it runs without that cache, and an actions/cache step does the same job.
1 file+13−70/1 viewed
| 371 | 371 | _ => {} | |
| 372 | 372 | } | |
| 373 | 373 | if let Some(uses) = &step.uses | |
| 374 | − | && let Some((severity, message)) = action_note(uses) | |
| 374 | + | && let Some((severity, message)) = action_note(uses, fields.get("with").and_then(|with| with.get("cache")).is_some()) | |
| 375 | 375 | { | |
| 376 | 376 | note(severity, Some(id), message); | |
| 377 | 377 | } | |
| 457 | 457 | } | |
| 458 | 458 | ||
| 459 | 459 | /// What to say about an action g1t runs differently, if anything. | |
| 460 | − | fn action_note(uses: &str) -> Option<(Severity, String)> { | |
| 460 | + | /// `caches`: the step sets a `cache` input. | |
| 461 | + | fn action_note(uses: &str, caches: bool) -> Option<(Severity, String)> { | |
| 461 | 462 | if uses.starts_with("docker://") { | |
| 462 | 463 | return Some((Severity::Unsupported, format!("`{uses}`: Docker actions do not run on g1t yet."))); | |
| 463 | 464 | } | |
| 465 | 466 | match name.as_str() { | |
| 466 | 467 | "actions/checkout" => Some((Severity::Info, "`actions/checkout` checks out from g1t.".to_owned())), | |
| 467 | 468 | "actions/cache" | "actions/cache/restore" | "actions/cache/save" => Some(( | |
| 468 | − | Severity::Warning, | |
| 469 | − | format!("`{name}`: g1t has no cache yet, so it always misses and the job does the work again."), | |
| 469 | + | Severity::Info, | |
| 470 | + | format!("`{name}`: g1t keeps the cache per repository for 7 days, up to 60 MB an entry."), | |
| 470 | 471 | )), | |
| 471 | 472 | "actions/upload-artifact" | "actions/download-artifact" => Some(( | |
| 473 | + | Severity::Info, | |
| 474 | + | format!("`{name}`: g1t keeps artifacts with the run for 14 days, up to 60 MB each."), | |
| 475 | + | )), | |
| 476 | + | _ if caches && name.starts_with("actions/setup-") => Some(( | |
| 472 | 477 | Severity::Warning, | |
| 473 | − | format!("`{name}`: artifacts are kept for the run on g1t, and passed between its jobs."), | |
| 478 | + | format!("`{name}` with `cache:` runs without that cache on g1t. Add an `actions/cache` step for the same effect."), | |
| 474 | 479 | )), | |
| 475 | 480 | _ => None, | |
| 476 | 481 | } | |
| 562 | 567 | #[test] | |
| 563 | 568 | fn notes_say_what_runs_differently() { | |
| 564 | 569 | let workflow = parse( | |
| 565 | − | "on: [push, release]\njobs:\n win:\n runs-on: windows-latest\n services:\n db: { image: postgres }\n steps:\n - uses: actions/cache@v6\n - uses: docker://alpine\n - run: dir\n shell: pwsh", | |
| 570 | + | "on: [push, release]\njobs:\n win:\n runs-on: windows-latest\n services:\n db: { image: postgres }\n steps:\n - uses: actions/cache@v6\n - uses: actions/setup-node@v7\n with: { cache: npm }\n - uses: docker://alpine\n - run: dir\n shell: pwsh", | |
| 566 | 571 | ) | |
| 567 | 572 | .unwrap(); | |
| 568 | 573 | let unsupported: Vec<&str> = | |
| 572 | 577 | assert!(unsupported.iter().any(|m| m.contains("services"))); | |
| 573 | 578 | assert!(unsupported.iter().any(|m| m.contains("docker://alpine"))); | |
| 574 | 579 | assert!(unsupported.iter().any(|m| m.contains("pwsh"))); | |
| 575 | − | assert!(workflow.notes.iter().any(|n| n.severity == Severity::Warning && n.message.contains("actions/cache"))); | |
| 580 | + | assert!(workflow.notes.iter().any(|n| n.severity == Severity::Info && n.message.contains("actions/cache"))); | |
| 581 | + | assert!(workflow.notes.iter().any(|n| n.severity == Severity::Warning && n.message.contains("actions/setup-node"))); | |
| 576 | 582 | } | |
| 577 | 583 | ||
| 578 | 584 | #[test] |