Track installer size across commits

This commit is contained in:
Fedor Indutny 2024-08-27 14:44:36 -04:00 committed by GitHub
parent 5a5b681b51
commit 2835934277
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 120 additions and 0 deletions

View file

@ -109,6 +109,14 @@ jobs:
env: env:
DISABLE_INSPECT_FUSE: on DISABLE_INSPECT_FUSE: on
SIGN_MACOS_SCRIPT: noop.sh SIGN_MACOS_SCRIPT: noop.sh
- name: Upload installer size
if: ${{ github.repository == 'signalapp/Signal-Desktop-Private' && github.ref == 'refs/heads/main' }}
run: |
node ts/scripts/dd-installer-size.js macos-arm64
node ts/scripts/dd-installer-size.js macos-x64
node ts/scripts/dd-installer-size.js macos-universal
env:
DD_API_KEY: ${{ secrets.DATADOG_API_KEY }}
- name: Rebuild native modules for x64 - name: Rebuild native modules for x64
run: npm run electron:install-app-deps run: npm run electron:install-app-deps
- run: npm run test-release - run: npm run test-release
@ -169,6 +177,12 @@ jobs:
env: env:
DISABLE_INSPECT_FUSE: on DISABLE_INSPECT_FUSE: on
- name: Upload installer size
if: ${{ github.repository == 'signalapp/Signal-Desktop-Private' && github.ref == 'refs/heads/main' }}
run: node ts/scripts/dd-installer-size.js linux
env:
DD_API_KEY: ${{ secrets.DATADOG_API_KEY }}
- run: xvfb-run --auto-servernum npm run test-node - run: xvfb-run --auto-servernum npm run test-node
- run: xvfb-run --auto-servernum npm run test-electron - run: xvfb-run --auto-servernum npm run test-electron
timeout-minutes: 5 timeout-minutes: 5
@ -247,6 +261,12 @@ jobs:
env: env:
DISABLE_INSPECT_FUSE: on DISABLE_INSPECT_FUSE: on
- name: Upload installer size
if: ${{ github.repository == 'signalapp/Signal-Desktop-Private' && github.ref == 'refs/heads/main' }}
run: node ts/scripts/dd-installer-size.js windows
env:
DD_API_KEY: ${{ secrets.DATADOG_API_KEY }}
- run: npm run test-electron - run: npm run test-electron
env: env:
ARTIFACTS_DIR: artifacts/windows ARTIFACTS_DIR: artifacts/windows

View file

@ -0,0 +1,100 @@
// Copyright 2024 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { stat } from 'node:fs/promises';
import { join } from 'node:path';
import { name as NAME, version as VERSION } from '../../package.json';
const SUPPORT_CONFIG = new Set([
'linux',
'windows',
'macos-arm64',
'macos-x64',
'macos-universal',
]);
const RELEASE_DIR = join(__dirname, '..', '..', 'release');
async function main(): Promise<void> {
const config = process.argv[2];
if (!SUPPORT_CONFIG.has(config)) {
throw new Error(`Invalid argument: ${config}`);
}
const { DD_API_KEY } = process.env;
if (DD_API_KEY == null) {
throw new Error('Missing DD_API_KEY env variable');
}
let fileName: string;
let platform: string;
let arch: string;
if (config === 'linux') {
fileName = `${NAME}_${VERSION}_amd64.deb`;
platform = 'linux';
arch = 'x64';
} else if (config === 'windows') {
fileName = `${NAME}-win-${VERSION}.exe`;
platform = 'windows';
arch = 'x64';
} else if (config === 'macos-arm64') {
fileName = `${NAME}-mac-arm64-${VERSION}.dmg`;
platform = 'macos';
arch = 'arm64';
} else if (config === 'macos-x64') {
fileName = `${NAME}-mac-x64-${VERSION}.dmg`;
platform = 'macos';
arch = 'x64';
} else if (config === 'macos-universal') {
fileName = `${NAME}-mac-universal-${VERSION}.dmg`;
platform = 'macos';
arch = 'universal';
} else {
throw new Error(`Unsupported config: ${config}`);
}
const filePath = join(RELEASE_DIR, fileName);
const { size } = await stat(filePath);
const res = await fetch('https://api.datadoghq.com/api/v2/series', {
method: 'POST',
headers: {
'content-type': 'application/json',
'DD-API-KEY': DD_API_KEY,
},
body: JSON.stringify({
series: [
{
metric: 'desktop.ci.installerSize',
type: 0,
points: [
{
timestamp: Math.floor(Date.now() / 1000),
value: size,
},
],
tags: [
`hash:${process.env.GITHUB_SHA ?? ''}`,
`platform:${platform}`,
`arch:${arch}`,
],
},
],
}),
});
if (!res.ok) {
throw new Error(
`Failed to submit metrics, status: ${res.status}, ` +
`body: ${await res.text()}`
);
}
console.log(`Submitted: ${size}`);
}
main().catch(err => {
console.error('Failed', err);
process.exit(1);
});