From f71904833c679f61b524feadac69fa88d601dfbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emek=20Vysok=C3=BD?= Date: Thu, 19 Jan 2023 09:57:51 +0100 Subject: [PATCH] Add Codespaces for source build investigations (#15285) --- .devcontainer/vmr-source-build/README.md | 27 ++++++++++++++ .../vmr-source-build/devcontainer.json | 24 +++++++++++++ .devcontainer/vmr-source-build/init.sh | 35 +++++++++++++++++++ README.md | 9 +++++ eng/vmr-sync.sh | 1 + .../content/.devcontainer/devcontainer.json | 3 +- .../prebuilt-sdk/devcontainer.json | 3 +- 7 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 .devcontainer/vmr-source-build/README.md create mode 100644 .devcontainer/vmr-source-build/devcontainer.json create mode 100644 .devcontainer/vmr-source-build/init.sh diff --git a/.devcontainer/vmr-source-build/README.md b/.devcontainer/vmr-source-build/README.md new file mode 100644 index 000000000..b3a5b337a --- /dev/null +++ b/.devcontainer/vmr-source-build/README.md @@ -0,0 +1,27 @@ + + +This Codespace can help you debug the source build of .NET. In case you have run this from a +`dotnet/installer` PR branch, it will contain the VMR (`dotnet/dotnet`) checked out into +`/workspaces/dotnet` with the PR changes pulled into it. You can then attempt to source-build +the VMR which is what the VMR leg in the installer PR build doing. This build takes about 45 +minutes and, after completion, produces an archived .NET SDK in `/workspaces/artifacts/x64/Release`. + +To build the VMR, run following: +```bash +cd /workspaces/dotnet +unset RepositoryName +./build.sh --online +``` + +> Please note that, at this time, the build modifies some of the checked-in sources so it might +be preferential to rebuild the Codespace between attempts. + +For more details, see the instructions at https://github.com/dotnet/dotnet. diff --git a/.devcontainer/vmr-source-build/devcontainer.json b/.devcontainer/vmr-source-build/devcontainer.json new file mode 100644 index 000000000..5cede5485 --- /dev/null +++ b/.devcontainer/vmr-source-build/devcontainer.json @@ -0,0 +1,24 @@ +// Container suitable for investigating issues with source build +// Contains the VMR (dotnet/dotnet) with applied changes from the current PR +// The container supports source-building the SDK +{ + "name": "VMR with PR changes", + "image": "mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-36", + "hostRequirements": { + // A completely source built .NET is >64 GB with all the repos/artifacts + "storage": "128gb" + }, + "customizations": { + "vscode": { + "extensions": [ + "ms-dotnettools.csharp" + ] + }, + "codespaces": { + "openFiles": [ + ".devcontainer/vmr-source-build/README.md" + ] + } + }, + "onCreateCommand": "${containerWorkspaceFolder}/.devcontainer/vmr-source-build/init.sh" +} \ No newline at end of file diff --git a/.devcontainer/vmr-source-build/init.sh b/.devcontainer/vmr-source-build/init.sh new file mode 100644 index 000000000..8861a4f5d --- /dev/null +++ b/.devcontainer/vmr-source-build/init.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +set -ex + +source="${BASH_SOURCE[0]}" +script_root="$( cd -P "$( dirname "$source" )" && pwd )" + +# TODO: Remove once we have a new version of the image +dnf -y install openssl1.1 + +installer_dir=$(realpath "$script_root/../..") +workspace_dir=$(realpath "$installer_dir/../") +tmp_dir=$(realpath "$workspace_dir/tmp") +vmr_dir=$(realpath "$workspace_dir/dotnet") + +mkdir -p "$tmp_dir" + +# Codespaces performs a shallow fetch only +git -C "$installer_dir" fetch --all --unshallow + +# We will try to figure out, which branch is the current (PR) branch based off of +# We need this to figure out, which VMR branch to use +vmr_branch=$(git log --pretty=format:'%D' HEAD^ | grep 'origin/' | head -n1 | sed 's@origin/@@' | sed 's@,.*@@') + +"$installer_dir/eng/vmr-sync.sh" \ + --vmr "$vmr_dir" \ + --tmp "$tmp_dir" \ + --branch "$vmr_branch" \ + --debug + +# Run prep.sh +unset RepositoryName +pushd "$vmr_dir" +./prep.sh +popd diff --git a/README.md b/README.md index beaf68613..0cbc6ac9f 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,15 @@ The dependencies for building .NET from source can be found [here](https://githu Clone the dotnet/dotnet repo and check out the tag for the desired release. Then, follow the instructions in [dotnet/dotnet's README](https://github.com/dotnet/dotnet/blob/main/README.md#dev-instructions) to build .NET from source. +### Codespaces + +It is also possible to utilize [GitHub Codespaces](https://github.com/features/codespaces) and build .NET from the `dotnet/dotnet` repository from source that way. +You can either create a Codespace in `dotnet/dotnet` directly or you can also make one from a PR branch in `dotnet/installer`. This will give you an environment with the VMR checked out and containing all of new changes from the PR. +This can be especially valuable for investigations of source-build failures during PRs. + +To create a Codespace for a `dotnet/installer` PR, use the `vmr-source-build` devcontainer configuration (select this when "newing the Codespace with options" under the three-dots-menu). +Further instructions on how to build inside of the Codespace will be available upon launch. + ## Building .NET 7.0 and .NET 6.0 1. Create a .NET source tarball. diff --git a/eng/vmr-sync.sh b/eng/vmr-sync.sh index 715ab3072..5251d4faf 100755 --- a/eng/vmr-sync.sh +++ b/eng/vmr-sync.sh @@ -151,6 +151,7 @@ fi if [[ ! -d "$vmr_dir" ]]; then highlight "Cloning 'dotnet/dotnet' into $vmr_dir.." git clone https://github.com/dotnet/dotnet "$vmr_dir" + git switch -c "$vmr_branch" else if ! git -C "$vmr_dir" diff --quiet; then fail "There are changes in the working tree of $vmr_dir. Please commit or stash your changes" diff --git a/src/SourceBuild/content/.devcontainer/devcontainer.json b/src/SourceBuild/content/.devcontainer/devcontainer.json index 8f8e2ac2d..c5bef51ea 100644 --- a/src/SourceBuild/content/.devcontainer/devcontainer.json +++ b/src/SourceBuild/content/.devcontainer/devcontainer.json @@ -9,8 +9,7 @@ "customizations": { "vscode": { "extensions": [ - "ms-dotnettools.csharp", - "eamodio.gitlens" + "ms-dotnettools.csharp" ] } } diff --git a/src/SourceBuild/content/.devcontainer/prebuilt-sdk/devcontainer.json b/src/SourceBuild/content/.devcontainer/prebuilt-sdk/devcontainer.json index 40d60fb29..6e8a61e06 100644 --- a/src/SourceBuild/content/.devcontainer/prebuilt-sdk/devcontainer.json +++ b/src/SourceBuild/content/.devcontainer/prebuilt-sdk/devcontainer.json @@ -9,8 +9,7 @@ "customizations": { "vscode": { "extensions": [ - "ms-dotnettools.csharp", - "eamodio.gitlens" + "ms-dotnettools.csharp" ] } },