From ba0a36e35330dc206ceb51ca255eb00afca3d3f6 Mon Sep 17 00:00:00 2001 From: David Driscoll Date: Fri, 18 Feb 2022 20:58:53 -0500 Subject: [PATCH] Updated build to enable caching (#946) --- .build/Build.CI.cs | 22 ++++++++++++++++++---- .github/renovate.json | 2 +- .github/workflows/ci-ignore.yml | 8 ++++++++ .github/workflows/ci.yml | 21 +++++++++++++++++---- .husky/pre-commit | 1 + .prettierignore | 2 ++ Directory.Packages.props | 9 ++++++--- 7 files changed, 53 insertions(+), 12 deletions(-) diff --git a/.build/Build.CI.cs b/.build/Build.CI.cs index bd9753730..e2e21f5b5 100644 --- a/.build/Build.CI.cs +++ b/.build/Build.CI.cs @@ -23,7 +23,11 @@ internal class LocalConstants "omnisharp.json", "package-lock.json", "package.json", - "Readme.md" + "Readme.md", + ".github/dependabot.yml", + ".github/labels.yml", + ".github/release.yml", + ".github/renovate.json", }; } @@ -103,6 +107,7 @@ RocketSurgeonGitHubActionsConfiguration configuration var checkoutStep = buildJob.Steps.OfType().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[] @@ -111,9 +116,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") { @@ -122,7 +136,7 @@ RocketSurgeonGitHubActionsConfiguration configuration new SetupDotNetStep("Use .NET Core 6.0 SDK") { DotNetVersion = "6.0.x" - }, + } } ); diff --git a/.github/renovate.json b/.github/renovate.json index b4c3b237b..33eeed9f6 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -2,7 +2,7 @@ "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": ["local>RocketSurgeonsGuild/.github:renovate-config"], "prHourlyLimit": 10, - "reviewers": ["david-driscoll"], + "assignees": ["david-driscoll"], "hostRules": [ { "concurrentRequestLimit": 999 diff --git a/.github/workflows/ci-ignore.yml b/.github/workflows/ci-ignore.yml index c5b398a29..a5c03cbb6 100644 --- a/.github/workflows/ci-ignore.yml +++ b/.github/workflows/ci-ignore.yml @@ -39,6 +39,10 @@ on: - 'package-lock.json' - 'package.json' - 'Readme.md' + - '.github/dependabot.yml' + - '.github/labels.yml' + - '.github/release.yml' + - '.github/renovate.json' pull_request: branches: - 'master' @@ -59,6 +63,10 @@ on: - 'package-lock.json' - 'package.json' - 'Readme.md' + - '.github/dependabot.yml' + - '.github/labels.yml' + - '.github/release.yml' + - '.github/renovate.json' jobs: Build: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52cad3206..ab99682bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,6 +39,10 @@ on: - 'package-lock.json' - 'package.json' - 'Readme.md' + - '.github/dependabot.yml' + - '.github/labels.yml' + - '.github/release.yml' + - '.github/renovate.json' pull_request: branches: - 'master' @@ -59,9 +63,15 @@ on: - 'package-lock.json' - 'package.json' - 'Readme.md' + - '.github/dependabot.yml' + - '.github/labels.yml' + - '.github/release.yml' + - '.github/renovate.json' jobs: Build: + env: + NUGET_PACKAGES: '${{ github.workspace }}/.nuget/packages' strategy: fail-fast: false matrix: @@ -76,10 +86,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: @@ -134,7 +147,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 diff --git a/.husky/pre-commit b/.husky/pre-commit index 104008d08..85a664f54 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -6,3 +6,4 @@ 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 +git add .nuke/build.schema.json diff --git a/.prettierignore b/.prettierignore index 2faf38352..33227515d 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1,4 @@ azure-pipelines.nuke.yml .github/workflows/ci.yml +.github/workflows/ci-ignore.yml +.nuke/build.schema.json diff --git a/Directory.Packages.props b/Directory.Packages.props index 926c676b2..2ebc34b06 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,4 +1,4 @@ - + @@ -134,5 +134,8 @@ - - \ No newline at end of file + +