Commit

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.

syntaqxcommitted Parent6fd4894Browse files
1 file+13−70/1 viewed
+13−7
371371 _ => {}
372372 }
373373 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())
375375 {
376376 note(severity, Some(id), message);
377377 }
457457 }
458458
459459 /// 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)> {
461462 if uses.starts_with("docker://") {
462463 return Some((Severity::Unsupported, format!("`{uses}`: Docker actions do not run on g1t yet.")));
463464 }
465466 match name.as_str() {
466467 "actions/checkout" => Some((Severity::Info, "`actions/checkout` checks out from g1t.".to_owned())),
467468 "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."),
470471 )),
471472 "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((
472477 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."),
474479 )),
475480 _ => None,
476481 }
562567 #[test]
563568 fn notes_say_what_runs_differently() {
564569 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",
566571 )
567572 .unwrap();
568573 let unsupported: Vec<&str> =
572577 assert!(unsupported.iter().any(|m| m.contains("services")));
573578 assert!(unsupported.iter().any(|m| m.contains("docker://alpine")));
574579 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")));
576582 }
577583
578584 #[test]