Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp CI infrastructure and implement release automation #1873

Merged
merged 17 commits into from
Jul 4, 2024

Conversation

PathogenDavid
Copy link
Member

@PathogenDavid PathogenDavid commented Jul 3, 2024

This PR revamps CI and adds release automation.

I don't expect to make any more changes, but I've marked this as a draft because manual configuration to the Bonsai repo must be completed before merging.

As a side effect, this PR brings some other changes as well:

  • Bonsai now uses the new central artifacts folder pattern, build outputs will be placed in the artifacts folder at the root of the repository
    • The stale output directories were removed from the gitignore and will result in a build warning to help people notice and delete them
    • This change includes the previous central bin folder
  • Directory.Build.* is now more structured in order to properly support non-C# projects and allow organization of the now more-complex MSBuild infrastructure
  • Various cleanup to build system stuff since I was looking at it (removed old cruft, fixed or suppressed various NuGet warnings as appropriate)
  • Bonsai32 no longer clobbers Bonsai's output (this was mostly invisible but was causing chaos within the build could break things in subtle ways)
  • Bonsai now builds successfully under the .NET 8 SDK from the command line
  • Bonsai now uses modern resource embedding
  • Bonsai now requires the .NET 8 SDK to be built (enforced via global.json) -- This isn't strictly necessary (we do assume .NET 8 since it comes with Source Link) but we're going to have a hard requirement soon so might as well
  • ILRepack has been updated to the latest version (required for some modern resource embedding fixes)
  • ILRepack no longer happens automatically, it's only done by CI and CI benefits from having it as a separate step anyway
  • Introduced an unhealthy amount of Python into a predominately C# project

This PR furthermore makes some major changes to how Bonsai is versioned:

  • All packages within Bonsai are versioned together now (packages with no changes skip version numbers instead of getting out of sync)
    • This means Bonsai.Shaders and friends are no longer using initial development (IE: 0.y.z) version numbers
  • Some core packages are always released even if they don't have any changes (this list is configurable in compare-nuget-packages.py)
  • The now-unnecessary revision octet of the file versions has been eliminated (RIP days since first commit Easter egg)
  • The origin and purpose of Bonsai binaries is now labeled clearly: Developer (local) builds, unstable CI builds, preview builds, and final release builds
    • Additionally all binaries will be stamped with the Git revision from which they were built (this now shows in the about box as well)
    • The title of Bonsai's editor will be tagged as such for anything other than the final release builds
    • Unstable CI builds from branches other than main will have their origin clearly tagged. (For example, a devel branch would produce packages versioned like 2.8.5-devel-ci42)

Some things that didn't end up making it into this PR:

  • The versions of Bonsai packages referenced inside templates (IE: the versions added to generated csproj and such) are not bumped (this had some particularly thorny issues and didn't feel worthwhile)
  • This PR does not fix the issue with the bootstrapper restoring the wrong version of itself when it can't find the right one

Related docs repo PR: bonsai-rx/docs#87
Related infrastructure backport PR: #1880

Closes #1856
Indirectly fixes #1831 (Bonsai.Editor is always released now, so this scenario can't happen anymore)

The x64 platform didn't actually build most of Bonsai, it's an artifact of fb65c18 when Bonsai64 was added (before becoming the default and leading to Bonsai32.)
The "Mixed Platforms" platform is something Visual Studio used to automatically add to solutions when multiple projects had conflicting platforms.

Technically Mixed Platforms was the default before, but Any CPU was equivalent and makes more sense in the context of Bonsai.
The XML declarations are an artifact of the fact that Bonsai is old enough to have use the legacy csproj format. They aren't present the official .NET templates anymore and only serve as noise.

The Microsoft.NET.Sdk.WindowsDesktop distinction no longer actually exists. (For modern projects you'd generally add a -windows suffix to the target framework instead, although in the case of Bonsai that wasn't actually necessary anywhere since we still target .NET Framework which is implicitly Windows-only.)
https://learn.microsoft.com/en-us/dotnet/core/tools/sdk-errors/netsdk1137
This is being done in preparation for having auxiliary files for organization purposes.

The csproj-specific files pattern is intended to avoid issues when projects of multiple types share the same repo.
This isn't strictly necessary in the case of Bonsai, but I did it out of habit.

This also adds a dummy Directory.Build.rsp (another lesser-used ambient MSBuild configuration mechanism) to avoid searching for one outside of the repo.
…'s output

Most of the side-effects of this mistake were not externally observable, but they can (and did) result in extremely confusingly broken builds.
.github/workflows/Bonsai.yml Outdated Show resolved Hide resolved
.github/workflows/Bonsai.yml Show resolved Hide resolved
.github/workflows/Bonsai.yml Show resolved Hide resolved
.github/workflows/Bonsai.yml Show resolved Hide resolved
.github/workflows/Bonsai.yml Show resolved Hide resolved
tooling/Common.csproj.props Outdated Show resolved Hide resolved
tooling/Common.props Outdated Show resolved Hide resolved
tooling/Common.targets Outdated Show resolved Hide resolved
tooling/Versioning.props Outdated Show resolved Hide resolved
tooling/Versioning.props Outdated Show resolved Hide resolved
The .NET SDK uses MSBuild Core rather than MSBuild Framework. One difference between them is that the legacy Windows-centric resource embedding was completely dropped from Core.
This updated resource embedding can be used with .NET Framework by using System.Resources.Extensions. (It only affects non-string resources like images, hence why only Bonsai.Design needs it.)

-------------------------------------------------

The new reference to System.Runtime.CompilerServices.Unsafe in Bonsai32 is to work around a quirk of how NuGet resolves the dependency graph.
There exists two paths to this package from the main Bonsai project (versions noted where important):
1) Bonsai -> Bonsai.Design -> System.Resources.Extensions -> System.Memory -> System.Runtime.CompilerServices.Unsafe/4.5.3
2) Bonsai -> System.Reflection.MetadataLoadContext->System.Collections.Immutable -> System.Runtime.CompilerServices.Unsafe/6.0.0

