Skip to content

Commit be7603a

Browse files
committed
chore: add resource collection test script
1 parent 5d47827 commit be7603a

File tree

4 files changed

+117
-2
lines changed

4 files changed

+117
-2
lines changed

.devcontainer/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ apt-get update
7171
apt-get install -y --no-install-recommends \
7272
gh \
7373
git \
74-
sudo
74+
sudo-rs \
75+
ssh
7576

7677
# Setup sudo access
7778
echo "ubuntu ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/ubuntu
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Resource Collection
2+
3+
on:
4+
workflow_dispatch:
5+
push: # Temp while testing the script heavily.
6+
7+
concurrency:
8+
group: resource-collection
9+
cancel-in-progress: true
10+
11+
permissions:
12+
contents: read # Required to clone the repository
13+
14+
jobs:
15+
collect-resources:
16+
strategy:
17+
matrix:
18+
os:
19+
- runner: ubuntu-24.04
20+
name: Linux
21+
- runner: ubuntu-24.04-arm
22+
name: Linux ARM
23+
- runner: windows-2025
24+
name: Windows
25+
- runner: windows-11-arm
26+
name: Windows ARM
27+
- runner: macos-26
28+
name: macOS
29+
- runner: macos-26-intel
30+
name: macOS Intel
31+
runs-on: ${{ matrix.os.runner }}
32+
name: Collect resources on ${{ matrix.os.name }}
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
36+
with:
37+
persist-credentials: false
38+
- name: Setup Node
39+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
40+
with:
41+
node-version-file: .node-version
42+
package-manager-cache: false
43+
- name: Collect resources
44+
run: node ./scripts/resource-collection.ts

scripts/build.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { promises as fs } from "node:fs";
21
import { join } from "node:path";
32
import * as esbuild from "esbuild";
43

scripts/resource-collection.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* This script is intended to be independnet of the rest of
5+
* the codebase. It is used to determine if the native logic
6+
* works before making wider modifications throughout the codebase.
7+
*/
8+
9+
import { statfs } from 'node:fs/promises';
10+
import os from 'node:os';
11+
12+
const convertBytesToGB = (bytes: number) => (bytes / Math.pow(1024, 3)).toFixed(2);
13+
14+
console.group('CI Information');
15+
console.log('CI:', process.env.CI);
16+
console.log('GITHUB_ACTION:', process.env.GITHUB_ACTION);
17+
console.log('GITHUB_WORKSPACE:', process.env.GITHUB_WORKSPACE);
18+
console.groupEnd();
19+
20+
console.group('Memory')
21+
console.log('Free memory:', convertBytesToGB(os.freemem()), 'GB');
22+
console.log('Total memory:', convertBytesToGB(os.totalmem()), 'GB');
23+
console.groupEnd();
24+
25+
console.group('Processor')
26+
console.log('CPU architecture:', os.machine());
27+
console.log('Number of CPU cores:', os.cpus().length);
28+
console.log('Parallelism Cores:', os.availableParallelism());
29+
console.groupEnd();
30+
31+
console.group('Operating System')
32+
console.log('Type:', os.type());
33+
console.log('Release:', os.release());
34+
console.log('Version:', os.version());
35+
console.groupEnd();
36+
37+
console.group('User');
38+
const userInfo = os.userInfo();
39+
console.log('Username:', userInfo.username);
40+
console.log('Home directory:', userInfo.homedir);
41+
console.log('Shell:', userInfo.shell);
42+
console.log('UID:', userInfo.uid);
43+
console.log('GID:', userInfo.gid);
44+
console.groupEnd();
45+
46+
console.group('Disk');
47+
let storagePath = process.env.RESOURCE_COLLECTION_STORAGE_PATH;
48+
switch (os.platform()) {
49+
case 'win32':
50+
storagePath ??= 'C:\\';
51+
break;
52+
case 'darwin':
53+
storagePath ??= '/System/Volumes/Data';
54+
break;
55+
case 'linux':
56+
storagePath ??= '/';
57+
break;
58+
default:
59+
break;
60+
}
61+
62+
if (!storagePath) {
63+
console.warn('No storage path specified or discovered for disk information. Skipping disk information.');
64+
console.groupEnd();
65+
process.exit(0);
66+
}
67+
68+
console.log(await statfs(storagePath, {
69+
bigint: true,
70+
}));
71+
console.groupEnd();

0 commit comments

Comments
 (0)