Skip to content

Commit

Permalink
feat: mirror protobuf binary (#717)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added support for Protocol Buffers with a new binary entry in the
configuration.

- **Tests**
- Introduced a new test case to verify the fetching of release data for
the Protocol Buffers repository from GitHub.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: shixia.ly <shixia.ly@antgroup.com>
  • Loading branch information
akitaSummer and shixia.ly authored Oct 18, 2024
1 parent efac8a9 commit d6f0e1d
Show file tree
Hide file tree
Showing 3 changed files with 14,237 additions and 0 deletions.
7 changes: 7 additions & 0 deletions config/binaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ const binaries = {
repo: 'samizdatco/skia-canvas',
distUrl: 'https://github.com/samizdatco/skia-canvas/releases',
},
protobuf: {
category: 'protobuf',
description: 'Protocol Buffers - Google\'s data interchange format',
type: BinaryType.GitHub,
repo: 'protocolbuffers/protobuf',
distUrl: 'https://github.com/protocolbuffers/protobuf/releases',
},
wrtc: {
category: 'wrtc',
description: 'node-webrtc is a Node.js Native Addon that provides bindings to WebRTC M87.',
Expand Down
38 changes: 38 additions & 0 deletions test/common/adapter/binary/GithubBinary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,43 @@ describe('test/common/adapter/binary/GithubBinary.test.ts', () => {
assert(matchFile2);
assert(matchFile3);
});

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

result = await binary.fetch('/v28.2/', 'protobuf');
assert(result?.items.every(item => !/{.*}/.test(item.url)));

result = await binary.fetch('/v28.2/', 'protobuf');
assert(result);
assert(result.items.length > 0);
console.log(JSON.stringify(result.items, null, 2));
let matchFile1 = false;
for (const item of result.items) {
assert(item.isDir === false);
if (item.name === 'protoc-28.2-linux-aarch_64.zip') {
assert(item.date === '2024-09-18T21:02:40Z');
assert(item.size === 3218760);
assert.equal(item.url, 'https://github.com/protocolbuffers/protobuf/releases/download/v28.2/protoc-28.2-linux-aarch_64.zip');
matchFile1 = true;
}
}
assert(matchFile1);
});
});
});
Loading

0 comments on commit d6f0e1d

Please sign in to comment.