Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/reorganize' into macos-m1
Browse files Browse the repository at this point in the history
  • Loading branch information
Fadenfire committed Jun 10, 2024
2 parents d87343f + 7e55f80 commit 132ccdc
Show file tree
Hide file tree
Showing 99 changed files with 2,307 additions and 1,197 deletions.
20 changes: 20 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 1,
"isRoot": true,
"tools": {
"docfx": {
"version": "2.76.0",
"commands": [
"docfx"
],
"rollForward": false
},
"docfxtocgenerator": {
"version": "1.19.0",
"commands": [
"DocFxTocGenerator"
],
"rollForward": false
}
}
}
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ root = true
end_of_line = lf
indent_style = space

[*.yml]
indent_size = 2

[*.{csproj,ilproj,props,targets}]
indent_size = 2

Expand Down
2 changes: 2 additions & 0 deletions .github/.github.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.Build.NoTargets" />
216 changes: 216 additions & 0 deletions .github/gen-test-matrix.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
param (
[string[]] $MatrixOutName,
[string] $GithubOutput
)

$ErrorActionPreference = "Stop";

$operatingSystems = @(
[pscustomobject]@{
name = "Windows";
runner = "windows-latest";
ridname = "win";
arch = @("x86","x64"); # while .NET Framework supports Arm64, GitHub doesn't provide Arm windows runners
runnerArch = 1;
hasFramework = $true;
monoArch = @("win32", "win64", "win_arm64");
monoDll = "mono-2.0-bdwgc.dll";
},
[pscustomobject]@{
name = "Linux";
runner = "ubuntu-latest";
ridname = "linux";
arch = @("x64");
runnerArch = 0;
hasMono = $true;
monoArch = @("linux64");
monoDll = "limonobdwgc-2.0.so"; # TODO
},
[pscustomobject]@{
name = "MacOS 13";
runner = "macos-13";
ridname = "osx";
arch = @("x64");
runnerArch = 0;
hasMono = $true;
monoArch = @("macos_x64");
monoDll = "limonobdwgc-2.0.dylib";
},
[pscustomobject]@{
#enable = $false;
name = "MacOS 14 (M1)";
runner = "macos-14";
ridname = "osx";
arch = @("x64"<#, "arm64"#>); # x64 comes from Rosetta, and we disable arm64 mode for now because we don't support it yet
runnerArch = 1;
hasMono = $true;
monoArch = @("macos_x64", "macos_arm64");
monoDll = "limonobdwgc-2.0.dylib";
}
);

$dotnetVersions = @(
[pscustomobject]@{
name = ".NET Framework 4.x";
id = 'fx';
tfm = "net462";
rids = @("win-x86","win-x64","win-arm64");
isFramework = $true;
},
[pscustomobject]@{
name = ".NET Core 2.1";
sdk = "2.1";
tfm = "netcoreapp2.1";
rids = @("win-x86","win-x64","linux-x64","osx-x64");
needsRestore = $true;
},
[pscustomobject]@{
name = ".NET Core 3.0";
sdk = "3.0";
tfm = "netcoreapp3.0";
rids = @("win-x86","win-x64","linux-x64","osx-x64");
},
[pscustomobject]@{
name = ".NET Core 3.1";
sdk = "3.1";
tfm = "netcoreapp3.1";
rids = @("win-x86","win-x64","linux-x64","osx-x64");
},
[pscustomobject]@{
name = ".NET 5.0";
sdk = "5.0";
tfm = "net5.0";
rids = @("win-x86","win-x64","linux-x64","osx-x64");
},
[pscustomobject]@{
name = ".NET 6.0";
sdk = "6.0";
tfm = "net6.0";
rids = @("win-x86","win-x64","win-arm64","linux-x64","linux-arm","linux-arm64","osx-x64","osx-arm64");
pgo = $true;
},
[pscustomobject]@{
name = ".NET 7.0";
sdk = "7.0";
tfm = "net7.0";
rids = @("win-x86","win-x64","win-arm64","linux-x64","linux-arm","linux-arm64","osx-x64","osx-arm64");
pgo = $true;
},
[pscustomobject]@{
name = ".NET 8.0";
sdk = "8.0";
tfm = "net8.0";
rids = @("win-x86","win-x64","win-arm64","linux-x64","linux-arm","linux-arm64","osx-x64","osx-arm64");
pgo = $true;
}
);

$monoTfm = "net462";

$monoVersions = @(
<#
[pscustomobject]@{
name = "Unity Mono 6000.0.2";
unityVersion = "6000.0.2";
monoName = "MonoBleedingEdge";
}
#>
);

$jobs = @();

foreach ($os in $operatingSystems)
{
if ($os.enable -eq $false) { continue; }
$outos = $os | Select-Object -ExcludeProperty arch,ridname,hasFramework,hasMono,monoArch,monoDll,runnerArch

if ($os.hasMono -and $os.runnerArch -lt $os.arch.Length)
{
# this OS has a system mono, emit a job for that
$jobs += @(
[pscustomobject]@{
title = "System Mono on $($os.name)";
os = $outos;
dotnet = [pscustomobject]@{
name = "Mono";
id = "sysmono";
needsRestore = $true; # Monos always need restore
isMono = $true;
systemMono = $true;
tfm = $monoTfm;
};
arch = $os.arch[$os.runnerArch];
}
);
}

foreach ($arch in $os.arch)
{
$rid = $os.ridname + "-" + $arch;

foreach ($dotnet in $dotnetVersions)
{
if ($dotnet.enable -eq $false) { continue; }

if ($dotnet.isFramework -and -not $os.hasFramework)
{
# we're looking at .NET Framework, but this OS doesn't support it
continue;
}

if (-not $dotnet.rids -contains $rid)
{
# the current OS/arch/runtime triple is not supported by .NET, skip
continue;
}

$outdotnet = $dotnet | Select-Object -ExcludeProperty rids

$title = "$($dotnet.name) $arch on $($os.name)"
if ($dotnet.pgo)
{
# this runtime supports pgo; generate 2 jobs; one with it enabled, one without
$jobs += @(
[pscustomobject]@{
title = $title + " (PGO Off)";
os = $outos;
dotnet = $outdotnet;
arch = $arch;
usePgo = $false;
},
[pscustomobject]@{
title = $title + " (PGO On)";
os = $outos;
dotnet = $outdotnet;
arch = $arch;
usePgo = $true;
}
);
}
else
{
# this is a normal job; only add one
$jobs += @(
[pscustomobject]@{
title = $title;
os = $outos;
dotnet = $outdotnet;
arch = $arch;
}
);
}
}

# TODO: non-system mono
}
}

# TODO: support multiple batches
if ($jobs.Length -gt 256)
{
Write-Error "Generated more than 256 jobs; actions will fail!";
}

$matrixObj = [pscustomobject]@{include = $jobs;};
$matrixStr = ConvertTo-Json -Compress -Depth 5 $matrixObj;
echo "$($MatrixOutName[0])=$matrixStr" >> $GithubOutput;
123 changes: 123 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Build

on:
workflow_call:
inputs:
os:
required: true
type: string
osname:
required: true
type: string
version:
required: true
type: string
no-suffix:
type: boolean
default: false
upload-packages:
type: boolean
default: false
upload-tests:
type: boolean
default: false

defaults:
run:
shell: pwsh

env:
DOTNET_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
NUGET_PACKAGES: ${{github.workspace}}/artifacts/pkg

jobs:
build:
runs-on: ${{ inputs.os }}
name: Build
env:
LOG_FILE_NAME: testresults.${{ inputs.os }}.auxtests.trx
VersionSuffix: ${{ !inputs.no-suffix && format('daily.{0}', inputs.version) }}
DoNotAddSuffix: ${{ inputs.no-suffix && '1' }}
steps:
- name: Configure git
run: |
git config --global core.autocrlf input
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
submodules: recursive

# TODO: maybe we can eventually use package locks for package caching?

- name: Install .NET SDK
uses: nike4613/install-dotnet@54b402247e474b39b84891b9093d8025892c8b47
with:
global-json: global.json

# NOTE: manual package caching
- name: Cache restored NuGet packages
uses: actions/cache@v4
with:
path: ${{ env.NUGET_PACKAGES }}
key: ${{ runner.os }}-nuget-v1-${{ hashFiles('**/*.csproj', '**/*.props', '**/*.targets', 'nuget.config', 'global.json') }}
restore-keys: ${{ runner.os }}-nuget-v1-

- name: Restore
run: dotnet restore -bl:restore.binlog -noAutoRsp

- name: Build
run: dotnet build --no-restore -c Release -p:ContinuousIntegrationBuild=true -bl:build.binlog -clp:NoSummary -noAutoRsp

- name: Pack
run: dotnet pack --no-restore -c Release -p:ContinuousIntegrationBuild=true -bl:pack.binlog -clp:NoSummary -noAutoRsp

# TODO: it might be worth trying to do a "smoketest" test run with the installed tfm to broadly make sure that all builds
# work. We may also want to do a hash check on the packages, though I have no idea how reliable that would be.

# TODO: If/when we add other test projects aside from MonoMod.UnitTest, we should run tests here
#- name: Run auxiliary tests
# run: dotnet test --no-build -c Release -l:"trx;LogFileName=$($env:LOG_FILE_NAME)" --filter "FullyQualifiedName!~MonoMod.UnitTest"
#
#- name: Upload test results
# uses: actions/upload-artifact@v4
# if: ${{ always() }}
# with:
# name: test-results aux ${{ runner.os }}
# retention-days: 1
# path: 'TestResults/*.trx'
# if-no-files-found: ignore

- name: Upload binlogs
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: binlogs-${{ runner.os }}
path: '*.binlog'
retention-days: 7

- name: Archive packages
uses: actions/upload-artifact@v4
if: ${{ inputs.upload-packages }}
with:
name: packages
path: artifacts/package/release/*.nupkg

- name: Archive packages
uses: actions/upload-artifact@v4
if: ${{ !inputs.upload-packages }}
with:
name: packages ${{ runner.os }}
path: artifacts/package/release/*.nupkg
retention-days: 7

- name: Upload test assets
uses: actions/upload-artifact@v4
if: ${{ inputs.upload-tests }}
with:
name: test-assets
retention-days: 1
path: |
artifacts/bin/MonoMod.UnitTest/*/**/*
Loading

0 comments on commit 132ccdc

Please sign in to comment.