Skip to content

Commit

Permalink
Feature/build cache (#619)
Browse files Browse the repository at this point in the history
* added build caching and added a few missing environment and secrets fields to places

* prettier ignore?
  • Loading branch information
david-driscoll authored Feb 17, 2022
1 parent fcb7a0f commit fd62471
Show file tree
Hide file tree
Showing 10 changed files with 272 additions and 229 deletions.
18 changes: 15 additions & 3 deletions .build/Build.CI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ internal class LocalConstants
"ci-ignore",
GitHubActionsImage.WindowsLatest,
GitHubActionsImage.UbuntuLatest,
AutoGenerate = false,
On = new[] { GitHubActionsTrigger.Push },
OnPushTags = new[] { "v*" },
OnPushBranches = new[] { "master", "main", "next" },
Expand All @@ -42,6 +43,7 @@ internal class LocalConstants
GitHubActionsImage.MacOsLatest,
GitHubActionsImage.WindowsLatest,
GitHubActionsImage.UbuntuLatest,
AutoGenerate = false,
On = new[] { GitHubActionsTrigger.Push },
OnPushTags = new[] { "v*" },
OnPushBranches = new[] { "master", "main", "next" },
Expand Down Expand Up @@ -101,6 +103,7 @@ RocketSurgeonGitHubActionsConfiguration configuration
var checkoutStep = buildJob.Steps.OfType<CheckoutStep>().Single();
// For fetch all
checkoutStep.FetchDepth = 0;
buildJob.Environment["NUGET_PACKAGES"] = "${{ github.workspace }}/.nuget/packages";
buildJob.Steps.InsertRange(
buildJob.Steps.IndexOf(checkoutStep) + 1,
new BaseGitHubActionsStep[]
Expand All @@ -109,9 +112,18 @@ RocketSurgeonGitHubActionsConfiguration configuration
{
Run = "git fetch --prune"
},
new SetupDotNetStep("Use .NET Core 2.1 SDK")
new UsingStep("NuGet Cache")
{
DotNetVersion = "2.1.x"
Uses = "actions/cache@v2",
With =
{
["path"] = "${{ github.workspace }}/.nuget/packages",
// keep in mind using central package versioning here
["key"] =
"${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}-${{ hashFiles('**/Directory.Packages.support.props') }}",
["restore-keys"] = @"|
${{ runner.os }}-nuget-"
}
},
new SetupDotNetStep("Use .NET Core 3.1 SDK")
{
Expand All @@ -120,7 +132,7 @@ RocketSurgeonGitHubActionsConfiguration configuration
new SetupDotNetStep("Use .NET Core 6.0 SDK")
{
DotNetVersion = "6.0.x"
},
}
}
);

Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ on:

jobs:
Build:
env:
NUGET_PACKAGES: '${{ github.workspace }}/.nuget/packages'
strategy:
fail-fast: false
matrix:
Expand All @@ -76,10 +78,13 @@ jobs:
- name: Fetch all history for all tags and branches
run: |
git fetch --prune
- name: 🔨 Use .NET Core 2.1 SDK
uses: actions/setup-dotnet@v1.9.0
- name: NuGet Cache
uses: actions/cache@v2
with:
dotnet-version: '2.1.x'
path: '${{ github.workspace }}/.nuget/packages'
key: "${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}-${{ hashFiles('**/Directory.Packages.support.props') }}"
restore-keys: |
${{ runner.os }}-nuget-
- name: 🔨 Use .NET Core 3.1 SDK
uses: actions/setup-dotnet@v1.9.0
with:
Expand Down Expand Up @@ -134,7 +139,7 @@ jobs:
Publish:
needs:
- Build
uses: RocketSurgeonsGuild/actions/.github/workflows/publish-nuget.yml@v0.3.0
secrets:
RSG_NUGET_API_KEY: '${{ secrets.RSG_NUGET_API_KEY }}'
RSG_AZURE_DEVOPS: '${{ secrets.RSG_AZURE_DEVOPS }}'
uses: RocketSurgeonsGuild/actions/.github/workflows/publish-nuget.yml@v0.3.0
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
. "$(dirname "$0")/_/husky.sh"

npx lint-staged -d -r
dotnet nuke --generate-configuration GitHubActions_ci --host GitHubActions
git add .github/workflows/ci.yml
dotnet nuke --generate-configuration GitHubActions_ci-ignore --host GitHubActions
git add .github/workflows/ci-ignore.yml
Loading

0 comments on commit fd62471

Please sign in to comment.