Skip to content

Commit 376917b

Browse files
authored
Rollup merge of #144049 - tshepang:rust-push, r=jieyouxu
rustc-dev-guide subtree update r? ghost
2 parents 8c7b8d9 + 41c0c5b commit 376917b

File tree

15 files changed

+151
-983
lines changed

15 files changed

+151
-983
lines changed

src/doc/rustc-dev-guide/.github/workflows/rustc-pull.yml

Lines changed: 9 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -9,106 +9,12 @@ on:
99
jobs:
1010
pull:
1111
if: github.repository == 'rust-lang/rustc-dev-guide'
12-
runs-on: ubuntu-latest
13-
outputs:
14-
pr_url: ${{ steps.update-pr.outputs.pr_url }}
15-
permissions:
16-
contents: write
17-
pull-requests: write
18-
steps:
19-
- uses: actions/checkout@v4
20-
with:
21-
# We need the full history for josh to work
22-
fetch-depth: '0'
23-
- name: Install stable Rust toolchain
24-
run: rustup update stable
25-
- uses: Swatinem/rust-cache@v2
26-
with:
27-
workspaces: "josh-sync"
28-
# Cache the josh directory with checked out rustc
29-
cache-directories: "/home/runner/.cache/rustc-dev-guide-josh"
30-
- name: Install josh
31-
run: RUSTFLAGS="--cap-lints warn" cargo install josh-proxy --git https://github.com/josh-project/josh --tag r24.10.04
32-
- name: Setup bot git name and email
33-
run: |
34-
git config --global user.name 'The rustc-dev-guide Cronjob Bot'
35-
git config --global user.email 'github-actions@github.com'
36-
- name: Perform rustc-pull
37-
id: rustc-pull
38-
# Turn off -e to disable early exit
39-
shell: bash {0}
40-
run: |
41-
cargo run --manifest-path josh-sync/Cargo.toml -- rustc-pull
42-
exitcode=$?
43-
44-
# If no pull was performed, we want to mark this job as successful,
45-
# but we do not want to perform the follow-up steps.
46-
if [ $exitcode -eq 0 ]; then
47-
echo "pull_result=pull-finished" >> $GITHUB_OUTPUT
48-
elif [ $exitcode -eq 2 ]; then
49-
echo "pull_result=skipped" >> $GITHUB_OUTPUT
50-
exitcode=0
51-
fi
52-
53-
exit ${exitcode}
54-
- name: Push changes to a branch
55-
if: ${{ steps.rustc-pull.outputs.pull_result == 'pull-finished' }}
56-
run: |
57-
# Update a sticky branch that is used only for rustc pulls
58-
BRANCH="rustc-pull"
59-
git switch -c $BRANCH
60-
git push -u origin $BRANCH --force
61-
- name: Create pull request
62-
id: update-pr
63-
if: ${{ steps.rustc-pull.outputs.pull_result == 'pull-finished' }}
64-
env:
65-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66-
run: |
67-
# Check if an open pull request for an rustc pull update already exists
68-
# If it does, the previous push has just updated it
69-
# If not, we create it now
70-
RESULT=`gh pr list --author github-actions[bot] --state open -q 'map(select(.title=="Rustc pull update")) | length' --json title`
71-
if [[ "$RESULT" -eq 0 ]]; then
72-
echo "Creating new pull request"
73-
PR_URL=`gh pr create -B master --title 'Rustc pull update' --body 'Latest update from rustc.'`
74-
echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT
75-
else
76-
PR_URL=`gh pr list --author github-actions[bot] --state open -q 'map(select(.title=="Rustc pull update")) | .[0].url' --json url,title`
77-
echo "Updating pull request ${PR_URL}"
78-
echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT
79-
fi
80-
send-zulip-message:
81-
needs: [pull]
82-
if: ${{ !cancelled() }}
83-
runs-on: ubuntu-latest
84-
steps:
85-
- uses: actions/checkout@v4
86-
- name: Compute message
87-
id: create-message
88-
env:
89-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90-
run: |
91-
if [ "${{ needs.pull.result }}" == "failure" ]; then
92-
WORKFLOW_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
93-
echo "message=Rustc pull sync failed. Check out the [workflow URL]($WORKFLOW_URL)." >> $GITHUB_OUTPUT
94-
else
95-
CREATED_AT=`gh pr list --author github-actions[bot] --state open -q 'map(select(.title=="Rustc pull update")) | .[0].createdAt' --json createdAt,title`
96-
PR_URL=`gh pr list --author github-actions[bot] --state open -q 'map(select(.title=="Rustc pull update")) | .[0].url' --json url,title`
97-
week_ago=$(date +%F -d '7 days ago')
98-
99-
# If there is an open PR that is at least a week old, post a message about it
100-
if [[ -n $DATE_GH && $DATE_GH < $week_ago ]]; then
101-
echo "message=A PR with a Rustc pull has been opened for more a week. Check out the [PR](${PR_URL})." >> $GITHUB_OUTPUT
102-
fi
103-
fi
104-
- name: Send a Zulip message about updated PR
105-
if: ${{ steps.create-message.outputs.message != '' }}
106-
uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5
107-
with:
108-
api-key: ${{ secrets.ZULIP_API_TOKEN }}
109-
email: "rustc-dev-guide-gha-notif-bot@rust-lang.zulipchat.com"
110-
organization-url: "https://rust-lang.zulipchat.com"
111-
to: 196385
112-
type: "stream"
113-
topic: "Subtree sync automation"
114-
content: ${{ steps.create-message.outputs.message }}
12+
uses: rust-lang/josh-sync/.github/workflows/rustc-pull.yml@main
13+
with:
14+
zulip-stream-id: 196385
15+
zulip-bot-email: "rustc-dev-guide-gha-notif-bot@rust-lang.zulipchat.com"
16+
pr-base-branch: master
17+
branch-name: rustc-pull
18+
secrets:
19+
zulip-api-token: ${{ secrets.ZULIP_API_TOKEN }}
20+
token: ${{ secrets.GITHUB_TOKEN }}

