Skip to content

Commit

Permalink
Support for actions/checkout@v4 with progress and filter
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma committed Nov 29, 2023
1 parent b94f4c1 commit 2c6ef6b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 13 deletions.
Original file line number Diff line number Diff line change
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@v3
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@v3
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@v3
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ build_script:
- sh: ./build.cmd Test

artifacts:
- path: src/*/obj/**
- path: src/*/bin/**
- path: output/test-results/*.trx
- path: output/test-results/*.xml
- path: 'src/*/obj/**'
- path: 'src/*/bin/**'
- path: 'output/test-results/*.trx'
- path: 'output/test-results/*.xml'
- path: output/coverage-report.zip

environment:
Expand Down
Original file line number Diff line number Diff line change
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@v3
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@v3
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@v3
with:
Expand Down
2 changes: 2 additions & 0 deletions source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.cs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 2c6ef6b

Please sign in to comment.