Skip to content

Commit

Permalink
fix: canary for arm64 macos (denoland#22187)
Browse files Browse the repository at this point in the history
This doesn't actually trigger the arm64 build job nightly yet. I'll do
that in a follow up.
  • Loading branch information
lucacasonato committed Jan 30, 2024
1 parent d730956 commit d923705
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 47 deletions.
21 changes: 4 additions & 17 deletions .github/workflows/ci.generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,31 +747,18 @@ const ci = {
"Compress-Archive -CompressionLevel Optimal -Force -Path target/release/deno.exe -DestinationPath target/release/deno-x86_64-pc-windows-msvc.zip",
},
{
name: "Upload canary to dl.deno.land (unix)",
name: "Upload canary to dl.deno.land",
if: [
"runner.os != 'Windows' &&",
"matrix.job == 'test' &&",
"matrix.profile == 'release' &&",
"github.repository == 'denoland/deno' &&",
"github.ref == 'refs/heads/main'",
].join("\n"),
run:
run: [
'gsutil -h "Cache-Control: public, max-age=3600" cp ./target/release/*.zip gs:https://dl.deno.land/canary/$(git rev-parse HEAD)/',
},
{
name: "Upload canary to dl.deno.land (windows)",
if: [
"runner.os == 'Windows' &&",
"matrix.job == 'test' &&",
"matrix.profile == 'release' &&",
"github.repository == 'denoland/deno' &&",
"github.ref == 'refs/heads/main'",
"echo ${{ github.sha }} > canary-latest.txt",
'gsutil -h "Cache-Control: no-cache" cp canary-latest.txt gs:https://dl.deno.land/canary-$(rustc -vV | sed -n "s|host: ||p")-latest.txt',
].join("\n"),
env: {
CLOUDSDK_PYTHON: "${{env.pythonLocation}}\\python.exe",
},
run:
'gsutil -h "Cache-Control: public, max-age=3600" cp ./target/release/*.zip gs:https://dl.deno.land/canary/$(git rev-parse HEAD)/',
},
{
name: "Autobahn testsuite",
Expand Down
20 changes: 6 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -437,24 +437,16 @@ jobs:
github.repository == 'denoland/deno')
shell: pwsh
run: Compress-Archive -CompressionLevel Optimal -Force -Path target/release/deno.exe -DestinationPath target/release/deno-x86_64-pc-windows-msvc.zip
- name: Upload canary to dl.deno.land (unix)
- name: Upload canary to dl.deno.land
if: |-
!(matrix.skip) && (runner.os != 'Windows' &&
matrix.job == 'test' &&
matrix.profile == 'release' &&
github.repository == 'denoland/deno' &&
github.ref == 'refs/heads/main')
run: 'gsutil -h "Cache-Control: public, max-age=3600" cp ./target/release/*.zip gs:https://dl.deno.land/canary/$(git rev-parse HEAD)/'
- name: Upload canary to dl.deno.land (windows)
if: |-
!(matrix.skip) && (runner.os == 'Windows' &&
matrix.job == 'test' &&
!(matrix.skip) && (matrix.job == 'test' &&
matrix.profile == 'release' &&
github.repository == 'denoland/deno' &&
github.ref == 'refs/heads/main')
env:
CLOUDSDK_PYTHON: '${{env.pythonLocation}}\python.exe'
run: 'gsutil -h "Cache-Control: public, max-age=3600" cp ./target/release/*.zip gs:https://dl.deno.land/canary/$(git rev-parse HEAD)/'
run: |-
gsutil -h "Cache-Control: public, max-age=3600" cp ./target/release/*.zip gs:https://dl.deno.land/canary/$(git rev-parse HEAD)/
echo ${{ github.sha }} > canary-latest.txt
gsutil -h "Cache-Control: no-cache" cp canary-latest.txt gs:https://dl.deno.land/canary-$(rustc -vV | sed -n "s|host: ||p")-latest.txt
- name: Autobahn testsuite
if: |-
!(matrix.skip) && (matrix.job == 'test' && matrix.profile == 'release' &&
Expand Down
77 changes: 61 additions & 16 deletions cli/tools/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,12 +483,6 @@ pub async fn upgrade(
};

let download_url = if upgrade_flags.canary {
// NOTE(bartlomieju): to keep clippy happy on M1 macs.
#[allow(clippy::eq_op)]
if env!("TARGET") == "aarch64-apple-darwin" {
bail!("Canary builds are not available for M1/M2");
}

format!(
"https://dl.deno.land/canary/{}/{}",
install_version, *ARCHIVE_NAME
Expand All @@ -502,7 +496,7 @@ pub async fn upgrade(

let archive_data = download_package(client, &download_url)
.await
.with_context(|| format!("Failed downloading {download_url}"))?;
.with_context(|| format!("Failed downloading {download_url}. The version you requested may not have been built for the current architechture."))?;

log::info!("Deno is upgrading to version {}", &install_version);

Expand Down Expand Up @@ -568,7 +562,7 @@ async fn get_latest_version(
release_kind: UpgradeReleaseKind,
check_kind: UpgradeCheckKind,
) -> Result<String, AnyError> {
let url = get_url(release_kind, check_kind);
let url = get_url(release_kind, env!("TARGET"), check_kind);
let text = client.download_text(url).await?;
Ok(normalize_version_from_server(release_kind, &text))
}
Expand All @@ -586,11 +580,14 @@ fn normalize_version_from_server(

fn get_url(
release_kind: UpgradeReleaseKind,
target_tuple: &str,
check_kind: UpgradeCheckKind,
) -> String {
let file_name = match release_kind {
UpgradeReleaseKind::Stable => "release-latest.txt",
UpgradeReleaseKind::Canary => "canary-latest.txt",
UpgradeReleaseKind::Stable => Cow::Borrowed("release-latest.txt"),
UpgradeReleaseKind::Canary => {
Cow::Owned(format!("canary-{target_tuple}-latest.txt"))
}
};
let query_param = match check_kind {
UpgradeCheckKind::Execution => "",
Expand Down Expand Up @@ -1024,19 +1021,67 @@ mod test {
#[test]
fn test_get_url() {
assert_eq!(
get_url(UpgradeReleaseKind::Canary, UpgradeCheckKind::Execution),
"https://dl.deno.land/canary-latest.txt"
get_url(
UpgradeReleaseKind::Canary,
"aarch64-apple-darwin",
UpgradeCheckKind::Execution
),
"https://dl.deno.land/canary-aarch64-apple-darwin-latest.txt"
);
assert_eq!(
get_url(UpgradeReleaseKind::Canary, UpgradeCheckKind::Lsp),
"https://dl.deno.land/canary-latest.txt?lsp"
get_url(
UpgradeReleaseKind::Canary,
"aarch64-apple-darwin",
UpgradeCheckKind::Lsp
),
"https://dl.deno.land/canary-aarch64-apple-darwin-latest.txt?lsp"
);
assert_eq!(
get_url(
UpgradeReleaseKind::Canary,
"x86_64-pc-windows-msvc",
UpgradeCheckKind::Execution
),
"https://dl.deno.land/canary-x86_64-pc-windows-msvc-latest.txt"
);
assert_eq!(
get_url(
UpgradeReleaseKind::Canary,
"x86_64-pc-windows-msvc",
UpgradeCheckKind::Lsp
),
"https://dl.deno.land/canary-x86_64-pc-windows-msvc-latest.txt?lsp"
);
assert_eq!(
get_url(UpgradeReleaseKind::Stable, UpgradeCheckKind::Execution),
get_url(
UpgradeReleaseKind::Stable,
"aarch64-apple-darwin",
UpgradeCheckKind::Execution
),
"https://dl.deno.land/release-latest.txt"
);
assert_eq!(
get_url(
UpgradeReleaseKind::Stable,
"aarch64-apple-darwin",
UpgradeCheckKind::Lsp
),
"https://dl.deno.land/release-latest.txt?lsp"
);
assert_eq!(
get_url(
UpgradeReleaseKind::Stable,
"x86_64-pc-windows-msvc",
UpgradeCheckKind::Execution
),
"https://dl.deno.land/release-latest.txt"
);
assert_eq!(
get_url(UpgradeReleaseKind::Stable, UpgradeCheckKind::Lsp),
get_url(
UpgradeReleaseKind::Stable,
"x86_64-pc-windows-msvc",
UpgradeCheckKind::Lsp
),
"https://dl.deno.land/release-latest.txt?lsp"
);
}
Expand Down

0 comments on commit d923705

Please sign in to comment.