src/doc/rustc-dev-guide/README.md

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -72,49 +72,6 @@ including the `<!-- toc -->` marker at the place where you want the TOC.
7272

7373
## Synchronizing josh subtree with rustc
7474

75-
This repository is linked to `rust-lang/rust` as a [josh](https://josh-project.github.io/josh/intro.html) subtree. You can use the following commands to synchronize the subtree in both directions.
75+
This repository is linked to `rust-lang/rust` as a [josh](https://josh-project.github.io/josh/intro.html) subtree. You can use the [rustc-josh-sync](https://github.com/rust-lang/josh-sync) tool to perform synchronization.
7676

77-
You'll need to install `josh-proxy` locally via
78-
79-
```
80-
cargo install josh-proxy --git https://github.com/josh-project/josh --tag r24.10.04
81-
```
82-
Older versions of `josh-proxy` may not round trip commits losslessly so it is important to install this exact version.
83-
84-
### Pull changes from `rust-lang/rust` into this repository
85-
86-
1) Checkout a new branch that will be used to create a PR into `rust-lang/rustc-dev-guide`
87-
2) Run the pull command
88-
```
89-
cargo run --manifest-path josh-sync/Cargo.toml rustc-pull
90-
```
91-
3) Push the branch to your fork and create a PR into `rustc-dev-guide`
92-
93-
### Push changes from this repository into `rust-lang/rust`
94-
95-
NOTE: If you use Git protocol to push to your fork of `rust-lang/rust`,
96-
ensure that you have this entry in your Git config,
97-
else the 2 steps that follow would prompt for a username and password:
98-
99-
```
100-
[url "git@github.com:"]
101-
insteadOf = "https://github.com/"
102-
```
103-
104-
1) Run the push command to create a branch named `<branch-name>` in a `rustc` fork under the `<gh-username>` account
105-
```
106-
cargo run --manifest-path josh-sync/Cargo.toml rustc-push <branch-name> <gh-username>
107-
```
108-
2) Create a PR from `<branch-name>` into `rust-lang/rust`
109-
110-
#### Minimal git config
111-
112-
For simplicity (ease of implementation purposes), the josh-sync script simply calls out to system git. This means that the git invocation may be influenced by global (or local) git configuration.
113-
114-
You may observe "Nothing to pull" even if you *know* rustc-pull has something to pull if your global git config sets `fetch.prunetags = true` (and possibly other configurations may cause unexpected outcomes).
115-
116-
To minimize the likelihood of this happening, you may wish to keep a separate *minimal* git config that *only* has `[user]` entries from global git config, then repoint system git to use the minimal git config instead. E.g.
117-
118-
```
119-
GIT_CONFIG_GLOBAL=/path/to/minimal/gitconfig GIT_CONFIG_SYSTEM='' cargo run --manifest-path josh-sync/Cargo.toml -- rustc-pull
120-
```
77+
You can find a guide on how to perform the synchronization [here](./src/external-repos.md#synchronizing-a-josh-subtree).

0 commit comments

Comments
 (0)