Skip to content

Commit

Permalink
Merge branch 'master' into promote-rustup
Browse files Browse the repository at this point in the history
  • Loading branch information
jdno committed Oct 2, 2024
2 parents a52f975 + 110ad45 commit 2020439
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 47 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ jobs:
run: rustup self update && rustup update stable

- name: Start the local environment
run: docker-compose up -d
run: docker compose up -d

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

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

- name: Remove the previously installed ${{ matrix.channel }} toolchain
run: rustup toolchain remove ${{ matrix.channel }}
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
if: github.event_name == 'push' && github.repository == 'rust-lang/promote-release' && github.ref == 'refs/heads/master'

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

steps:
- name: Download the Docker image previously built
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: docker-image

Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
version: '3'

services:
minio:
image: quay.io/minio/minio:RELEASE.2023-04-13T03-08-07Z
Expand Down
6 changes: 3 additions & 3 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fi
channel="$2"
override_commit="${3-}"

container_id="$(docker-compose ps -q local)"
container_id="$(docker compose ps -q local)"
if [[ "${container_id}" == "" ]]; then
container_status="missing"
else
Expand All @@ -38,7 +38,7 @@ if [[ "${container_status}" != "running" ]]; then
echo "Error: the local environment is not running!"
echo "You can start it by running in a new terminal the following command:"
echo
echo " docker-compose up"
echo " docker compose up"
echo
exit 1
fi
Expand All @@ -49,4 +49,4 @@ if [[ "$(uname)" == "Linux" ]]; then
fi

# Run the command inside the docker environment.
docker-compose exec -T local "/src/local/${command}.sh" "${channel}" "${override_commit}"
docker compose exec -T local /src/local/run.sh "${channel}" "${override_commit}"
77 changes: 40 additions & 37 deletions src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,51 +355,48 @@ impl RepositoryClient<'_> {
start: &str,
path: &str,
) -> anyhow::Result<FullCommitData> {
self.start_new_request()?;
self.client.get(true)?;
self.client.url(&format!(
"https://api.github.com/repos/{repo}/commits/{start}",
repo = self.repo
))?;
let resolved_start = self
.client
.without_body()
.send_with_response::<CommitData>()?
.sha;
for page in 1..20 {
const MAX_COMMITS: usize = 200;
const BORS_EMAIL: &str = "[email protected]";

let mut commit = start.to_string();
let mut scanned_commits = 0;
for _ in 0..MAX_COMMITS {
scanned_commits += 1;

self.start_new_request()?;
self.client.get(true)?;
self.client.url(&format!(
"https://api.github.com/repos/{repo}/commits?sha={resolved_start}&per_page=100&page={page}&author=bors",
"https://api.github.com/repos/{repo}/commits/{commit}",
repo = self.repo
))?;
let commits = self

let commit_data = self
.client
.without_body()
.send_with_response::<Vec<CommitData>>()?;
for commit in commits {
self.start_new_request()?;
self.client.get(true)?;
self.client.url(&format!(
"https://api.github.com/repos/{repo}/commits/{sha}",
repo = self.repo,
sha = commit.sha,
))?;
let commit = self
.client
.without_body()
.send_with_response::<FullCommitData>()?;
if commit.files.iter().any(|f| f.filename == path) {
return Ok(commit);
}
.send_with_response::<FullCommitData>()?;

// We pick the *first* parent commit to continue walking through the commit graph. In
// a merge commit, the first parent is always the merge base (i.e. the master branch),
// while the second parent is always the branch being merged in.
//
// This is important because we only want bors merge commits for branches merged into
// Rust's master branch, not bors merge commits in subtrees being pulled in.
let Some(parent) = &commit_data.parents.first() else {
break;
};
commit.clone_from(&parent.sha);

if commit_data.commit.author.email != BORS_EMAIL {
continue;
}
if commit_data.files.iter().any(|f| f.filename == path) {
return Ok(commit_data);
}
}

anyhow::bail!(
"Failed to find bors commit touching {:?} in start={} ancestors (scanned {} commits)",
path,
start,
20 * 100,
"Failed to find bors commit touching {path:?} in \
start={start} ancestors (scanned {scanned_commits} commits)"
);
}

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

#[derive(serde::Deserialize)]
pub(crate) struct FullCommitData {
#[allow(unused)]
#[cfg_attr(not(test), allow(unused))]
pub(crate) sha: String,
pub(crate) parents: Vec<CommitParent>,
pub(crate) commit: CommitCommit,
pub(crate) files: Vec<CommitFile>,
}

#[derive(serde::Deserialize)]
pub(crate) struct CommitData {
pub(crate) sha: String,
pub(crate) struct CommitCommit {
pub(crate) author: CommitAuthor,
}

#[derive(serde::Deserialize)]
pub(crate) struct CommitAuthor {
pub(crate) email: String,
}

#[derive(serde::Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ impl Context {
.arg("cp")
.arg("--recursive")
.arg("--only-show-errors")
.arg(&self.s3_artifacts_url(&format!("{}/", rev)))
.arg(self.s3_artifacts_url(&format!("{}/", rev)))
.arg(format!("{}/", dl.display())))?;

let mut files = dl.read_dir()?;
Expand Down

0 comments on commit 2020439

Please sign in to comment.