1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

ci: use non-XL runners more (#18675)

![image](https://user-images.githubusercontent.com/1609021/231593822-b9d7c9db-4416-4735-bd89-f28a260607f1.png)

Non-xl runners are faster than the linux xl job, so let's use them for
now

Closes #17103
This commit is contained in:
David Sherret 2023-04-13 05:44:39 -04:00 committed by Levente Kurusa
parent b3ff0eaee0
commit dc37f414ee
No known key found for this signature in database
GPG key ID: 9F72F3C05BA137C4
2 changed files with 125 additions and 72 deletions

View file

@ -2,14 +2,19 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import * as yaml from "https://deno.land/std@0.173.0/encoding/yaml.ts"; import * as yaml from "https://deno.land/std@0.173.0/encoding/yaml.ts";
const windowsRunnerCondition = const Runners = (() => {
"github.repository == 'denoland/deno' && 'windows-2022-xl' || 'windows-2022'"; const ubuntuRunner = "ubuntu-22.04";
const Runners = { const ubuntuXlRunner = "ubuntu-22.04-xl";
linux:
"${{ github.repository == 'denoland/deno' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}", return {
ubuntuXl:
`\${{ github.repository == 'denoland/deno' && '${ubuntuXlRunner}' || '${ubuntuRunner}' }}`,
ubuntu: ubuntuRunner,
linux: ubuntuRunner,
macos: "macos-12", macos: "macos-12",
windows: `\${{ ${windowsRunnerCondition} }}`, windows: "windows-2022",
}; };
})();
// bump the number at the start when you want to purge the cache // bump the number at the start when you want to purge the cache
const prCacheKeyPrefix = const prCacheKeyPrefix =
"18-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ matrix.job }}-"; "18-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ matrix.job }}-";
@ -184,6 +189,55 @@ function withCondition(
}; };
} }
function removeSurroundingExpression(text: string) {
if (text.startsWith("${{")) {
return text.replace(/^\${{/, "").replace(/}}$/, "").trim();
} else {
return `'${text}'`;
}
}
function handleMatrixItems(items: {
skip_pr?: string | true;
os: string;
profile?: string;
job?: string;
use_sysroot?: boolean;
wpt?: string;
}[]) {
function getOsDisplayName(os: string) {
if (os.includes("ubuntu")) {
return "ubuntu-x86_64";
} else if (os.includes("windows")) {
return "windows-x86_64";
} else if (os.includes("macos")) {
return "macos-x86_64";
} 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
if (item.skip_pr != null) {
let text = "${{ github.event_name == 'pull_request' && ";
if (typeof item.skip_pr === "string") {
text += removeSurroundingExpression(item.skip_pr.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),
};
});
}
const ci = { const ci = {
name: "ci", name: "ci",
on: { on: {
@ -229,7 +283,8 @@ const ci = {
]), ]),
}, },
build: { build: {
name: "${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os }}", name:
"${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os_display_name }}",
needs: ["pre_build"], needs: ["pre_build"],
if: "${{ needs.pre_build.outputs.skip_build != 'true' }}", if: "${{ needs.pre_build.outputs.skip_build != 'true' }}",
"runs-on": "${{ matrix.runner || matrix.os }}", "runs-on": "${{ matrix.runner || matrix.os }}",
@ -243,63 +298,51 @@ const ci = {
}, },
strategy: { strategy: {
matrix: { matrix: {
include: [ include: handleMatrixItems([{
{
os: Runners.macos, os: Runners.macos,
job: "test", job: "test",
profile: "debug", profile: "debug",
}, }, {
{
os: Runners.macos, os: Runners.macos,
job: "test", job: "test",
profile: "release", profile: "release",
skip_pr: true, skip_pr: true,
}, }, {
{
os: Runners.windows, os: Runners.windows,
job: "test", job: "test",
profile: "debug", profile: "debug",
}, }, {
{
os: Runners.windows, os: Runners.windows,
// use a free runner on PRs since this will be skipped
runner:
`\${{ github.event_name == 'pull_request' && 'windows-2022' || (${windowsRunnerCondition}) }}`,
job: "test", job: "test",
profile: "release", profile: "release",
skip_pr: true, skip_pr: true,
}, }, {
{ os: Runners.ubuntuXl,
os: Runners.linux,
job: "test", job: "test",
profile: "release", profile: "release",
use_sysroot: true, use_sysroot: true,
// TODO(ry): Because CI is so slow on for OSX and Windows, we // TODO(ry): Because CI is so slow on for OSX and Windows, we
// currently run the Web Platform tests only on Linux. // currently run the Web Platform tests only on Linux.
wpt: "${{ !startsWith(github.ref, 'refs/tags/') }}", wpt: "${{ !startsWith(github.ref, 'refs/tags/') }}",
}, }, {
{ os: Runners.ubuntuXl,
os: Runners.linux,
job: "bench", job: "bench",
profile: "release", profile: "release",
use_sysroot: true, use_sysroot: true,
skip_pr: skip_pr:
"${{ !contains(github.event.pull_request.labels.*.name, 'ci-bench') }}", "${{ !contains(github.event.pull_request.labels.*.name, 'ci-bench') }}",
}, }, {
{ os: Runners.ubuntu,
os: Runners.linux,
job: "test", job: "test",
profile: "debug", profile: "debug",
use_sysroot: true, use_sysroot: true,
wpt: wpt:
"${{ github.ref == 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/') }}", "${{ github.ref == 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/') }}",
}, }, {
{ os: Runners.ubuntu,
os: Runners.linux,
job: "lint", job: "lint",
profile: "debug", profile: "debug",
}, }]),
],
}, },
// Always run main branch builds to completion. This allows the cache to // Always run main branch builds to completion. This allows the cache to
// stay mostly up-to-date in situations where a single job fails due to // stay mostly up-to-date in situations where a single job fails due to

View file

@ -41,7 +41,7 @@ jobs:
echo $GIT_MESSAGE | grep '\[ci\]' || (echo 'Exiting due to draft PR. Commit with [ci] to bypass.' ; echo 'skip_build=true' >> $GITHUB_OUTPUT) echo $GIT_MESSAGE | grep '\[ci\]' || (echo 'Exiting due to draft PR. Commit with [ci] to bypass.' ; echo 'skip_build=true' >> $GITHUB_OUTPUT)
if: github.event.pull_request.draft == true if: github.event.pull_request.draft == true
build: build:
name: '${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os }}' name: '${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os_display_name }}'
needs: needs:
- pre_build - pre_build
if: '${{ needs.pre_build.outputs.skip_build != ''true'' }}' if: '${{ needs.pre_build.outputs.skip_build != ''true'' }}'
@ -56,36 +56,46 @@ jobs:
- os: macos-12 - os: macos-12
job: test job: test
profile: debug profile: debug
os_display_name: macos-x86_64
- os: macos-12 - os: macos-12
job: test job: test
profile: release profile: release
skip_pr: true skip_pr: true
- os: '${{ github.repository == ''denoland/deno'' && ''windows-2022-xl'' || ''windows-2022'' }}' runner: '${{ github.event_name == ''pull_request'' && ''ubuntu-22.04'' || ''macos-12'' }}'
os_display_name: macos-x86_64
- os: windows-2022
job: test job: test
profile: debug profile: debug
- os: '${{ github.repository == ''denoland/deno'' && ''windows-2022-xl'' || ''windows-2022'' }}' os_display_name: windows-x86_64
runner: '${{ github.event_name == ''pull_request'' && ''windows-2022'' || (github.repository == ''denoland/deno'' && ''windows-2022-xl'' || ''windows-2022'') }}' - os: windows-2022
job: test job: test
profile: release profile: release
skip_pr: true skip_pr: true
runner: '${{ github.event_name == ''pull_request'' && ''ubuntu-22.04'' || ''windows-2022'' }}'
os_display_name: windows-x86_64
- os: '${{ github.repository == ''denoland/deno'' && ''ubuntu-22.04-xl'' || ''ubuntu-22.04'' }}' - os: '${{ github.repository == ''denoland/deno'' && ''ubuntu-22.04-xl'' || ''ubuntu-22.04'' }}'
job: test job: test
profile: release profile: release
use_sysroot: true use_sysroot: true
wpt: '${{ !startsWith(github.ref, ''refs/tags/'') }}' wpt: '${{ !startsWith(github.ref, ''refs/tags/'') }}'
os_display_name: ubuntu-x86_64
- os: '${{ github.repository == ''denoland/deno'' && ''ubuntu-22.04-xl'' || ''ubuntu-22.04'' }}' - os: '${{ github.repository == ''denoland/deno'' && ''ubuntu-22.04-xl'' || ''ubuntu-22.04'' }}'
job: bench job: bench
profile: release profile: release
use_sysroot: true use_sysroot: true
skip_pr: '${{ !contains(github.event.pull_request.labels.*.name, ''ci-bench'') }}' skip_pr: '${{ !contains(github.event.pull_request.labels.*.name, ''ci-bench'') }}'
- os: '${{ github.repository == ''denoland/deno'' && ''ubuntu-22.04-xl'' || ''ubuntu-22.04'' }}' runner: '${{ github.event_name == ''pull_request'' && !contains(github.event.pull_request.labels.*.name, ''ci-bench'') && ''ubuntu-22.04'' || github.repository == ''denoland/deno'' && ''ubuntu-22.04-xl'' || ''ubuntu-22.04'' }}'
os_display_name: ubuntu-x86_64
- os: ubuntu-22.04
job: test job: test
profile: debug profile: debug
use_sysroot: true use_sysroot: true
wpt: '${{ github.ref == ''refs/heads/main'' && !startsWith(github.ref, ''refs/tags/'') }}' wpt: '${{ github.ref == ''refs/heads/main'' && !startsWith(github.ref, ''refs/tags/'') }}'
- os: '${{ github.repository == ''denoland/deno'' && ''ubuntu-22.04-xl'' || ''ubuntu-22.04'' }}' os_display_name: ubuntu-x86_64
- os: ubuntu-22.04
job: lint job: lint
profile: debug profile: debug
os_display_name: ubuntu-x86_64
fail-fast: '${{ github.event_name == ''pull_request'' || (github.ref != ''refs/heads/main'' && !startsWith(github.ref, ''refs/tags/'')) }}' fail-fast: '${{ github.event_name == ''pull_request'' || (github.ref != ''refs/heads/main'' && !startsWith(github.ref, ''refs/tags/'')) }}'
env: env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always