From 6f466995cf9ae3d15c32d49804723e2204d67b62 Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Wed, 29 Nov 2023 11:42:02 +0200 Subject: [PATCH] Support for actions/checkout@v4 with progress and filter --- ...tribute=GitHubActionsAttribute.verified.txt | 12 +++++++++--- ...tribute=GitHubActionsAttribute.verified.txt | 6 +++--- .../CI/ConfigurationGenerationTest.cs | 2 ++ .../Configuration/GitHubActionsCheckoutStep.cs | 10 ++++++++-- .../CI/GitHubActions/GitHubActionsAttribute.cs | 18 +++++++++++++++++- 5 files changed, 39 insertions(+), 9 deletions(-) diff --git a/source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.Test_testName=detailed-triggers_attribute=GitHubActionsAttribute.verified.txt b/source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.Test_testName=detailed-triggers_attribute=GitHubActionsAttribute.verified.txt index baa10b88e..cba457564 100644 --- a/source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.Test_testName=detailed-triggers_attribute=GitHubActionsAttribute.verified.txt +++ b/source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.Test_testName=detailed-triggers_attribute=GitHubActionsAttribute.verified.txt @@ -53,11 +53,13 @@ jobs: group: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.run_id }} cancel-in-progress: true steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive lfs: true fetch-depth: 2 + progress: false + filter: tree:0 - name: 'Cache: .nuke/temp, ~/.nuget/packages' uses: actions/cache@v4 with: @@ -96,11 +98,13 @@ jobs: group: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.run_id }} cancel-in-progress: true steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive lfs: true fetch-depth: 2 + progress: false + filter: tree:0 - name: 'Cache: .nuke/temp, ~/.nuget/packages' uses: actions/cache@v4 with: @@ -139,11 +143,13 @@ jobs: group: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.run_id }} cancel-in-progress: true steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive lfs: true fetch-depth: 2 + progress: false + filter: tree:0 - name: 'Cache: .nuke/temp, ~/.nuget/packages' uses: actions/cache@v4 with: diff --git a/source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.Test_testName=simple-triggers_attribute=GitHubActionsAttribute.verified.txt b/source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.Test_testName=simple-triggers_attribute=GitHubActionsAttribute.verified.txt index 740323d94..81771b54a 100644 --- a/source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.Test_testName=simple-triggers_attribute=GitHubActionsAttribute.verified.txt +++ b/source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.Test_testName=simple-triggers_attribute=GitHubActionsAttribute.verified.txt @@ -27,7 +27,7 @@ jobs: name: macos-latest runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: 'Cache: .nuke/temp, ~/.nuget/packages' uses: actions/cache@v4 with: @@ -59,7 +59,7 @@ jobs: name: ubuntu-latest runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: 'Cache: .nuke/temp, ~/.nuget/packages' uses: actions/cache@v4 with: @@ -91,7 +91,7 @@ jobs: name: windows-latest runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: 'Cache: .nuke/temp, ~/.nuget/packages' uses: actions/cache@v4 with: diff --git a/source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.cs b/source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.cs index 8d3ffbbca..902af5909 100644 --- a/source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.cs +++ b/source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.cs @@ -157,6 +157,8 @@ yield return Submodules = GitHubActionsSubmodules.Recursive, Lfs = true, FetchDepth = 2, + Progress = false, + Filter = "tree:0", TimeoutMinutes = 30, JobConcurrencyCancelInProgress = true } diff --git a/source/Nuke.Common/CI/GitHubActions/Configuration/GitHubActionsCheckoutStep.cs b/source/Nuke.Common/CI/GitHubActions/Configuration/GitHubActionsCheckoutStep.cs index 213acf17d..269c08e30 100644 --- a/source/Nuke.Common/CI/GitHubActions/Configuration/GitHubActionsCheckoutStep.cs +++ b/source/Nuke.Common/CI/GitHubActions/Configuration/GitHubActionsCheckoutStep.cs @@ -15,12 +15,14 @@ public class GitHubActionsCheckoutStep : GitHubActionsStep public GitHubActionsSubmodules? Submodules { get; set; } public bool? Lfs { get; set; } public uint? FetchDepth { get; set; } + public bool? Progress { get; set; } + public string Filter { get; set; } public override void Write(CustomFileWriter writer) { - writer.WriteLine("- uses: actions/checkout@v3"); + writer.WriteLine("- uses: actions/checkout@v4"); - if (Submodules.HasValue || Lfs.HasValue || FetchDepth.HasValue) + if (Submodules.HasValue || Lfs.HasValue || FetchDepth.HasValue || Progress.HasValue || !Filter.IsNullOrWhiteSpace()) { using (writer.Indent()) { @@ -33,6 +35,10 @@ public override void Write(CustomFileWriter writer) writer.WriteLine($"lfs: {Lfs.ToString().ToLowerInvariant()}"); if (FetchDepth.HasValue) writer.WriteLine($"fetch-depth: {FetchDepth}"); + if (Progress.HasValue) + writer.WriteLine($"progress: {Progress.ToString().ToLowerInvariant()}"); + if (!Filter.IsNullOrWhiteSpace()) + writer.WriteLine($"filter: {Filter}"); } } } diff --git a/source/Nuke.Common/CI/GitHubActions/GitHubActionsAttribute.cs b/source/Nuke.Common/CI/GitHubActions/GitHubActionsAttribute.cs index 497702c69..90c0a8ef5 100644 --- a/source/Nuke.Common/CI/GitHubActions/GitHubActionsAttribute.cs +++ b/source/Nuke.Common/CI/GitHubActions/GitHubActionsAttribute.cs @@ -28,6 +28,8 @@ public class GitHubActionsAttribute : ConfigurationAttributeBase private GitHubActionsSubmodules? _submodules; private bool? _lfs; private uint? _fetchDepth; + private bool? _progress; + private string _filter; public GitHubActionsAttribute( string name, @@ -98,6 +100,18 @@ public uint FetchDepth get => throw new NotSupportedException(); } + public bool Progress + { + set => _progress = value; + get => throw new NotSupportedException(); + } + + public string Filter + { + set => _filter = value; + get => throw new NotSupportedException(); + } + public override CustomFileWriter CreateWriter(StreamWriter streamWriter) { return new CustomFileWriter(streamWriter, indentationFactor: 2, commentPrefix: "#"); @@ -142,7 +156,9 @@ private IEnumerable GetSteps(GitHubActionsImage image, IReadO { Submodules = _submodules, Lfs = _lfs, - FetchDepth = _fetchDepth + FetchDepth = _fetchDepth, + Progress = _progress, + Filter = _filter }; if (CacheKeyFiles.Any())