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

feat(datasource/github-runners): Add ubuntu-22.04-arm and ubuntu-24.04-arm support #33680

Closed
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
12 changes: 12 additions & 0 deletions lib/modules/datasource/github-runners/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ describe('modules/datasource/github-runners/index', () => {
});
});

it('returns releases for Ubuntu ARM64', async () => {
const res = await getPkgReleases({
datasource: GithubRunnersDatasource.id,
packageName: 'ubuntu_arm64',
});

expect(res).toMatchObject({
releases: [{ version: '22.04' }, { version: '24.04' }],
sourceUrl: 'https://github.com/actions/runner-images',
});
});

it('returns releases for macOS', async () => {
const res = await getPkgReleases({
datasource: GithubRunnersDatasource.id,
Expand Down
14 changes: 13 additions & 1 deletion lib/modules/datasource/github-runners/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class GithubRunnersDatasource extends Datasource {
{ version: '18.04', isDeprecated: true },
{ version: '16.04', isDeprecated: true },
],
ubuntu_arm64: [{ version: '24.04' }, { version: '22.04' }],
macos: [
{ version: '15', isStable: false },
{ version: '15-large', isStable: false },
Expand All @@ -46,6 +47,13 @@ export class GithubRunnersDatasource extends Datasource {
],
};

private static readonly supportsLatest: Record<string, boolean> = {
ubuntu: true,
ubuntu_arm64: false,
Copy link
Author

Choose a reason for hiding this comment

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

macos: true,
windows: true,
};

public static isValidRunner(
runnerName: string,
runnerVersion: string,
Expand All @@ -59,7 +67,11 @@ export class GithubRunnersDatasource extends Datasource {
({ version }) => version === runnerVersion,
);

return runnerVersion === 'latest' || versionExists;
return (
(runnerVersion === 'latest' &&
GithubRunnersDatasource.supportsLatest[runnerName]) ||
versionExists
);
}

override readonly defaultVersioning = dockerVersioningId;
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/datasource/github-runners/readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
This datasource returns a list of all runners that are hosted by GitHub.
The datasource is based on [GitHub's `runner-images` repository](https://github.com/actions/runner-images).

Examples: `windows-2022` / `ubuntu-24.04` / `macos-14`
Examples: `windows-2022` / `ubuntu-24.04` / `macos-14` / `ubuntu-24.04-arm`

## Maintenance

Expand Down
14 changes: 13 additions & 1 deletion lib/modules/manager/github-actions/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ jobs:
labels: ubuntu-20.04-16core
test10:
runs-on: abc-123
test11:
runs-on: ubuntu-22.04-arm
test12:
runs-on: ubuntu-latest-arm
`;

describe('modules/manager/github-actions/extract', () => {
Expand Down Expand Up @@ -569,10 +573,18 @@ describe('modules/manager/github-actions/extract', () => {
datasource: 'github-runners',
autoReplaceStringTemplate: '{{depName}}-{{newValue}}',
},
{
depName: 'ubuntu_arm64',
currentValue: '22.04',
replaceString: 'ubuntu-22.04-arm',
depType: 'github-runner',
datasource: 'github-runners',
autoReplaceStringTemplate: 'ubuntu-{{newValue}}-arm',
},
]);
expect(
res?.deps.filter((d) => d.datasource === 'github-runners'),
).toHaveLength(7);
).toHaveLength(8);
});
});
});
18 changes: 15 additions & 3 deletions lib/modules/manager/github-actions/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,19 @@ function extractRunner(runner: string): PackageDependency | null {
return null;
}

const { depName, currentValue } = runnerVersionGroups;
let { depName, currentValue } = runnerVersionGroups;
let replaceString = `${depName}-${currentValue}`;
let autoReplaceStringTemplate = '{{depName}}-{{newValue}}';

const armVersionMatch = currentValue.match(
/^(?<version>[\\.A-Za-z0-9]+)-arm$/,
);
if (depName === 'ubuntu' && armVersionMatch) {
depName = 'ubuntu_arm64';
currentValue = armVersionMatch.groups?.version ?? currentValue;
replaceString = `ubuntu-${currentValue}-arm`;
autoReplaceStringTemplate = 'ubuntu-{{newValue}}-arm';
}

if (!GithubRunnersDatasource.isValidRunner(depName, currentValue)) {
return null;
Expand All @@ -166,10 +178,10 @@ function extractRunner(runner: string): PackageDependency | null {
const dependency: PackageDependency = {
depName,
currentValue,
replaceString: `${depName}-${currentValue}`,
replaceString,
depType: 'github-runner',
datasource: GithubRunnersDatasource.id,
autoReplaceStringTemplate: '{{depName}}-{{newValue}}',
autoReplaceStringTemplate,
};

if (!dockerVersioning.api.isValid(currentValue)) {
Expand Down