Skip to content

Commit 8e52e0f

Browse files
author
Joshua Peterson
authored
Merge pull request #8 from Unity-Technologies/add-unity-readme
Document and automate the process to fetch from upstream
2 parents 5a62c1a + a229f0e commit 8e52e0f

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/sh
2+
3+
# Prequisites:
4+
# This script assumes git and github CLR (gh) are installed.
5+
6+
# Cause the script to fail if any individual command fails
7+
set -e
8+
9+
# Fetch from upstream
10+
git remote add upstream https://github.com/dotnet/runtime
11+
git fetch upstream
12+
13+
# Create a new branch for a pull request to merge in upstream/main
14+
# using the current date in the branch name.
15+
git checkout unity-main
16+
branch_name=bot-upstream-main-merge-$(date '+%Y-%m-%d')
17+
git checkout -b $branch_name
18+
git merge upstream/main -m "Merge with main from upstream"
19+
git push --set-upstream origin $branch_name
20+
21+
# Login to Github
22+
set -u
23+
echo "$GITHUB_TOKEN" > .githubtoken
24+
unset GITHUB_TOKEN
25+
gh auth login --hostname github.com --with-token < .githubtoken
26+
rm .githubtoken
27+
28+
# Yamato has a local mirror of github.com for cloning. This configuration
29+
# causes problems for Github CLI, so set the remote manually here.
30+
git remote set-url origin $GIT_REPOSITORY_URL
31+
32+
# Create a pull request back to unity-main
33+
gh pr create --fill
34+
35+
# For some unknown reason we often see this error from Github CLI:
36+
#
37+
# pull request create failed: HTTP 502: Something went wrong while executing your query.
38+
# This may be the result of a timeout, or it could be a GitHub bug.
39+
# Please include `B96C:2166:B667D:BCDCF:61A53AF5` when reporting this issue. (https://api.github.com/graphql)
40+
#
41+
# Often the pull request was actually created though, so manually check for it if this happens.

.yamato/update_from_upstream.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Update from upstream
2+
agent:
3+
type: Unity::VM
4+
image: platform-foundation/linux-ubuntu18.04-il2cpp-bokken:latest
5+
flavor: b1.xlarge
6+
7+
commands:
8+
- curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
9+
- 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
10+
- sudo apt update
11+
- sudo apt install gh
12+
- git config --global user.email "joshuap@unity3d.com"
13+
- git config --global user.name "Josh Peterson"
14+
- .yamato/scripts/update_from_upstream.sh
15+
16+
triggers:
17+
recurring:
18+
- branch: unity-main
19+
frequency: weekly

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Unity's Fork of the .NET Runtime
2+
3+
See [unity/README.md](unity/README.md) for details specific to Unity's fork.
4+
15
# .NET Runtime
26
[![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)
37
[![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)

unity/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# .NET Runtime - Unity Details
2+
3+
This is Unity's fork of the .NET Runtime repository.
4+
5+
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.
6+
7+
## Pulling changes from upstream
8+
9+
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.
10+
11+
## Pushing changes to upstream
12+
13+
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.
14+
15+
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.
16+
17+
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.

0 commit comments

Comments
 (0)