Unnamed repository; edit this file 'description' to name the repository.
Support specific revisions for pgo
Laurențiu Nicola 2025-04-18
parent ed737b5 · commit 0ba49a3
-rw-r--r--.github/workflows/release.yaml12
-rw-r--r--xtask/src/dist.rs20
2 files changed, 20 insertions, 12 deletions
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 97c4987992..a758ecfd46 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -29,10 +29,10 @@ jobs:
- os: windows-latest
target: x86_64-pc-windows-msvc
code-target: win32-x64
- pgo: clap-rs/clap
+ pgo: clap-rs/[email protected]
- os: windows-latest
target: i686-pc-windows-msvc
- pgo: clap-rs/clap
+ pgo: clap-rs/[email protected]
- os: windows-latest
target: aarch64-pc-windows-msvc
code-target: win32-arm64
@@ -42,12 +42,12 @@ jobs:
# Zig is not used because it doesn't work with PGO
container: quay.io/pypa/manylinux_2_28_x86_64
code-target: linux-x64
- pgo: clap-rs/clap
+ pgo: clap-rs/[email protected]
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
container: quay.io/pypa/manylinux_2_28_aarch64
code-target: linux-arm64
- pgo: clap-rs/clap
+ pgo: clap-rs/[email protected]
- os: ubuntu-latest
target: arm-unknown-linux-gnueabihf
zig_target: arm-unknown-linux-gnueabihf.2.28
@@ -55,11 +55,11 @@ jobs:
- os: macos-13
target: x86_64-apple-darwin
code-target: darwin-x64
- pgo: clap-rs/clap
+ pgo: clap-rs/[email protected]
- os: macos-14
target: aarch64-apple-darwin
code-target: darwin-arm64
- pgo: clap-rs/clap
+ pgo: clap-rs/[email protected]
name: dist (${{ matrix.target }})
runs-on: ${{ matrix.os }}
diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs
index 7e26167725..b3d6f06b07 100644
--- a/xtask/src/dist.rs
+++ b/xtask/src/dist.rs
@@ -180,8 +180,8 @@ fn gather_pgo_profile<'a>(
let (train_path, label) = match &train_crate {
PgoTrainingCrate::RustAnalyzer => (PathBuf::from("."), "itself"),
- PgoTrainingCrate::GitHub(url) => {
- (download_crate_for_training(sh, &pgo_dir, url)?, url.as_str())
+ PgoTrainingCrate::GitHub(repo) => {
+ (download_crate_for_training(sh, &pgo_dir, repo)?, repo.as_str())
}
};
@@ -212,12 +212,20 @@ fn gather_pgo_profile<'a>(
}
/// Downloads a crate from GitHub, stores it into `pgo_dir` and returns a path to it.
-fn download_crate_for_training(sh: &Shell, pgo_dir: &Path, url: &str) -> anyhow::Result<PathBuf> {
- let normalized_path = url.replace("/", "-");
+fn download_crate_for_training(sh: &Shell, pgo_dir: &Path, repo: &str) -> anyhow::Result<PathBuf> {
+ let mut it = repo.splitn(2, '@');
+ let repo = it.next().unwrap();
+ let revision = it.next();
+
+ // FIXME: switch to `--revision` here around 2035 or so
+ let revision =
+ if let Some(revision) = revision { &["--branch", revision] as &[&str] } else { &[] };
+
+ let normalized_path = repo.replace("/", "-");
let target_path = pgo_dir.join(normalized_path);
- cmd!(sh, "git clone --depth 1 https://github.com/{url} {target_path}")
+ cmd!(sh, "git clone --depth 1 https://github.com/{repo} {revision...} {target_path}")
.run()
- .with_context(|| "cannot download PGO training crate from {url}")?;
+ .with_context(|| "cannot download PGO training crate from {repo}")?;
Ok(target_path)
}