Skip to content

Commit

Permalink
Updated build to enable caching (#946)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-driscoll authored Feb 19, 2022
1 parent 578fcdb commit ba0a36e
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 12 deletions.
22 changes: 18 additions & 4 deletions .build/Build.CI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
}

Expand Down Expand Up @@ -103,6 +107,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 @@ -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")
{
Expand All @@ -122,7 +136,7 @@ RocketSurgeonGitHubActionsConfiguration configuration
new SetupDotNetStep("Use .NET Core 6.0 SDK")
{
DotNetVersion = "6.0.x"
},
}
}
);

Expand Down
2 changes: 1 addition & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/ci-ignore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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:
Expand Down
21 changes: 17 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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:
Expand All @@ -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/[email protected]
- 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/[email protected]
with:
Expand Down Expand Up @@ -134,7 +147,7 @@ jobs:
Publish:
needs:
- Build
uses: RocketSurgeonsGuild/actions/.github/workflows/[email protected]
secrets:
RSG_NUGET_API_KEY: '${{ secrets.RSG_NUGET_API_KEY }}'
RSG_AZURE_DEVOPS: '${{ secrets.RSG_AZURE_DEVOPS }}'
uses: RocketSurgeonsGuild/actions/.github/workflows/[email protected]
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
azure-pipelines.nuke.yml
.github/workflows/ci.yml
.github/workflows/ci-ignore.yml
.nuke/build.schema.json
9 changes: 6 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<Project>
<ItemGroup>
<PackageVersion Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" />
Expand Down Expand Up @@ -134,5 +134,8 @@
<PackageVersion Include="xunit.analyzers" Version="0.10.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.3" />
</ItemGroup>
<Import Project="$(MSBuildThisFileDirectory)/Directory.Packages.support.props" Condition="Exists('$(MSBuildThisFileDirectory)/Directory.Packages.support.props')" />
</Project>
<Import
Project="$(MSBuildThisFileDirectory)/Directory.Packages.support.props"
Condition="Exists('$(MSBuildThisFileDirectory)/Directory.Packages.support.props')"
/>
</Project>

0 comments on commit ba0a36e

Please sign in to comment.