Skip to content

Commit 8e2e3cf

Browse files
lahmamatkoch
authored andcommitted
feat(cicd): add filter and progress to GitHubActionsAttribute (#1298)
1 parent ba7999b commit 8e2e3cf

5 files changed

+39
-9
lines changed

source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.Test_testName=detailed-triggers_attribute=GitHubActionsAttribute.verified.txt

+9-3
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@ jobs:
5353
group: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.run_id }}
5454
cancel-in-progress: true
5555
steps:
56-
- uses: actions/checkout@v3
56+
- uses: actions/checkout@v4
5757
with:
5858
submodules: recursive
5959
lfs: true
6060
fetch-depth: 2
61+
progress: false
62+
filter: tree:0
6163
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
6264
uses: actions/cache@v4
6365
with:
@@ -96,11 +98,13 @@ jobs:
9698
group: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.run_id }}
9799
cancel-in-progress: true
98100
steps:
99-
- uses: actions/checkout@v3
101+
- uses: actions/checkout@v4
100102
with:
101103
submodules: recursive
102104
lfs: true
103105
fetch-depth: 2
106+
progress: false
107+
filter: tree:0
104108
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
105109
uses: actions/cache@v4
106110
with:
@@ -139,11 +143,13 @@ jobs:
139143
group: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.run_id }}
140144
cancel-in-progress: true
141145
steps:
142-
- uses: actions/checkout@v3
146+
- uses: actions/checkout@v4
143147
with:
144148
submodules: recursive
145149
lfs: true
146150
fetch-depth: 2
151+
progress: false
152+
filter: tree:0
147153
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
148154
uses: actions/cache@v4
149155
with:

source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.Test_testName=simple-triggers_attribute=GitHubActionsAttribute.verified.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
name: macos-latest
2828
runs-on: macos-latest
2929
steps:
30-
- uses: actions/checkout@v3
30+
- uses: actions/checkout@v4
3131
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
3232
uses: actions/cache@v4
3333
with:
@@ -59,7 +59,7 @@ jobs:
5959
name: ubuntu-latest
6060
runs-on: ubuntu-latest
6161
steps:
62-
- uses: actions/checkout@v3
62+
- uses: actions/checkout@v4
6363
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
6464
uses: actions/cache@v4
6565
with:
@@ -91,7 +91,7 @@ jobs:
9191
name: windows-latest
9292
runs-on: windows-latest
9393
steps:
94-
- uses: actions/checkout@v3
94+
- uses: actions/checkout@v4
9595
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
9696
uses: actions/cache@v4
9797
with:

source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ public class TestBuild : NukeBuild
156156
Submodules = GitHubActionsSubmodules.Recursive,
157157
Lfs = true,
158158
FetchDepth = 2,
159+
Progress = false,
160+
Filter = "tree:0",
159161
TimeoutMinutes = 30,
160162
JobConcurrencyCancelInProgress = true
161163
}

source/Nuke.Common/CI/GitHubActions/Configuration/GitHubActionsCheckoutStep.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ public class GitHubActionsCheckoutStep : GitHubActionsStep
1515
public GitHubActionsSubmodules? Submodules { get; set; }
1616
public bool? Lfs { get; set; }
1717
public uint? FetchDepth { get; set; }
18+
public bool? Progress { get; set; }
19+
public string Filter { get; set; }
1820

1921
public override void Write(CustomFileWriter writer)
2022
{
21-
writer.WriteLine("- uses: actions/checkout@v3");
23+
writer.WriteLine("- uses: actions/checkout@v4");
2224

23-
if (Submodules.HasValue || Lfs.HasValue || FetchDepth.HasValue)
25+
if (Submodules.HasValue || Lfs.HasValue || FetchDepth.HasValue || Progress.HasValue || !Filter.IsNullOrWhiteSpace())
2426
{
2527
using (writer.Indent())
2628
{
@@ -33,6 +35,10 @@ public override void Write(CustomFileWriter writer)
3335
writer.WriteLine($"lfs: {Lfs.ToString().ToLowerInvariant()}");
3436
if (FetchDepth.HasValue)
3537
writer.WriteLine($"fetch-depth: {FetchDepth}");
38+
if (Progress.HasValue)
39+
writer.WriteLine($"progress: {Progress.ToString().ToLowerInvariant()}");
40+
if (!Filter.IsNullOrWhiteSpace())
41+
writer.WriteLine($"filter: {Filter}");
3642
}
3743
}
3844
}

source/Nuke.Common/CI/GitHubActions/GitHubActionsAttribute.cs

+17-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public class GitHubActionsAttribute : ConfigurationAttributeBase
2828
private GitHubActionsSubmodules? _submodules;
2929
private bool? _lfs;
3030
private uint? _fetchDepth;
31+
private bool? _progress;
32+
private string _filter;
3133

3234
public GitHubActionsAttribute(
3335
string name,
@@ -98,6 +100,18 @@ public uint FetchDepth
98100
get => throw new NotSupportedException();
99101
}
100102

103+
public bool Progress
104+
{
105+
set => _progress = value;
106+
get => throw new NotSupportedException();
107+
}
108+
109+
public string Filter
110+
{
111+
set => _filter = value;
112+
get => throw new NotSupportedException();
113+
}
114+
101115
public override CustomFileWriter CreateWriter(StreamWriter streamWriter)
102116
{
103117
return new CustomFileWriter(streamWriter, indentationFactor: 2, commentPrefix: "#");
@@ -142,7 +156,9 @@ private IEnumerable<GitHubActionsStep> GetSteps(GitHubActionsImage image, IReadO
142156
{
143157
Submodules = _submodules,
144158
Lfs = _lfs,
145-
FetchDepth = _fetchDepth
159+
FetchDepth = _fetchDepth,
160+
Progress = _progress,
161+
Filter = _filter
146162
};
147163

148164
if (CacheKeyFiles.Any())

0 commit comments

Comments
 (0)