Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit 7cb73c8

Browse files
authored
fix: Dowload lambda see #1541 for details. (#1542)
* fix: Update filter to match with new GitHub release assets. * fix: Update filter to match with new GitHub release assets. * Alter test data for pre-relases, add test case for empty response
1 parent d32ca1b commit 7cb73c8

File tree

3 files changed

+6793
-140
lines changed

3 files changed

+6793
-140
lines changed

Diff for: modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/src/syncer/syncer.test.ts

+15-7
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('Synchronize action distribution.', () => {
6262
mockS3.getObjectTagging.mockImplementation(() => {
6363
return {
6464
promise() {
65-
return Promise.resolve({ TagSet: [{ Key: 'name', Value: 'actions-runner-linux-x64-2.272.0.tar.gz' }] });
65+
return Promise.resolve({ TagSet: [{ Key: 'name', Value: 'actions-runner-linux-x64-2.285.1.tar.gz' }] });
6666
},
6767
};
6868
});
@@ -86,7 +86,7 @@ describe('Synchronize action distribution.', () => {
8686
mockS3.getObjectTagging.mockImplementation(() => {
8787
return {
8888
promise() {
89-
return Promise.resolve({ TagSet: [{ Key: 'name', Value: 'actions-runner-linux-x64-2.272.0.tar.gz' }] });
89+
return Promise.resolve({ TagSet: [{ Key: 'name', Value: 'actions-runner-linux-x64-2.285.1.tar.gz' }] });
9090
},
9191
};
9292
});
@@ -105,7 +105,7 @@ describe('Synchronize action distribution.', () => {
105105
mockS3.getObjectTagging.mockImplementation(() => {
106106
return {
107107
promise() {
108-
return Promise.resolve({ TagSet: [{ Key: 'name', Value: 'actions-runner-linux-x64-2.273.0.tar.gz' }] });
108+
return Promise.resolve({ TagSet: [{ Key: 'name', Value: 'actions-runner-linux-x64-2.286.0.tar.gz' }] });
109109
},
110110
};
111111
});
@@ -136,7 +136,7 @@ describe('Synchronize action distribution.', () => {
136136
});
137137
expect(mockS3.upload).toBeCalledTimes(1);
138138
const s3JsonBody = mockS3.upload.mock.calls[0][0];
139-
expect(s3JsonBody['Tagging']).toEqual('name=actions-runner-linux-x64-2.272.0.tar.gz');
139+
expect(s3JsonBody['Tagging']).toEqual('name=actions-runner-linux-x64-2.285.1.tar.gz');
140140
});
141141

142142
it('Distribution should update to release if there are no pre-releases.', async () => {
@@ -162,7 +162,7 @@ describe('Synchronize action distribution.', () => {
162162
});
163163
expect(mockS3.upload).toBeCalledTimes(1);
164164
const s3JsonBody = mockS3.upload.mock.calls[0][0];
165-
expect(s3JsonBody['Tagging']).toEqual('name=actions-runner-linux-x64-2.272.0.tar.gz');
165+
expect(s3JsonBody['Tagging']).toEqual('name=actions-runner-linux-x64-2.285.1.tar.gz');
166166
});
167167

168168
it('Distribution should update to prerelease.', async () => {
@@ -183,7 +183,7 @@ describe('Synchronize action distribution.', () => {
183183
});
184184
expect(mockS3.upload).toBeCalledTimes(1);
185185
const s3JsonBody = mockS3.upload.mock.calls[0][0];
186-
expect(s3JsonBody['Tagging']).toEqual('name=actions-runner-linux-x64-2.273.0.tar.gz');
186+
expect(s3JsonBody['Tagging']).toEqual('name=actions-runner-linux-x64-2.286.0.tar.gz');
187187
});
188188

189189
it('Distribution should not update to prerelease if there is a newer release.', async () => {
@@ -211,7 +211,7 @@ describe('Synchronize action distribution.', () => {
211211
});
212212
expect(mockS3.upload).toBeCalledTimes(1);
213213
const s3JsonBody = mockS3.upload.mock.calls[0][0];
214-
expect(s3JsonBody['Tagging']).toEqual('name=actions-runner-linux-x64-2.273.0.tar.gz');
214+
expect(s3JsonBody['Tagging']).toEqual('name=actions-runner-linux-x64-2.286.0.tar.gz');
215215
});
216216

217217
it('No tag in S3, distribution should update.', async () => {
@@ -273,6 +273,14 @@ describe('No release assets found.', () => {
273273

274274
await expect(sync()).rejects.toThrow(errorMessage);
275275
});
276+
277+
it('Empty asset list.', async () => {
278+
mockOctokit.repos.listReleases.mockImplementation(() => ({
279+
data: [],
280+
}));
281+
282+
await expect(sync()).rejects.toThrow(errorMessage);
283+
});
276284
});
277285

278286
describe('Invalid config', () => {

Diff for: modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/src/syncer/syncer.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,13 @@ async function getReleaseAsset(
5757
} else if (latestReleaseIndex != -1) {
5858
asset = assetsList.data[latestReleaseIndex];
5959
} else {
60+
logger.warn('Cannot find either a release or pre release.');
6061
return undefined;
6162
}
63+
64+
const releaseVersion = asset.tag_name.replace('v', '');
6265
const assets = asset.assets?.filter((a: { name?: string }) =>
63-
a.name?.includes(`actions-runner-${runnerOs}-${runnerArch}-`),
66+
a.name?.includes(`actions-runner-${runnerOs}-${runnerArch}-${releaseVersion}.`),
6467
);
6568

6669
return assets?.length === 1 ? { name: assets[0].name, downloadUrl: assets[0].browser_download_url } : undefined;

0 commit comments

Comments
 (0)