Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add aarch64-apple-darwin builds to ci #21243

Merged
merged 13 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 67 additions & 23 deletions .github/workflows/ci.generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@ import * as yaml from "https://deno.land/[email protected]/encoding/yaml.ts";
// automatically via regex, so ensure that this line maintains this format.
const cacheVersion = 59;

const Runners = (() => {
const ubuntuRunner = "ubuntu-22.04";
const ubuntuXlRunner = "ubuntu-22.04-xl";
const windowsRunner = "windows-2022";
const windowsXlRunner = "windows-2022-xl";
const ubuntuRunner = "ubuntu-22.04";
const ubuntuXlRunner = "ubuntu-22.04-xl";
const windowsRunner = "windows-2022";
const windowsXlRunner = "windows-2022-xl";
const macosX86Runner = "macos-12";
// https://github.blog/2023-10-02-introducing-the-new-apple-silicon-powered-m1-macos-larger-runner-for-github-actions/
const macosArmRunner = "macos-13-xlarge";

const Runners = (() => {
return {
ubuntuXl:
`\${{ github.repository == 'denoland/deno' && '${ubuntuXlRunner}' || '${ubuntuRunner}' }}`,
ubuntu: ubuntuRunner,
linux: ubuntuRunner,
macos: "macos-12",
macos: macosX86Runner,
macosArm: macosArmRunner,
mmastrac marked this conversation as resolved.
Show resolved Hide resolved
windows: windowsRunner,
windowsXl:
`\${{ github.repository == 'denoland/deno' && '${windowsXlRunner}' || '${windowsRunner}' }}`,
Expand Down Expand Up @@ -199,7 +203,7 @@ function skipJobsIfPrAndMarkedSkip(
return steps.map((s) =>
withCondition(
s,
"!(github.event_name == 'pull_request' && matrix.skip_pr)",
"!(matrix.skip)",
)
);
}
Expand Down Expand Up @@ -235,6 +239,7 @@ function removeSurroundingExpression(text: string) {

function handleMatrixItems(items: {
skip_pr?: string | true;
skip?: string;
os: string;
profile?: string;
job?: string;
Expand All @@ -246,27 +251,40 @@ function handleMatrixItems(items: {
return "ubuntu-x86_64";
} else if (os.includes("windows")) {
return "windows-x86_64";
} else if (os.includes("macos")) {
} else if (os == macosX86Runner) {
return "macos-x86_64";
} else if (os == macosArmRunner) {
return "macos-aarch64";
} else {
throw new Error(`Display name not found: ${os}`);
}
}

return items.map((item) => {
// use a free "ubuntu" runner on jobs that are skipped on pull requests
// use a free "ubuntu" runner on jobs that are skipped

// skip_pr is shorthand for skip = github.event_name == 'pull_request'.
if (item.skip_pr != null) {
let text = "${{ github.event_name == 'pull_request' && ";
if (typeof item.skip_pr === "string") {
text += removeSurroundingExpression(item.skip_pr.toString()) + " && ";
if (item.skip_pr === true) {
item.skip = "${{ github.event_name == 'pull_request' }}";
} else if (typeof item.skip_pr === "string") {
item.skip = "${{ github.event_name == 'pull_request' && " +
removeSurroundingExpression(item.skip_pr.toString()) + " }}";
}
delete item.skip_pr;
}

if (typeof item.skip === "string") {
let text = "${{ (";
text += removeSurroundingExpression(item.skip.toString()) + ") && ";
text += `'${Runners.ubuntu}' || ${
removeSurroundingExpression(item.os)
} }}`;

// deno-lint-ignore no-explicit-any
(item as any).runner = text;
}

return {
...item,
os_display_name: getOsDisplayName(item.os),
Expand Down Expand Up @@ -343,6 +361,13 @@ const ci = {
job: "test",
profile: "release",
skip_pr: true,
}, {
os: Runners.macosArm,
job: "test",
profile: "release",
// TODO(mmastrac): We don't want to run this M1 runner on every main commit because of the expense.
skip:
"${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' }}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! In the future, perhaps we could have this also run infrequently on main.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might be able to do something silly like "if commit ID ends in zero, run aarch64 build"

}, {
os: Runners.windows,
job: "test",
Expand Down Expand Up @@ -497,6 +522,14 @@ const ci = {
if: "matrix.use_sysroot",
...sysRootStep,
},
{
name: "Install aarch64 lld",
run: [
"./tools/install_prebuilt.js ld64.lld",
"echo $GITHUB_WORKSPACE/third_party/prebuilt/mac >> $GITHUB_PATH",
].join("\n"),
if: `matrix.os == '${macosArmRunner}'`,
},
{
name: "Log versions",
run: [
Expand Down Expand Up @@ -601,9 +634,7 @@ const ci = {
if: [
"(matrix.job == 'test' || matrix.job == 'bench') &&",
"matrix.profile == 'release' && (matrix.use_sysroot ||",
"(github.repository == 'denoland/deno' &&",
"(github.ref == 'refs/heads/main' ||",
"startsWith(github.ref, 'refs/tags/'))))",
"github.repository == 'denoland/deno')",
].join("\n"),
run: [
// output fs space before and after building
Expand Down Expand Up @@ -642,28 +673,40 @@ const ci = {
].join("\n"),
},
{
name: "Pre-release (mac)",
name: "Pre-release (mac intel)",
if: [
"startsWith(matrix.os, 'macOS') &&",
`matrix.os == '${macosX86Runner}' &&`,
"matrix.job == 'test' &&",
"matrix.profile == 'release' &&",
"github.repository == 'denoland/deno' &&",
"(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))",
"github.repository == 'denoland/deno'",
].join("\n"),
run: [
"cd target/release",
"zip -r deno-x86_64-apple-darwin.zip deno",
]
.join("\n"),
},
{
name: "Pre-release (mac aarch64)",
if: [
`matrix.os == '${macosArmRunner}' &&`,
"matrix.job == 'test' &&",
"matrix.profile == 'release' &&",
"github.repository == 'denoland/deno'",
].join("\n"),
run: [
"cd target/release",
"zip -r deno-aarch64-apple-darwin.zip deno",
]
.join("\n"),
},
{
name: "Pre-release (windows)",
if: [
"startsWith(matrix.os, 'windows') &&",
"matrix.job == 'test' &&",
"matrix.profile == 'release' &&",
"github.repository == 'denoland/deno' &&",
"(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))",
"github.repository == 'denoland/deno'",
].join("\n"),
shell: "pwsh",
run:
Expand Down Expand Up @@ -718,7 +761,7 @@ const ci = {
name: "Test debug (fast)",
if: [
"matrix.job == 'test' && matrix.profile == 'debug' &&",
"!startsWith(matrix.os, 'ubuntu')",
"(startsWith(github.ref, 'refs/tags/') || !startsWith(matrix.os, 'ubuntu'))",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were skipping test debug on ubuntu for tag builds

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this was done on purpose to limit CI run time for tags.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit odd because we run the fast tests on every other platform, but ubuntu (the fastest runner) doesn't. It kind of feels like an accidental bit of logic.

].join("\n"),
run: [
// Run unit then integration tests. Skip doc tests here
Expand All @@ -734,7 +777,7 @@ const ci = {
"matrix.job == 'test' && matrix.profile == 'release' &&",
"(matrix.use_sysroot || (",
"github.repository == 'denoland/deno' &&",
"github.ref == 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')))",
"!startsWith(github.ref, 'refs/tags/')))",
].join("\n"),
run: "cargo test --release --locked",
},
Expand Down Expand Up @@ -939,6 +982,7 @@ const ci = {
"target/release/deno-x86_64-pc-windows-msvc.zip",
"target/release/deno-x86_64-unknown-linux-gnu.zip",
"target/release/deno-x86_64-apple-darwin.zip",
"target/release/deno-aarch64-apple-darwin.zip",
"target/release/deno_src.tar.gz",
"target/release/lib.deno.d.ts",
].join("\n"),
Expand Down
Loading