Skip to content

Commit 4b64c3b

Browse files
committed
Merge branch 'master' into promote-rustup
2 parents a52f975 + 110ad45 commit 4b64c3b

File tree

5 files changed

+49
-48
lines changed

5 files changed

+49
-48
lines changed

.github/workflows/ci.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ jobs:
4545
run: rustup self update && rustup update stable
4646

4747
- name: Start the local environment
48-
run: docker-compose up -d
48+
run: docker compose up -d
4949

5050
- name: Run the local release process for channel ${{ matrix.channel }}
5151
run: ./run.sh release ${{ matrix.channel }}
5252

5353
- name: Validate the generated signatures
54-
run: docker-compose exec -T local /src/local/check-signature.sh ${{ matrix.channel }}
54+
run: docker compose exec -T local /src/local/check-signature.sh ${{ matrix.channel }}
5555

5656
- name: Remove the previously installed ${{ matrix.channel }} toolchain
5757
run: rustup toolchain remove ${{ matrix.channel }}
@@ -78,7 +78,7 @@ jobs:
7878
run: rustup self update && rustup update stable
7979

8080
- name: Start the local environment
81-
run: docker-compose up -d
81+
run: docker compose up -d
8282

8383
- name: Run the local release process for channel ${{ matrix.channel }}
8484
run: ./run.sh rustup ${{ matrix.channel }}
@@ -104,7 +104,7 @@ jobs:
104104
if: github.event_name == 'push' && github.repository == 'rust-lang/promote-release' && github.ref == 'refs/heads/master'
105105

106106
- name: Upload the Docker image we built to GitHub Actions artifacts
107-
uses: actions/upload-artifact@v2
107+
uses: actions/upload-artifact@v4
108108
with:
109109
name: docker-image
110110
path: promote-release.tar.zstd
@@ -122,7 +122,7 @@ jobs:
122122

123123
steps:
124124
- name: Download the Docker image previously built
125-
uses: actions/download-artifact@v3
125+
uses: actions/download-artifact@v4
126126
with:
127127
name: docker-image
128128

docker-compose.yml

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
---
2-
version: '3'
3-
42
services:
53
minio:
64
image: quay.io/minio/minio:RELEASE.2023-04-13T03-08-07Z

run.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fi
2828
channel="$2"
2929
override_commit="${3-}"
3030

31-
container_id="$(docker-compose ps -q local)"
31+
container_id="$(docker compose ps -q local)"
3232
if [[ "${container_id}" == "" ]]; then
3333
container_status="missing"
3434
else
@@ -38,7 +38,7 @@ if [[ "${container_status}" != "running" ]]; then
3838
echo "Error: the local environment is not running!"
3939
echo "You can start it by running in a new terminal the following command:"
4040
echo
41-
echo " docker-compose up"
41+
echo " docker compose up"
4242
echo
4343
exit 1
4444
fi
@@ -49,4 +49,4 @@ if [[ "$(uname)" == "Linux" ]]; then
4949
fi
5050

5151
# Run the command inside the docker environment.
52-
docker-compose exec -T local "/src/local/${command}.sh" "${channel}" "${override_commit}"
52+
docker compose exec -T local /src/local/run.sh "${channel}" "${override_commit}"

src/github.rs

+40-37
Original file line numberDiff line numberDiff line change
@@ -355,51 +355,48 @@ impl RepositoryClient<'_> {
355355
start: &str,
356356
path: &str,
357357
) -> anyhow::Result<FullCommitData> {
358-
self.start_new_request()?;
359-
self.client.get(true)?;
360-
self.client.url(&format!(
361-
"https://api.github.com/repos/{repo}/commits/{start}",
362-
repo = self.repo
363-
))?;
364-
let resolved_start = self
365-
.client
366-
.without_body()
367-
.send_with_response::<CommitData>()?
368-
.sha;
369-
for page in 1..20 {
358+
const MAX_COMMITS: usize = 200;
359+
const BORS_EMAIL: &str = "[email protected]";
360+
361+
let mut commit = start.to_string();
362+
let mut scanned_commits = 0;
363+
for _ in 0..MAX_COMMITS {
364+
scanned_commits += 1;
365+
370366
self.start_new_request()?;
371367
self.client.get(true)?;
372368
self.client.url(&format!(
373-
"https://api.github.com/repos/{repo}/commits?sha={resolved_start}&per_page=100&page={page}&author=bors",
369+
"https://api.github.com/repos/{repo}/commits/{commit}",
374370
repo = self.repo
375371
))?;
376-
let commits = self
372+
373+
let commit_data = self
377374
.client
378375
.without_body()
379-
.send_with_response::<Vec<CommitData>>()?;
380-
for commit in commits {
381-
self.start_new_request()?;
382-
self.client.get(true)?;
383-
self.client.url(&format!(
384-
"https://api.github.com/repos/{repo}/commits/{sha}",
385-
repo = self.repo,
386-
sha = commit.sha,
387-
))?;
388-
let commit = self
389-
.client
390-
.without_body()
391-
.send_with_response::<FullCommitData>()?;
392-
if commit.files.iter().any(|f| f.filename == path) {
393-
return Ok(commit);
394-
}
376+
.send_with_response::<FullCommitData>()?;
377+
378+
// We pick the *first* parent commit to continue walking through the commit graph. In
379+
// a merge commit, the first parent is always the merge base (i.e. the master branch),
380+
// while the second parent is always the branch being merged in.
381+
//
382+
// This is important because we only want bors merge commits for branches merged into
383+
// Rust's master branch, not bors merge commits in subtrees being pulled in.
384+
let Some(parent) = &commit_data.parents.first() else {
385+
break;
386+
};
387+
commit.clone_from(&parent.sha);
388+
389+
if commit_data.commit.author.email != BORS_EMAIL {
390+
continue;
391+
}
392+
if commit_data.files.iter().any(|f| f.filename == path) {
393+
return Ok(commit_data);
395394
}
396395
}
397396

398397
anyhow::bail!(
399-
"Failed to find bors commit touching {:?} in start={} ancestors (scanned {} commits)",
400-
path,
401-
start,
402-
20 * 100,
398+
"Failed to find bors commit touching {path:?} in \
399+
start={start} ancestors (scanned {scanned_commits} commits)"
403400
);
404401
}
405402

@@ -511,15 +508,21 @@ pub(crate) struct CreateTag<'a> {
511508

512509
#[derive(serde::Deserialize)]
513510
pub(crate) struct FullCommitData {
514-
#[allow(unused)]
511+
#[cfg_attr(not(test), allow(unused))]
515512
pub(crate) sha: String,
516513
pub(crate) parents: Vec<CommitParent>,
514+
pub(crate) commit: CommitCommit,
517515
pub(crate) files: Vec<CommitFile>,
518516
}
519517

520518
#[derive(serde::Deserialize)]
521-
pub(crate) struct CommitData {
522-
pub(crate) sha: String,
519+
pub(crate) struct CommitCommit {
520+
pub(crate) author: CommitAuthor,
521+
}
522+
523+
#[derive(serde::Deserialize)]
524+
pub(crate) struct CommitAuthor {
525+
pub(crate) email: String,
523526
}
524527

525528
#[derive(serde::Deserialize)]

src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ impl Context {
380380
.arg("cp")
381381
.arg("--recursive")
382382
.arg("--only-show-errors")
383-
.arg(&self.s3_artifacts_url(&format!("{}/", rev)))
383+
.arg(self.s3_artifacts_url(&format!("{}/", rev)))
384384
.arg(format!("{}/", dl.display())))?;
385385

386386
let mut files = dl.read_dir()?;

0 commit comments

Comments
 (0)