Skip to content

Commit

Permalink
Add ubuntu-22.04-arm and ubuntu-24.04-arm support in GitHub Runners
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Jan 17, 2025
1 parent 3e74602 commit f24ac5a
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
15 changes: 15 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,21 @@ 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', isStable: false },
{ version: '24.04', isStable: false },
],
sourceUrl: 'https://github.com/actions/runner-images',
});
});

it('returns releases for macOS', async () => {
const res = await getPkgReleases({
datasource: GithubRunnersDatasource.id,
Expand Down
17 changes: 16 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,10 @@ export class GithubRunnersDatasource extends Datasource {
{ version: '18.04', isDeprecated: true },
{ version: '16.04', isDeprecated: true },
],
ubuntu_arm64: [
{ version: '24.04', isStable: false },
{ version: '22.04', isStable: false },
],
macos: [
{ version: '15', isStable: false },
{ version: '15-large', isStable: false },
Expand All @@ -46,6 +50,13 @@ export class GithubRunnersDatasource extends Datasource {
],
};

private static readonly supportsLatest: Record<string, boolean> = {
ubuntu: true,
ubuntu_arm64: false,
macos: true,
windows: true,
};

public static isValidRunner(
runnerName: string,
runnerVersion: string,
Expand All @@ -59,7 +70,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
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);
});
});
});
16 changes: 13 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,17 @@ 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>\d+\.\d+)-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 +176,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

0 comments on commit f24ac5a

Please sign in to comment.