Skip to content

Commit

Permalink
Get build running on Linux and MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma committed Nov 27, 2023
1 parent 9175311 commit 2aae7b9
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ nswag.js text eol=lf
*.sass text
*.scm text
*.scss text
*.sh text
*.sh text eol=lf
*.sql text
*.styl text
*.tpl text
Expand Down
11 changes: 0 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,7 @@ jobs:
run: |
echo "Adding GNU tar to PATH"
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
- uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0.100
- uses: actions/checkout@v3
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
uses: actions/cache@v3
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('global.json', 'src/**/*.csproj', 'src/**/package.json') }}
- name: 'Run: InstallDependencies, Compile, Test, Pack, Publish'
run: ./build.cmd InstallDependencies Compile Test Pack Publish
env:
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ jobs:
windows-latest:
name: windows-latest
runs-on: windows-latest
concurrency:
group: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.run_id }}
cancel-in-progress: true
steps:
- name: 'Allow long file path'
run: git config --system core.longpaths true
Expand All @@ -41,17 +38,20 @@ jobs:
run: |
echo "Adding GNU tar to PATH"
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
- uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0.100
- uses: actions/checkout@v3
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
uses: actions/cache@v3
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('global.json', 'src/**/*.csproj', 'src/**/package.json') }}
- name: 'Run: InstallDependencies, Compile, Test, Pack'
run: ./build.cmd InstallDependencies Compile Test Pack
ubuntu-latest:
name: ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 'Run: InstallDependencies, Compile, Test, Pack'
run: ./build.cmd InstallDependencies Compile Test Pack
macos-latest:
name: macos-latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: 'Run: InstallDependencies, Compile, Test, Pack'
run: ./build.cmd InstallDependencies Compile Test Pack
23 changes: 13 additions & 10 deletions build/Build.CI.GitHubActions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using Nuke.Common.CI.GitHubActions;
using Nuke.Common.CI.GitHubActions.Configuration;
Expand All @@ -7,29 +8,26 @@
[CustomGitHubActions(
"pr",
GitHubActionsImage.WindowsLatest,
// GitHubActionsImage.UbuntuLatest,
// GitHubActionsImage.MacOsLatest,
GitHubActionsImage.UbuntuLatest,
GitHubActionsImage.MacOsLatest,
OnPullRequestBranches = new[] { "master", "main" },
OnPullRequestIncludePaths = new[] { "**/*.*" },
OnPullRequestExcludePaths = new[] { "**/*.md" },
PublishArtifacts = false,
InvokedTargets = new[] { nameof(InstallDependencies), nameof(Compile), nameof(Test), nameof(Pack) },
CacheKeyFiles = new[] { "global.json", "src/**/*.csproj", "src/**/package.json" },
JobConcurrencyCancelInProgress = true),
CacheKeyFiles = new string[0])
]
[CustomGitHubActions(
"build",
GitHubActionsImage.WindowsLatest,
// GitHubActionsImage.UbuntuLatest,
// GitHubActionsImage.MacOsLatest,
OnPushBranches = new[] { "master", "main" },
OnPushTags = new[] { "v*.*.*" },
OnPushIncludePaths = new[] { "**/*.*" },
OnPushExcludePaths = new[] { "**/*.md" },
PublishArtifacts = true,
InvokedTargets = new[] { nameof(InstallDependencies), nameof(Compile), nameof(Test), nameof(Pack), nameof(Publish) },
ImportSecrets = new[] { "NUGET_API_KEY", "MYGET_API_KEY", "CHOCO_API_KEY", "NPM_AUTH_TOKEN" },
CacheKeyFiles = new[] { "global.json", "src/**/*.csproj", "src/**/package.json" })
CacheKeyFiles = new string[0])
]
public partial class Build
{
Expand All @@ -48,13 +46,18 @@ protected override GitHubActionsJob GetJobs(GitHubActionsImage image, IReadOnlyC
var newSteps = new List<GitHubActionsStep>(job.Steps);

// only need to list the ones that are missing from default image
/*
newSteps.Insert(0, new GitHubActionsSetupDotNetStep(new[]
{
"8.0.100"
}));

newSteps.Insert(0, new GitHubActionsUseGnuTarStep());
newSteps.Insert(0, new GitHubActionsConfigureLongPathsStep());
*/

if (image.ToString().StartsWith("windows", StringComparison.OrdinalIgnoreCase))
{
newSteps.Insert(0, new GitHubActionsUseGnuTarStep());
newSteps.Insert(0, new GitHubActionsConfigureLongPathsStep());
}

job.Steps = newSteps.ToArray();
return job;
Expand Down
37 changes: 13 additions & 24 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ protected override void OnBuildInitialized()

Target InstallDependencies => _ => _
.Before(Restore, Compile)
.OnlyWhenDynamic(() => !IsServerBuild)
.Executes(() =>
{
Chocolatey("install wixtoolset -y");
Expand All @@ -138,13 +139,16 @@ protected override void OnBuildInitialized()
.SetProcessWorkingDirectory(SourceDirectory / "NSwag.Npm")
);
MSBuild(x => x
.SetTargetPath(Solution)
.SetTargets("Restore")
.SetMaxCpuCount(Environment.ProcessorCount)
.SetNodeReuse(IsLocalBuild)
.SetVerbosity(MSBuildVerbosity.Minimal)
);
if (IsRunningOnWindows)
{
MSBuild(x => x
.SetTargetPath(Solution)
.SetTargets("Restore")
.SetMaxCpuCount(Environment.ProcessorCount)
.SetNodeReuse(IsLocalBuild)
.SetVerbosity(MSBuildVerbosity.Minimal)
);
}
DotNetRestore(x => x
.SetProjectFile(Solution)
Expand All @@ -162,22 +166,7 @@ protected override void OnBuildInitialized()
Serilog.Log.Information("Build and copy full .NET command line with configuration {Configuration}", Configuration);
// TODO: Fix build here
MSBuild(x => x
.SetProjectFile(GetProject("NSwagStudio"))
.SetTargets("Build")
.SetAssemblyVersion(VersionPrefix)
.SetFileVersion(VersionPrefix)
.SetInformationalVersion(VersionPrefix)
.SetConfiguration(Configuration)
.SetMaxCpuCount(Environment.ProcessorCount)
.SetNodeReuse(IsLocalBuild)
.SetVerbosity(MSBuildVerbosity.Minimal)
.SetProperty("Deterministic", IsServerBuild)
.SetProperty("ContinuousIntegrationBuild", IsServerBuild)
);
MSBuild(x => x
DotNetMSBuild(x => x
.SetTargetPath(Solution)
.SetTargets("Build")
.SetAssemblyVersion(VersionPrefix)
Expand All @@ -186,7 +175,7 @@ protected override void OnBuildInitialized()
.SetConfiguration(Configuration)
.SetMaxCpuCount(Environment.ProcessorCount)
.SetNodeReuse(IsLocalBuild)
.SetVerbosity(MSBuildVerbosity.Minimal)
.SetVerbosity(DotNetVerbosity.Minimal)
.SetProperty("Deterministic", IsServerBuild)
.SetProperty("ContinuousIntegrationBuild", IsServerBuild)
);
Expand Down

0 comments on commit 2aae7b9

Please sign in to comment.