[MTGOSDK/Core] Refactor Compiler, Remoting namespaces #262
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
types: [opened, synchronize] | |
paths: | |
- '.github/workflows/build.yml' | |
- '**/*.cs' | |
- '**/*.sln' | |
- '**/*.csproj' | |
- '**/*.props' | |
- '**/*.targets' | |
- '**/packages.lock.json' | |
workflow_dispatch: | |
concurrency: | |
group: ci-${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
MSBUILD_CACHES: | | |
**/dist/**/Reference | |
**/bin | |
**/obj | |
NUGET_CACHES: | | |
~/.nuget/packages | |
NUGET_DEFAULTS: -Verbosity quiet -NonInteractive -UseLockFile | |
jobs: | |
# Runs test suite | |
build: | |
runs-on: windows-latest | |
name: "MSBuild Runner" | |
steps: | |
# Fetches remote repository without --progress option. | |
# | |
# The default behavior of @actions/checkout outputs many noisy lines of | |
# status output in the workflow log, which is problematic for log size. | |
- name: Checkout latest repository commit | |
uses: actions/checkout@v4 | |
with: | |
show-progress: false | |
fetch-depth: 0 # Disable shallow clone for Nerdbank.GitVersioning | |
# Setup the .NET environment | |
- name: Install .NET Core | |
uses: actions/setup-dotnet@v4 | |
- run: dotnet --version | |
- name: Restore .NET tools | |
run: dotnet tool restore | |
# Setup MSBuild environment | |
- name: Restore Build Cache | |
id: msbuild-cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.MSBUILD_CACHES }} | |
key: ${{ runner.os }}-msbuild-${{ github.ref_name }}-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-msbuild-${{ github.ref_name }} | |
${{ runner.os }}-msbuild- | |
# Setup NuGet environment | |
- name: Setup NuGet | |
uses: NuGet/setup-nuget@v1.2.0 | |
- name: Restore NuGet Cache | |
id: nuget-cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.NUGET_CACHES }} | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-nuget- | |
- name: Restore NuGet packages | |
if: steps.nuget-cache.outputs.cache-hit != 'true' | |
run: nuget restore SDK.sln ${{ env.NUGET_DEFAULTS }} | |
# Build the SDK | |
- name: Build SDK Solution | |
run: dotnet build SDK.sln -c Release | |
# Evict expired cache entries | |
- name: Purge expired cache entries | |
uses: actions/github-script@v6 | |
env: | |
MSBUILD_HIT: ${{ steps.msbuild-cache.outputs.cache-hit }} | |
NUGET_HIT: ${{ steps.nuget-cache.outputs.cache-hit }} | |
with: | |
script: | | |
// Extract environmental variables into their JS equivalents | |
const MSBUILD = process.env.MSBUILD_HIT !== 'true' | |
const NUGET = process.env.NUGET_HIT !== 'true' | |
// Exit early if no cache hits | |
if (!MSBUILD && !NUGET) | |
return // No cache hit | |
// Fetch the repository's Actions cache list | |
const caches = await github.rest.actions.getActionsCacheList({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
}) | |
// Purge expired MSBuild and NuGet caches from the current ref | |
for (const { id, ref, key } of caches.data.actions_caches) { | |
if (ref != context.ref) | |
continue // Cache is not accessible in this context | |
if ((MSBUILD && key.startsWith("${{ runner.os }}-msbuild-")) || | |
(NUGET && key.startsWith("${{ runner.os }}-nuget-"))) { | |
await github.rest.actions.deleteActionsCacheById({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
cache_id: id, | |
}) | |
} | |
} |