Skip to content

Commit

Permalink
fix: change skia-canvas to github release
Browse files Browse the repository at this point in the history
closes #710

pick from #712
  • Loading branch information
ltxhhz authored and fengmk2 committed Oct 13, 2024
1 parent b0cd0ba commit ab3e9d9
Show file tree
Hide file tree
Showing 4 changed files with 3,540 additions and 62 deletions.
7 changes: 2 additions & 5 deletions config/binaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,9 @@ const binaries = {
'skia-canvas': {
category: 'skia-canvas',
description: 'A canvas environment for Node',
type: BinaryType.NodePreGyp,
type: BinaryType.GitHub,
repo: 'samizdatco/skia-canvas',
distUrl: 'https://skia-canvas.s3.us-east-1.amazonaws.com',
options: {
requiredNapiVersions: true,
},
distUrl: 'https://github.com/samizdatco/skia-canvas/releases',
},
wrtc: {
category: 'wrtc',
Expand Down
56 changes: 56 additions & 0 deletions test/common/adapter/binary/GithubBinary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe('test/common/adapter/binary/GithubBinary.test.ts', () => {
beforeEach(async () => {
binary = await app.getEggObject(GithubBinary);
});

describe('fetch()', () => {
it('should fetch root and subdir work', async () => {
const response = await TestUtil.readJSONFile(TestUtil.getFixtures('electron-releases.json'));
Expand All @@ -34,5 +35,60 @@ describe('test/common/adapter/binary/GithubBinary.test.ts', () => {
}
// console.log(result.items);
});

it('should fetch skia-canvas', async () => {
const response = await TestUtil.readJSONFile(TestUtil.getFixtures('skia-canvas-releases.json'));
app.mockHttpclient(/https:\/\/api\.github\.com\/repos\/samizdatco\/skia-canvas\/releases/, 'GET', {
data: response,
status: 200,
});
let result = await binary.fetch('/', 'skia-canvas');
assert(result);
assert(result.items.length > 0);
// console.log(JSON.stringify(result.items, null, 2));
let matchDir = false;
for (const item of result.items) {
assert(item.isDir === true);
if (item.name === 'v0.9.30/') {
matchDir = true;
}
}
assert(matchDir);

result = await binary.fetch('/v0.9.24/', 'skia-canvas');
assert(result?.items.every(item => !/{.*}/.test(item.url)));

result = await binary.fetch('/v0.9.30/', 'skia-canvas');
assert(result);
assert(result.items.length > 0);
console.log(JSON.stringify(result.items, null, 2));
let matchFile1 = false;
let matchFile2 = false;
let matchFile3 = false;
for (const item of result.items) {
assert(item.isDir === false);
if (item.name === 'skia-canvas-v0.9.30-darwin-arm64.tar.gz') {
assert(item.date === '2024-08-26T18:04:13Z');
assert(item.size === 7547563);
assert.equal(item.url, 'https://github.com/samizdatco/skia-canvas/releases/download/v0.9.30/skia-canvas-v0.9.30-darwin-arm64.tar.gz');
matchFile1 = true;
}
if (item.name === 'skia-canvas-v0.9.30-linux-arm-glibc.tar.gz') {
assert(item.date === '2024-08-26T18:04:17Z');
assert(item.size === 8836353);
assert.equal(item.url, 'https://github.com/samizdatco/skia-canvas/releases/download/v0.9.30/skia-canvas-v0.9.30-linux-arm-glibc.tar.gz');
matchFile2 = true;
}
if (item.name === 'skia-canvas-v0.9.30-win32-x64.tar.gz') {
assert(item.date === '2024-08-26T18:04:29Z');
assert(item.size === 7497076);
assert.equal(item.url, 'https://github.com/samizdatco/skia-canvas/releases/download/v0.9.30/skia-canvas-v0.9.30-win32-x64.tar.gz');
matchFile3 = true;
}
}
assert(matchFile1);
assert(matchFile2);
assert(matchFile3);
});
});
});
57 changes: 0 additions & 57 deletions test/common/adapter/binary/NodePreGypBinary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,63 +137,6 @@ describe('test/common/adapter/binary/NodePreGypBinary.test.ts', () => {
assert(matchFile3);
});

it('should fetch skia-canvas', async () => {
app.mockHttpclient('https://registry.npmjs.com/skia-canvas', 'GET', {
data: await TestUtil.readFixturesFile('registry.npmjs.com/skia-canvas.json'),
});
app.mockHttpclient('https://nodejs.org/dist/index.json', 'GET', {
data: await TestUtil.readFixturesFile('nodejs.org/site/index.json'),
});
let result = await binary.fetch('/', 'skia-canvas');
assert(result);
assert(result.items.length > 0);
// console.log(JSON.stringify(result.items, null, 2));
let matchDir = false;
for (const item of result.items) {
assert(item.isDir === true);
if (item.name === 'v0.9.30/') {
matchDir = true;
}
}
assert(matchDir);

result = await binary.fetch('/v0.9.24/', 'skia-canvas');
assert(result?.items.every(item => !/{.*}/.test(item.url)));

result = await binary.fetch('/v0.9.30/', 'skia-canvas');
assert(result);
assert(result.items.length > 0);
// console.log(JSON.stringify(result.items, null, 2));
let matchFile1 = false;
let matchFile2 = false;
let matchFile3 = false;
for (const item of result.items) {
assert(item.isDir === false);
assert.deepEqual(item.ignoreDownloadStatuses, [ 404, 403 ]);
if (item.name === 'darwin-arm64-napi-v6-unknown.tar.gz') {
assert(item.date === '2022-06-08T01:53:43.908Z');
assert(item.size === '-');
assert(item.url === 'https://skia-canvas.s3.us-east-1.amazonaws.com/v0.9.30/darwin-arm64-napi-v6-unknown.tar.gz');
matchFile1 = true;
}
if (item.name === 'linux-arm-napi-v6-glibc.tar.gz') {
assert(item.date === '2022-06-08T01:53:43.908Z');
assert(item.size === '-');
assert(item.url === 'https://skia-canvas.s3.us-east-1.amazonaws.com/v0.9.30/linux-arm-napi-v6-glibc.tar.gz');
matchFile2 = true;
}
if (item.name === 'win32-x64-napi-v6-unknown.tar.gz') {
assert(item.date === '2022-06-08T01:53:43.908Z');
assert(item.size === '-');
assert(item.url === 'https://skia-canvas.s3.us-east-1.amazonaws.com/v0.9.30/win32-x64-napi-v6-unknown.tar.gz');
matchFile3 = true;
}
}
assert(matchFile1);
assert(matchFile2);
assert(matchFile3);
});

it('should fetch wrtc', async () => {
app.mockHttpclient('https://registry.npmjs.com/wrtc', 'GET', {
data: await TestUtil.readFixturesFile('registry.npmjs.com/wrtc.json'),
Expand Down
Loading

0 comments on commit ab3e9d9

Please sign in to comment.