diff --git a/.yamato/scripts/update_from_upstream.sh b/.yamato/scripts/update_from_upstream.sh new file mode 100755 index 00000000000000..8a3fbdf5befc69 --- /dev/null +++ b/.yamato/scripts/update_from_upstream.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +# Prequisites: +# This script assumes git and github CLR (gh) are installed. + +# Cause the script to fail if any individual command fails +set -e + +# Fetch from upstream +git remote add upstream https://github.com/dotnet/runtime +git fetch upstream + +# Create a new branch for a pull request to merge in upstream/main +# using the current date in the branch name. +git checkout unity-main +branch_name=bot-upstream-main-merge-$(date '+%Y-%m-%d') +git checkout -b $branch_name +git merge upstream/main -m "Merge with main from upstream" +git push --set-upstream origin $branch_name + +# Login to Github +set -u +echo "$GITHUB_TOKEN" > .githubtoken +unset GITHUB_TOKEN +gh auth login --hostname github.com --with-token < .githubtoken +rm .githubtoken + +# Yamato has a local mirror of github.com for cloning. This configuration +# causes problems for Github CLI, so set the remote manually here. +git remote set-url origin $GIT_REPOSITORY_URL + +# Create a pull request back to unity-main +gh pr create --fill + +# For some unknown reason we often see this error from Github CLI: +# +# pull request create failed: HTTP 502: Something went wrong while executing your query. +# This may be the result of a timeout, or it could be a GitHub bug. +# Please include `B96C:2166:B667D:BCDCF:61A53AF5` when reporting this issue. (https://api.github.com/graphql) +# +# Often the pull request was actually created though, so manually check for it if this happens. diff --git a/.yamato/update_from_upstream.yml b/.yamato/update_from_upstream.yml new file mode 100644 index 00000000000000..e9c477fcc11bea --- /dev/null +++ b/.yamato/update_from_upstream.yml @@ -0,0 +1,19 @@ +name: Update from upstream +agent: + type: Unity::VM + image: platform-foundation/linux-ubuntu18.04-il2cpp-bokken:latest + flavor: b1.xlarge + +commands: + - curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg + - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null + - sudo apt update + - sudo apt install gh + - git config --global user.email "joshuap@unity3d.com" + - git config --global user.name "Josh Peterson" + - .yamato/scripts/update_from_upstream.sh + +triggers: + recurring: + - branch: unity-main + frequency: weekly diff --git a/README.md b/README.md index 91bd8573ac8f15..deb3b40749741b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +# Unity's Fork of the .NET Runtime + +See [unity/README.md](unity/README.md) for details specific to Unity's fork. + # .NET Runtime [![Build Status](https://dnceng.visualstudio.com/public/_apis/build/status/dotnet/runtime/runtime?branchName=main)](https://dnceng.visualstudio.com/public/_build/latest?definitionId=686&branchName=main) [![Help Wanted](https://img.shields.io/github/issues/dotnet/runtime/up-for-grabs?style=flat-square&color=%232EA043&label=help%20wanted)](https://github.com/dotnet/runtime/issues?q=is%3Aissue+is%3Aopen+label%3A%22up-for-grabs%22) diff --git a/unity/README.md b/unity/README.md new file mode 100644 index 00000000000000..115500da0f0160 --- /dev/null +++ b/unity/README.md @@ -0,0 +1,17 @@ +# .NET Runtime - Unity Details + +This is Unity's fork of the .NET Runtime repository. + +The difference between this fork and the upstream repository should be as small as possible, with all of the differences specific to Unity. Our goal is to upstream as many changes made here as possible. + +## Pulling changes from upstream + +There is a job in Unity's internal CI which runs weekly to pull the latest code from the upstream [dotnet/runtime](https://github.com/dotnet/runtime) repository `main` branch and create a pull request to merge these changes to the [`unity-main`](https://github.com/Unity-Technologies/runtime/tree/unity-main) branch. + +## Pushing changes to upstream + +When a pull request is open against this fork, we should determine if the changes in that pull request should be pushed upstream (most should). Ideally, pull request should be organized so that all changes in a given pull request can be directly applied upstream. Any changes specific to the Unity fork should be done in a separate pull request. + +Assuming the branch with changes to upstream is named `great-new-feature` then a new branch of upstream [`main`](https://github.com/dotnet/runtime/tree/main) named `upstream-great-new-feature` should be created. Each commit from `great-new-feature` should be cherry-picked `upstream-great-new-feature`, and then a pull request should be opened from `upstream-great-new-feature` to [`main`](https://github.com/dotnet/runtime/tree/main) in the upstream repository. + +It is acceptable to _merge_ changes to this fork from `great-new-feature` before `upstream-great-new-feature` is merged, but we should at least _open_ an upstream pull request first.