Skip to content

Commit 7b2fb95

Browse files
committed
Tidy UI configuration
1 parent f974e0c commit 7b2fb95

File tree

14 files changed

+853
-772
lines changed

14 files changed

+853
-772
lines changed

.eslintrc.json

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
{
2-
"plugins": [
3-
"@typescript-eslint"
4-
],
5-
"extends": [
6-
"plugin:github/recommended"
7-
],
2+
"plugins": ["@typescript-eslint"],
3+
"extends": ["plugin:github/recommended"],
84
"parser": "@typescript-eslint/parser",
95
"parserOptions": {
106
"ecmaVersion": 9,
@@ -36,10 +32,7 @@
3632
"allowExpressions": true
3733
}
3834
],
39-
"@typescript-eslint/func-call-spacing": [
40-
"error",
41-
"never"
42-
],
35+
"@typescript-eslint/func-call-spacing": ["error", "never"],
4336
"@typescript-eslint/no-array-constructor": "error",
4437
"@typescript-eslint/no-explicit-any": "error",
4538
"@typescript-eslint/no-extraneous-class": "error",
@@ -59,11 +52,7 @@
5952
"@typescript-eslint/promise-function-async": "error",
6053
"@typescript-eslint/require-array-sort-compare": "error",
6154
"@typescript-eslint/restrict-plus-operands": "error",
62-
"semi": "off",
63-
"@typescript-eslint/semi": [
64-
"error",
65-
"never"
66-
],
55+
"@typescript-eslint/semi": ["error", "never"],
6756
"@typescript-eslint/type-annotation-spacing": "error",
6857
"@typescript-eslint/unbound-method": "error"
6958
},

.github/workflows/self-test.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: self-test
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'src/**'
7+
- 'action.yml'
8+
- '.github/workflows/self-test.yml'
9+
workflow_dispatch:
10+
11+
permissions:
12+
pull-requests: write
13+
contents: read
14+
15+
jobs:
16+
self-test:
17+
name: Test the action against itself
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: 20
27+
28+
- name: Build & package
29+
run: |
30+
npm ci
31+
npm run build
32+
npm run package
33+
34+
# Test the action itself (using the local changes)
35+
- name: Run workflow telemetry
36+
uses: ./
37+
with:
38+
proc_trace_sys_enable: true
39+
40+
# This is a simple test that gives the action something to measure
41+
- name: Run some commands to generate metrics
42+
run: |
43+
echo "Creating some disk activity..."
44+
dd if=/dev/zero of=testfile bs=1M count=100
45+
rm testfile
46+
47+
echo "Creating some CPU activity..."
48+
for i in {1..10000000}; do :; done

.prettierrc.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
"printWidth": 80,
33
"tabWidth": 2,
44
"useTabs": false,
5-
"semi": false,
6-
"singleQuote": true,
7-
"trailingComma": "none",
5+
"semi": true,
6+
"trailingComma": "es5",
87
"bracketSpacing": true,
98
"arrowParens": "avoid"
109
}

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ inputs:
2828
required: false
2929
proc_trace_table_show:
3030
description: "Enables showing traced processes in trace table. Defaults to 'false'."
31-
default: "false"
31+
default: "true"
3232
required: false
3333
comment_on_pr:
3434
description: "Set to `true` to publish the results as comment to the PR (applicable if workflow run is triggered from PR). Defaults to 'true'."

src/config.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Configuration constants
2+
export const UI_CONFIG = {
3+
FONT_FAMILY: "Arial, Helvetica, sans-serif",
4+
};
5+
6+
// Chart configuration defaults
7+
export const CHART_DEFAULTS = {
8+
options: {
9+
width: 1000,
10+
height: 500,
11+
xAxis: {
12+
label: "Time",
13+
fontFamily: UI_CONFIG.FONT_FAMILY,
14+
},
15+
yAxis: {
16+
fontFamily: UI_CONFIG.FONT_FAMILY,
17+
},
18+
timeTicks: {
19+
unit: "auto",
20+
},
21+
fontFamily: UI_CONFIG.FONT_FAMILY,
22+
},
23+
};
24+
25+
// Mermaid chart defaults
26+
export const MERMAID_DEFAULTS = {
27+
gantt: {
28+
dateFormat: "YYYY-MM-DD",
29+
axisFormat: "%H:%M:%S",
30+
fontFamily: UI_CONFIG.FONT_FAMILY,
31+
},
32+
};

src/interfaces/index.ts

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,113 @@
11
// eslint-disable-next-line import/no-unresolved
2-
import { components } from '@octokit/openapi-types'
2+
import { components } from "@octokit/openapi-types";
33

4-
export type WorkflowJobType = components['schemas']['job']
4+
export type WorkflowJobType = components["schemas"]["job"];
55

66
export interface CPUStats {
7-
readonly time: number
8-
readonly totalLoad: number
9-
readonly userLoad: number
10-
readonly systemLoad: number
7+
readonly time: number;
8+
readonly totalLoad: number;
9+
readonly userLoad: number;
10+
readonly systemLoad: number;
1111
}
1212

1313
export interface MemoryStats {
14-
readonly time: number
15-
readonly totalMemoryMb: number
16-
readonly activeMemoryMb: number
17-
readonly availableMemoryMb: number
14+
readonly time: number;
15+
readonly totalMemoryMb: number;
16+
readonly activeMemoryMb: number;
17+
readonly availableMemoryMb: number;
1818
}
1919

2020
export interface NetworkStats {
21-
readonly time: number
22-
readonly rxMb: number
23-
readonly txMb: number
21+
readonly time: number;
22+
readonly rxMb: number;
23+
readonly txMb: number;
2424
}
2525

2626
export interface DiskStats {
27-
readonly time: number
28-
readonly rxMb: number
29-
readonly wxMb: number
27+
readonly time: number;
28+
readonly rxMb: number;
29+
readonly wxMb: number;
3030
}
3131

3232
export interface DiskSizeStats {
33-
readonly time: number
34-
readonly availableSizeMb: number
35-
readonly usedSizeMb: number
33+
readonly time: number;
34+
readonly availableSizeMb: number;
35+
readonly usedSizeMb: number;
3636
}
3737

3838
export interface ProcessedStats {
39-
readonly x: number
40-
readonly y: number
39+
readonly x: number;
40+
readonly y: number;
4141
}
4242

4343
export interface ProcessedCPUStats {
44-
readonly userLoadX: ProcessedStats[]
45-
readonly systemLoadX: ProcessedStats[]
44+
readonly userLoadX: ProcessedStats[];
45+
readonly systemLoadX: ProcessedStats[];
4646
}
4747

4848
export interface ProcessedMemoryStats {
49-
readonly activeMemoryX: ProcessedStats[]
50-
readonly availableMemoryX: ProcessedStats[]
49+
readonly activeMemoryX: ProcessedStats[];
50+
readonly availableMemoryX: ProcessedStats[];
5151
}
5252

5353
export interface ProcessedNetworkStats {
54-
readonly networkReadX: ProcessedStats[]
55-
readonly networkWriteX: ProcessedStats[]
54+
readonly networkReadX: ProcessedStats[];
55+
readonly networkWriteX: ProcessedStats[];
5656
}
5757

5858
export interface ProcessedDiskStats {
59-
readonly diskReadX: ProcessedStats[]
60-
readonly diskWriteX: ProcessedStats[]
59+
readonly diskReadX: ProcessedStats[];
60+
readonly diskWriteX: ProcessedStats[];
6161
}
6262

6363
export interface ProcessedDiskSizeStats {
64-
readonly diskAvailableX: ProcessedStats[]
65-
readonly diskUsedX: ProcessedStats[]
64+
readonly diskAvailableX: ProcessedStats[];
65+
readonly diskUsedX: ProcessedStats[];
6666
}
6767

6868
export interface LineGraphOptions {
69-
readonly label: string
70-
readonly axisColor: string
69+
readonly label: string;
70+
readonly axisColor: string;
7171
readonly line: {
72-
readonly label: string
73-
readonly color: string
74-
readonly points: ProcessedStats[]
75-
}
72+
readonly label: string;
73+
readonly color: string;
74+
readonly points: ProcessedStats[];
75+
};
7676
}
7777

7878
export interface StackedArea {
79-
readonly label: string
80-
readonly color: string
81-
readonly points: ProcessedStats[]
79+
readonly label: string;
80+
readonly color: string;
81+
readonly points: ProcessedStats[];
8282
}
8383

8484
export interface StackedAreaGraphOptions {
85-
readonly label: string
86-
readonly axisColor: string
87-
readonly areas: StackedArea[]
85+
readonly label: string;
86+
readonly axisColor: string;
87+
readonly areas: StackedArea[];
8888
}
8989

9090
export interface GraphResponse {
91-
readonly id: string
92-
readonly url: string
91+
readonly id: string;
92+
readonly url: string;
9393
}
9494

9595
export interface CompletedCommand {
96-
readonly ts: string
97-
readonly event: string
98-
readonly name: string
99-
readonly uid: number
100-
readonly pid: number
101-
readonly ppid: string
102-
readonly startTime: number
103-
readonly fileName: string
104-
readonly args: string[]
105-
readonly duration: number
106-
readonly exitCode: number
107-
readonly order: number
96+
readonly ts: string;
97+
readonly event: string;
98+
readonly name: string;
99+
readonly uid: number;
100+
readonly pid: number;
101+
readonly ppid: string;
102+
readonly startTime: number;
103+
readonly fileName: string;
104+
readonly args: string[];
105+
readonly duration: number;
106+
readonly exitCode: number;
107+
readonly order: number;
108108
}
109109

110110
export interface ProcEventParseOptions {
111-
readonly minDuration: number
112-
readonly traceSystemProcesses: boolean
111+
readonly minDuration: number;
112+
readonly traceSystemProcesses: boolean;
113113
}

src/logger.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import * as core from '@actions/core'
1+
import * as core from "@actions/core";
22

3-
const LOG_HEADER: string = '[Workflow Telemetry]'
3+
const LOG_HEADER: string = "[Workflow Telemetry]";
44

55
export function isDebugEnabled(): boolean {
6-
return core.isDebug()
6+
return core.isDebug();
77
}
88

99
export function debug(msg: string) {
10-
core.debug(LOG_HEADER + ' ' + msg)
10+
core.debug(LOG_HEADER + " " + msg);
1111
}
1212

1313
export function info(msg: string) {
14-
core.info(LOG_HEADER + ' ' + msg)
14+
core.info(LOG_HEADER + " " + msg);
1515
}
1616

1717
export function error(msg: string | Error) {
18-
if (msg instanceof String || typeof msg === 'string') {
19-
core.error(LOG_HEADER + ' ' + msg)
18+
if (msg instanceof String || typeof msg === "string") {
19+
core.error(LOG_HEADER + " " + msg);
2020
} else {
21-
core.error(LOG_HEADER + ' ' + (msg as Error).name)
22-
core.error(msg as Error)
21+
core.error(LOG_HEADER + " " + (msg as Error).name);
22+
core.error(msg as Error);
2323
}
2424
}

src/main.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import * as core from '@actions/core'
2-
import * as stepTracer from './stepTracer'
3-
import * as statCollector from './statCollector'
4-
import * as processTracer from './processTracer'
5-
import * as logger from './logger'
1+
import * as core from "@actions/core";
2+
import * as stepTracer from "./stepTracer";
3+
import * as statCollector from "./statCollector";
4+
import * as processTracer from "./processTracer";
5+
import * as logger from "./logger";
66

77
async function run(): Promise<void> {
88
try {
9-
logger.info(`Initializing ...`)
9+
logger.info(`Initializing ...`);
1010

1111
// Start step tracer
12-
await stepTracer.start()
12+
await stepTracer.start();
1313
// Start stat collector
14-
await statCollector.start()
14+
await statCollector.start();
1515
// Start process tracer
16-
await processTracer.start()
16+
await processTracer.start();
1717

18-
logger.info(`Initialization completed`)
19-
} catch (error: any) {
20-
logger.error(error.message)
18+
logger.info(`Initialization completed`);
19+
} catch (error) {
20+
logger.error(error.message);
2121
}
2222
}
2323

24-
run()
24+
run();

0 commit comments

Comments
 (0)