Skip to content

Commit 8994e2c

Browse files
Run tests on PR and push
1 parent 8057e81 commit 8994e2c

File tree

3 files changed

+58
-3
lines changed

3 files changed

+58
-3
lines changed

.github/workflows/ci.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# ------------------------------------------------------------------------------
2+
# <auto-generated>
3+
#
4+
# This code was generated.
5+
#
6+
# - To turn off auto-generation set:
7+
#
8+
# [GitHubActions (AutoGenerate = false)]
9+
#
10+
# - To trigger manual generation invoke:
11+
#
12+
# nuke --generate-configuration GitHubActions_ci --host GitHubActions
13+
#
14+
# </auto-generated>
15+
# ------------------------------------------------------------------------------
16+
17+
name: ci
18+
19+
on: [pull_request, push]
20+
21+
jobs:
22+
ubuntu-latest:
23+
name: ubuntu-latest
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 10000
29+
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
30+
uses: actions/cache@v4
31+
with:
32+
path: |
33+
.nuke/temp
34+
~/.nuget/packages
35+
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
36+
- name: 'Run: Test'
37+
run: ./build.cmd Test

.nuke/build.schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"DeployDemo",
3131
"Pack",
3232
"Push",
33-
"Restore"
33+
"Restore",
34+
"Test"
3435
]
3536
},
3637
"Verbosity": {

build/Build.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
WritePermissions = [GitHubActionsPermissions.Contents, GitHubActionsPermissions.Pages],
3232
EnableGitHubToken = true
3333
)]
34+
[GitHubActions("ci",
35+
GitHubActionsImage.UbuntuLatest,
36+
On = [GitHubActionsTrigger.PullRequest, GitHubActionsTrigger.Push],
37+
InvokedTargets = [nameof(Test)],
38+
FetchDepth = 10000)]
3439
class Build : NukeBuild
3540
{
3641
[Nuke.Common.Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
@@ -53,6 +58,7 @@ class Build : NukeBuild
5358

5459
Project LibProject => Solution.GetProject("SimpleBlazorMultiselect");
5560
Project DemoProject => Solution.GetProject("SimpleBlazorMultiselect.Demo");
61+
Project TestsProject => Solution.GetProject("SimpleBlazorMultiselect.Tests");
5662

5763
Target Clean => _ => _
5864
.Before(Restore)
@@ -86,7 +92,7 @@ class Build : NukeBuild
8692
.SetProjectFile(Solution)
8793
.SetConfiguration(Configuration)
8894
.CombineWith(
89-
from project in new[] { LibProject, DemoProject }
95+
from project in new[] { LibProject, DemoProject, TestsProject }
9096
from framework in project.GetTargetFrameworks()
9197
select new { project, framework }, (cs, v) => cs
9298
.SetProjectFile(v.project.Path)
@@ -95,6 +101,17 @@ from framework in project.GetTargetFrameworks()
95101
);
96102
});
97103

104+
Target Test => _ => _
105+
.DependsOn(Compile)
106+
.Executes(() =>
107+
{
108+
DotNetTest(s => s
109+
.EnableNoRestore()
110+
.EnableNoBuild()
111+
.SetConfiguration(Configuration)
112+
.SetProjectFile(TestsProject));
113+
});
114+
98115
Target BuildDemo => _ => _
99116
.DependsOn(Restore, Compile)
100117
.Before(DeployDemo)
@@ -197,7 +214,7 @@ from framework in project.GetTargetFrameworks()
197214

198215
// ReSharper disable once UnusedMember.Local
199216
Target Pack => _ => _
200-
.DependsOn(Clean, Compile)
217+
.DependsOn(Clean, Compile, Test)
201218
.Before(Push)
202219
.Requires(() => Configuration == Configuration.Release)
203220
.Executes(() =>

0 commit comments

Comments
 (0)