Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ jobs:

- name: Typecheck
run: npm run tsc

- name: Check Format
id: npm-format-check
run: npm run format:check
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DS_Store
.licenses/
dist/
node_modules/
coverage/
14 changes: 14 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
printWidth: 80
tabWidth: 2
useTabs: false
semi: false
singleQuote: true
quoteProps: as-needed
jsxSingleQuote: false
trailingComma: none
bracketSpacing: true
bracketSameLine: true
arrowParens: always
proseWrap: always
htmlWhitespaceSensitivity: css
endOfLine: lf
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# workflow-timer

Workflow-timer is a GitHub action that measures the duration of the workflow and compares it to the duration of historical runs.
Workflow-timer is a GitHub action that measures the duration of the workflow and
compares it to the duration of historical runs.

The action should be triggered on `pull_requests` hence it will create a comment on the PR with information like:
The action should be triggered on `pull_requests` hence it will create a comment
on the PR with information like:

`🕒 Workflow "Unit tests" took 22.056s which is a decrease with 6.944s (23.94%) compared to latest run on master/main.`

The purpose of this action is to make the developer aware of when feedbacks loops get longer. Let's say that you are running unit tests as part of your current workflow. If merging your changes (your PR) would increase the time it takes to run the unit tests by 50%, your changes probably have unwanted side effects. It's about creating awareness for the developer.
The purpose of this action is to make the developer aware of when feedbacks
loops get longer. Let's say that you are running unit tests as part of your
current workflow. If merging your changes (your PR) would increase the time it
takes to run the unit tests by 50%, your changes probably have unwanted side
effects. It's about creating awareness for the developer.

## How to use it

Expand All @@ -17,7 +23,10 @@ As the **very last job** in your workflow, add
uses: DeviesDevelopment/workflow-timer@v0.0.2
```

Workflow-timer compares the current workflow run with the latest run on the master/main branch. Therefore, the same workflow needs to run when merging with the master as well, otherwise, there will be no data to compare. We suggest having the following definition in the workflow:
Workflow-timer compares the current workflow run with the latest run on the
master/main branch. Therefore, the same workflow needs to run when merging with
the master as well, otherwise, there will be no data to compare. We suggest
having the following definition in the workflow:

```yaml
on:
Expand All @@ -29,4 +38,5 @@ on:

## How to contribute

Feel free to open a pull request! All contributions, no matter how small, are more than welcome. Happy hacking!
Feel free to open a pull request! All contributions, no matter how small, are
more than welcome. Happy hacking!
16 changes: 9 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: "Workflow Timer"
description: "Measures the duration of the workflow and compares it to the duration of historical runs."
name: 'Workflow Timer'
description:
'Measures the duration of the workflow and compares it to the duration of
historical runs.'
branding:
icon: "clock"
color: "green"
icon: 'clock'
color: 'green'
inputs:
token:
description: "GITHUB_TOKEN or a repo scoped PAT."
description: 'GITHUB_TOKEN or a repo scoped PAT.'
default: ${{ github.token }}
runs:
using: "node20"
main: "dist/index.js"
using: 'node20'
main: 'dist/index.js'
47 changes: 23 additions & 24 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
"node": ">=20"
},
"scripts": {
"format:write": "npx prettier --write .",
"format:check": "npx prettier --check .",
"package": "npx rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",
"package:watch": "npm run package -- --watch",
"tsc": "tsc --noEmit",
"all": "npm run tsc && npm run package"
"all": "npm run format:write && npm run tsc && npm run package"
},
"dependencies": {
"@actions/core": "^1.11.1",
Expand All @@ -26,6 +28,7 @@
"@rollup/plugin-node-resolve": "^16.0.1",
"@rollup/plugin-typescript": "^12.1.2",
"@types/node": "^22.15.2",
"prettier": "^3.5.3",
"rollup": "^4.40.0",
"tslib": "^2.8.1",
"typescript": "^5.8.3"
Expand Down
20 changes: 10 additions & 10 deletions rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// See: https://rollupjs.org/introduction/

import commonjs from "@rollup/plugin-commonjs";
import nodeResolve from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import commonjs from '@rollup/plugin-commonjs'
import nodeResolve from '@rollup/plugin-node-resolve'
import typescript from '@rollup/plugin-typescript'

const config = {
input: "src/index.ts",
input: 'src/index.ts',
output: {
esModule: true,
file: "dist/index.js",
format: "es",
sourcemap: true,
file: 'dist/index.js',
format: 'es',
sourcemap: true
},
plugins: [typescript(), nodeResolve({ preferBuiltins: true }), commonjs()],
};
plugins: [typescript(), nodeResolve({ preferBuiltins: true }), commonjs()]
}

export default config;
export default config
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { run } from "./main.js";
import { run } from './main.js'

run();
run()
Loading