Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for actions/checkout@v4 with progress and filter #1298

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.cs
Expand Up @@ -157,6 +157,8 @@ yield return
Submodules = GitHubActionsSubmodules.Recursive,
Lfs = true,
FetchDepth = 2,
Progress = false,
Filter = "tree:0",
TimeoutMinutes = 30,
JobConcurrencyCancelInProgress = true
}
Expand Down
Expand Up @@ -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())
{
Expand All @@ -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}");
}
}
}
Expand Down
18 changes: 17 additions & 1 deletion source/Nuke.Common/CI/GitHubActions/GitHubActionsAttribute.cs
Expand Up @@ -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,
Expand Down Expand Up @@ -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: "#");
Expand Down Expand Up @@ -142,7 +156,9 @@ private IEnumerable<GitHubActionsStep> GetSteps(GitHubActionsImage image, IReadO
{
Submodules = _submodules,
Lfs = _lfs,
FetchDepth = _fetchDepth
FetchDepth = _fetchDepth,
Progress = _progress,
Filter = _filter
};

if (CacheKeyFiles.Any())
Expand Down