Path bonsai-rx#2 is private to Bonsai, while Path bonsai-rx#1 is not.
Because Path bonsai-rx#2 is private, it isn't even part of the restore graph of Bonsai32.
As a result, Bonsai32 gets a transitive reference to S.R.CS.Unsafe 4.5.3 but Bonsai already has private reference to S.R.CS.Unsafe 6.0.0, resulting in a conflict.
This eventually results in a MSB3277 warning and can result in a completely broken build (if it weren't for the recent change the prevented Bonsai32 from clobbering Bonsai's output.)
Source link is enabled by default in .NET 8, so this mostly just means removing things that were interfering with it and enforcing building with the .NET 8 SDK.

Release automation will rely on Source Link being made default in .NET 8 and we're going to be moving to .NET 8 soon anyway, so no time like the present.
…s` projects

This reference is causing bogus warnings on build and isn't actually being used.
I think this is an artifact from older versions of Visual Studio, the current VSIX project template doesn't include it.
More info: https://learn.microsoft.com/en-us/dotnet/core/sdk/artifacts-output
This also applies to the setup executables and VSIX projects even though they use legacy .NET SDK.
Also add it to the main solution since it was orphaned and it'll be able to be built from it.
The ancient version of ILRepack we were using was broken due to a bug in Mono.Cecil that caused it to crash when running in a modern .NET context.
Even ignoring that, it chokes on modern resources embeddings.

The package we were using hasn't been updated since early 2019.

There is a fork that branched off in 2013 https://www.nuget.org/packages/ILRepack.Lib.MSBuild.Task but it doesn't work quite the same way (it tries to work automagically) and isn't a drop-in replacement.

As such this change just invokes the executable from the official distribution of ILRepack.

This change also makes it so that repacking is no longer done automatically during release builds. It'll be done explicitly by release automation.
This commit also comes with some major changes to how versioning of Bonsai and its components works:
* All packages within Bonsai are versioned together now (packages with no changes skip version numbers instead of getting out of sync)
    * This means Bonsai.Shaders and friends are no longer using initial development (IE: 0.y.z) version numbers
* It is now forbidden for projects to explicitly specify their versions (this is required for package diffing
* The now-unnecessary revision octet of the file versions has been eliminated (RIP days since first commit Easter egg)
* The origin and purpose of Bonsai binaries is now labeled clearly: Developer (local) builds, unstable CI builds, preview builds, and final release builds
    * The title of Bonsai's editor will be tagged as such for anything other than the final release builds
The labels in the table try to use word wrap when they're too long, but only the first line is visible so the wrapped text just disappears instead.
AutoEllipsis prevents the wrap and instead cuts off excess information with an ellipsis.

Version was disappearing entirely when build metadata was included.

The copyright year range was being cut off as well, made the form a bit wider so it's fully visible.
@PathogenDavid PathogenDavid marked this pull request as ready for review July 4, 2024 16:11
@glopesdev glopesdev self-requested a review July 4, 2024 16:12
@glopesdev glopesdev changed the title Release automation Revamp CI infrastructure and implement release automation Jul 4, 2024
@glopesdev glopesdev merged commit a9dd431 into bonsai-rx:main Jul 4, 2024
10 checks passed
@PathogenDavid PathogenDavid added this to the 2.8.4 milestone Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants