Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"plugins": [
"@typescript-eslint"
],
"extends": [
"plugin:github/recommended"
],
"plugins": ["@typescript-eslint"],
"extends": ["plugin:github/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
Expand Down Expand Up @@ -36,10 +32,7 @@
"allowExpressions": true
}
],
"@typescript-eslint/func-call-spacing": [
"error",
"never"
],
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-extraneous-class": "error",
Expand All @@ -59,11 +52,7 @@
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"semi": "off",
"@typescript-eslint/semi": [
"error",
"never"
],
"@typescript-eslint/semi": ["error", "never"],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error"
},
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/self-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: self-test

on:
pull_request:
paths:
- 'src/**'
- 'action.yml'
- '.github/workflows/self-test.yml'
workflow_dispatch:

permissions:
pull-requests: write
contents: read

jobs:
self-test:
name: Test the action against itself
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Build & package
run: |
npm ci
npm run build
npm run package

# Test the action itself (using the local changes)
- name: Run workflow telemetry
uses: ./
with:
proc_trace_sys_enable: true

# This is a simple test that gives the action something to measure
- name: Run some commands to generate metrics
run: |
echo "Creating some disk activity..."
dd if=/dev/zero of=testfile bs=1M count=100
rm testfile

echo "Creating some CPU activity..."
for i in {1..10000000}; do :; done
5 changes: 2 additions & 3 deletions .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"semi": true,
"trailingComma": "es5",
"bracketSpacing": true,
"arrowParens": "avoid"
}
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ inputs:
required: false
proc_trace_table_show:
description: "Enables showing traced processes in trace table. Defaults to 'false'."
default: "false"
default: "true"
required: false
comment_on_pr:
description: "Set to `true` to publish the results as comment to the PR (applicable if workflow run is triggered from PR). Defaults to 'true'."
Expand Down
32 changes: 32 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Configuration constants
export const UI_CONFIG = {
FONT_FAMILY: "Arial, Helvetica, sans-serif",
};

// Chart configuration defaults
export const CHART_DEFAULTS = {
options: {
width: 1000,
height: 500,
xAxis: {
label: "Time",
fontFamily: UI_CONFIG.FONT_FAMILY,
},
yAxis: {
fontFamily: UI_CONFIG.FONT_FAMILY,
},
timeTicks: {
unit: "auto",
},
fontFamily: UI_CONFIG.FONT_FAMILY,
},
};

// Mermaid chart defaults
export const MERMAID_DEFAULTS = {
gantt: {
dateFormat: "x",
axisFormat: "%H:%M:%S",
fontFamily: UI_CONFIG.FONT_FAMILY,
},
};
118 changes: 59 additions & 59 deletions src/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,113 +1,113 @@
// eslint-disable-next-line import/no-unresolved
import { components } from '@octokit/openapi-types'
import { components } from "@octokit/openapi-types";

export type WorkflowJobType = components['schemas']['job']
export type WorkflowJobType = components["schemas"]["job"];

export interface CPUStats {
readonly time: number
readonly totalLoad: number
readonly userLoad: number
readonly systemLoad: number
readonly time: number;
readonly totalLoad: number;
readonly userLoad: number;
readonly systemLoad: number;
}

export interface MemoryStats {
readonly time: number
readonly totalMemoryMb: number
readonly activeMemoryMb: number
readonly availableMemoryMb: number
readonly time: number;
readonly totalMemoryMb: number;
readonly activeMemoryMb: number;
readonly availableMemoryMb: number;
}

export interface NetworkStats {
readonly time: number
readonly rxMb: number
readonly txMb: number
readonly time: number;
readonly rxMb: number;
readonly txMb: number;
}

export interface DiskStats {
readonly time: number
readonly rxMb: number
readonly wxMb: number
readonly time: number;
readonly rxMb: number;
readonly wxMb: number;
}

export interface DiskSizeStats {
readonly time: number
readonly availableSizeMb: number
readonly usedSizeMb: number
readonly time: number;
readonly availableSizeMb: number;
readonly usedSizeMb: number;
}

export interface ProcessedStats {
readonly x: number
readonly y: number
readonly x: number;
readonly y: number;
}

export interface ProcessedCPUStats {
readonly userLoadX: ProcessedStats[]
readonly systemLoadX: ProcessedStats[]
readonly userLoadX: ProcessedStats[];
readonly systemLoadX: ProcessedStats[];
}

export interface ProcessedMemoryStats {
readonly activeMemoryX: ProcessedStats[]
readonly availableMemoryX: ProcessedStats[]
readonly activeMemoryX: ProcessedStats[];
readonly availableMemoryX: ProcessedStats[];
}

export interface ProcessedNetworkStats {
readonly networkReadX: ProcessedStats[]
readonly networkWriteX: ProcessedStats[]
readonly networkReadX: ProcessedStats[];
readonly networkWriteX: ProcessedStats[];
}

export interface ProcessedDiskStats {
readonly diskReadX: ProcessedStats[]
readonly diskWriteX: ProcessedStats[]
readonly diskReadX: ProcessedStats[];
readonly diskWriteX: ProcessedStats[];
}

export interface ProcessedDiskSizeStats {
readonly diskAvailableX: ProcessedStats[]
readonly diskUsedX: ProcessedStats[]
readonly diskAvailableX: ProcessedStats[];
readonly diskUsedX: ProcessedStats[];
}

export interface LineGraphOptions {
readonly label: string
readonly axisColor: string
readonly label: string;
readonly axisColor: string;
readonly line: {
readonly label: string
readonly color: string
readonly points: ProcessedStats[]
}
readonly label: string;
readonly color: string;
readonly points: ProcessedStats[];
};
}

export interface StackedArea {
readonly label: string
readonly color: string
readonly points: ProcessedStats[]
readonly label: string;
readonly color: string;
readonly points: ProcessedStats[];
}

export interface StackedAreaGraphOptions {
readonly label: string
readonly axisColor: string
readonly areas: StackedArea[]
readonly label: string;
readonly axisColor: string;
readonly areas: StackedArea[];
}

export interface GraphResponse {
readonly id: string
readonly url: string
readonly id: string;
readonly url: string;
}

export interface CompletedCommand {
readonly ts: string
readonly event: string
readonly name: string
readonly uid: number
readonly pid: number
readonly ppid: string
readonly startTime: number
readonly fileName: string
readonly args: string[]
readonly duration: number
readonly exitCode: number
readonly order: number
readonly ts: string;
readonly event: string;
readonly name: string;
readonly uid: number;
readonly pid: number;
readonly ppid: string;
readonly startTime: number;
readonly fileName: string;
readonly args: string[];
readonly duration: number;
readonly exitCode: number;
readonly order: number;
}

export interface ProcEventParseOptions {
readonly minDuration: number
readonly traceSystemProcesses: boolean
readonly minDuration: number;
readonly traceSystemProcesses: boolean;
}
18 changes: 9 additions & 9 deletions src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import * as core from '@actions/core'
import * as core from "@actions/core";

const LOG_HEADER: string = '[Workflow Telemetry]'
const LOG_HEADER: string = "[Workflow Telemetry]";

export function isDebugEnabled(): boolean {
return core.isDebug()
return core.isDebug();
}

export function debug(msg: string) {
core.debug(LOG_HEADER + ' ' + msg)
core.debug(LOG_HEADER + " " + msg);
}

export function info(msg: string) {
core.info(LOG_HEADER + ' ' + msg)
core.info(LOG_HEADER + " " + msg);
}

export function error(msg: string | Error) {
if (msg instanceof String || typeof msg === 'string') {
core.error(LOG_HEADER + ' ' + msg)
if (msg instanceof String || typeof msg === "string") {
core.error(LOG_HEADER + " " + msg);
} else {
core.error(LOG_HEADER + ' ' + (msg as Error).name)
core.error(msg as Error)
core.error(LOG_HEADER + " " + (msg as Error).name);
core.error(msg as Error);
}
}
24 changes: 12 additions & 12 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import * as core from '@actions/core'
import * as stepTracer from './stepTracer'
import * as statCollector from './statCollector'
import * as processTracer from './processTracer'
import * as logger from './logger'
import * as core from "@actions/core";
import * as stepTracer from "./stepTracer";
import * as statCollector from "./statCollector";
import * as processTracer from "./processTracer";
import * as logger from "./logger";

async function run(): Promise<void> {
try {
logger.info(`Initializing ...`)
logger.info(`Initializing ...`);

// Start step tracer
await stepTracer.start()
await stepTracer.start();
// Start stat collector
await statCollector.start()
await statCollector.start();
// Start process tracer
await processTracer.start()
await processTracer.start();

logger.info(`Initialization completed`)
logger.info(`Initialization completed`);
} catch (error: any) {
logger.error(error.message)
logger.error(error.message);
}
}

run()
run();
Loading
Loading