This repository has been archived by the owner on Sep 29, 2022. It is now read-only.
generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
423 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,36 @@ | ||
# How to use | ||
# BlueRacer | ||
|
||
PyTest durations reporter for GitHub. | ||
|
||
## How to use | ||
|
||
```yaml | ||
uses: teamniteo/blueracer-action@main | ||
with: | ||
durations-file: test_durations.csv | ||
... | ||
- uses: teamniteo/blueracer-action@main | ||
id: blueracer | ||
with: | ||
durations-file: test_durations.csv | ||
percentage-warn: 10 # optional | ||
percentage-error: 30 # optional | ||
|
||
- name: Find Comment | ||
uses: peter-evans/find-comment@main | ||
id: fc | ||
if: github.event_name == 'pull_request' | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body-includes: "### BlueRacer unit tests" | ||
|
||
- name: Create or update comment | ||
uses: peter-evans/create-or-update-comment@main | ||
if: github.event_name == 'pull_request' | ||
with: | ||
comment-id: ${{ steps.fc.outputs.comment-id }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: ${{ steps.blueracer.outputs.report }} | ||
edit-mode: replace | ||
``` | ||
## Developing and Releasing | ||
see https://github.com/actions/typescript-action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {expect, test} from '@jest/globals' | ||
import {defualtBranchSHA, defualtBranchSHABefore} from '../src/constants' | ||
import * as github from '@actions/github' | ||
import * as fs from 'fs' | ||
import * as path from 'path' | ||
|
||
const MASTER = JSON.parse( | ||
fs.readFileSync(path.resolve(__dirname, 'default.json')).toString() | ||
) | ||
|
||
github.context.ref = MASTER.ref | ||
github.context.sha = MASTER.sha | ||
github.context.payload = MASTER.payload | ||
|
||
test('get sha for cache restore', async () => { | ||
expect(defualtBranchSHA()).toEqual('b629b84bdcfd917ded87409cd7406712ae7e1dad') | ||
expect(defualtBranchSHABefore()).toEqual( | ||
'5ba7a84840dcc723cca6d0a70cccbde49e6584ef' | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
{ | ||
"payload": { | ||
"after": "b629b84bdcfd917ded87409cd7406712ae7e1dad", | ||
"base_ref": null, | ||
"before": "5ba7a84840dcc723cca6d0a70cccbde49e6584ef", | ||
"commits": [ | ||
{ | ||
"author": { | ||
"email": "[email protected]", | ||
"name": "Janez Troha", | ||
"username": "dz0ny" | ||
}, | ||
"committer": { | ||
"email": "[email protected]", | ||
"name": "GitHub", | ||
"username": "web-flow" | ||
}, | ||
"distinct": true, | ||
"id": "b629b84bdcfd917ded87409cd7406712ae7e1dad", | ||
"message": "Run new report (#1716)", | ||
"timestamp": "2022-08-08T15:47:04+02:00", | ||
"tree_id": "5c82f380b2bcf876dca9caa7fb0addba2800d188", | ||
"url": "https://github.com/teamniteo/minisites/commit/b629b84bdcfd917ded87409cd7406712ae7e1dad" | ||
} | ||
], | ||
"compare": "https://github.com/teamniteo/minisites/compare/5ba7a84840dc...b629b84bdcfd", | ||
"created": false, | ||
"deleted": false, | ||
"forced": false, | ||
"head_commit": { | ||
"author": { | ||
"email": "[email protected]", | ||
"name": "Janez Troha", | ||
"username": "dz0ny" | ||
}, | ||
"committer": { | ||
"email": "[email protected]", | ||
"name": "GitHub", | ||
"username": "web-flow" | ||
}, | ||
"distinct": true, | ||
"id": "b629b84bdcfd917ded87409cd7406712ae7e1dad", | ||
"message": "Run new report (#1716)", | ||
"timestamp": "2022-08-08T15:47:04+02:00", | ||
"tree_id": "5c82f380b2bcf876dca9caa7fb0addba2800d188", | ||
"url": "https://github.com/teamniteo/minisites/commit/b629b84bdcfd917ded87409cd7406712ae7e1dad" | ||
}, | ||
"organization": { | ||
"avatar_url": "https://avatars.githubusercontent.com/u/1309418?v=4", | ||
"description": "Niteo is a decade old SaaS studio full of bright ideas, building smart solutions that empower small businesses online.", | ||
"events_url": "https://api.github.com/orgs/teamniteo/events", | ||
"hooks_url": "https://api.github.com/orgs/teamniteo/hooks", | ||
"id": 1309418, | ||
"issues_url": "https://api.github.com/orgs/teamniteo/issues", | ||
"login": "teamniteo", | ||
"members_url": "https://api.github.com/orgs/teamniteo/members{/member}", | ||
"node_id": "MDEyOk9yZ2FuaXphdGlvbjEzMDk0MTg=", | ||
"public_members_url": "https://api.github.com/orgs/teamniteo/public_members{/member}", | ||
"repos_url": "https://api.github.com/orgs/teamniteo/repos", | ||
"url": "https://api.github.com/orgs/teamniteo" | ||
}, | ||
"pusher": { | ||
"email": "[email protected]", | ||
"name": "dz0ny" | ||
}, | ||
"ref": "refs/heads/master", | ||
"repository": { | ||
"allow_forking": false, | ||
"archive_url": "https://api.github.com/repos/teamniteo/minisites/{archive_format}{/ref}", | ||
"archived": false, | ||
"assignees_url": "https://api.github.com/repos/teamniteo/minisites/assignees{/user}", | ||
"blobs_url": "https://api.github.com/repos/teamniteo/minisites/git/blobs{/sha}", | ||
"branches_url": "https://api.github.com/repos/teamniteo/minisites/branches{/branch}", | ||
"clone_url": "https://github.com/teamniteo/minisites.git", | ||
"collaborators_url": "https://api.github.com/repos/teamniteo/minisites/collaborators{/collaborator}", | ||
"comments_url": "https://api.github.com/repos/teamniteo/minisites/comments{/number}", | ||
"commits_url": "https://api.github.com/repos/teamniteo/minisites/commits{/sha}", | ||
"compare_url": "https://api.github.com/repos/teamniteo/minisites/compare/{base}...{head}", | ||
"contents_url": "https://api.github.com/repos/teamniteo/minisites/contents/{+path}", | ||
"contributors_url": "https://api.github.com/repos/teamniteo/minisites/contributors", | ||
"created_at": 1494328077, | ||
"default_branch": "master", | ||
"deployments_url": "https://api.github.com/repos/teamniteo/minisites/deployments", | ||
"description": "Pyramid based framework for publishing mini websites, such as lead generation sites, landing pages and sales websites. ", | ||
"disabled": false, | ||
"downloads_url": "https://api.github.com/repos/teamniteo/minisites/downloads", | ||
"events_url": "https://api.github.com/repos/teamniteo/minisites/events", | ||
"fork": false, | ||
"forks": 0, | ||
"forks_count": 0, | ||
"forks_url": "https://api.github.com/repos/teamniteo/minisites/forks", | ||
"full_name": "teamniteo/minisites", | ||
"git_commits_url": "https://api.github.com/repos/teamniteo/minisites/git/commits{/sha}", | ||
"git_refs_url": "https://api.github.com/repos/teamniteo/minisites/git/refs{/sha}", | ||
"git_tags_url": "https://api.github.com/repos/teamniteo/minisites/git/tags{/sha}", | ||
"git_url": "git://github.com/teamniteo/minisites.git", | ||
"has_downloads": true, | ||
"has_issues": false, | ||
"has_pages": false, | ||
"has_projects": false, | ||
"has_wiki": false, | ||
"homepage": "", | ||
"hooks_url": "https://api.github.com/repos/teamniteo/minisites/hooks", | ||
"html_url": "https://github.com/teamniteo/minisites", | ||
"id": 90736516, | ||
"is_template": false, | ||
"issue_comment_url": "https://api.github.com/repos/teamniteo/minisites/issues/comments{/number}", | ||
"issue_events_url": "https://api.github.com/repos/teamniteo/minisites/issues/events{/number}", | ||
"issues_url": "https://api.github.com/repos/teamniteo/minisites/issues{/number}", | ||
"keys_url": "https://api.github.com/repos/teamniteo/minisites/keys{/key_id}", | ||
"labels_url": "https://api.github.com/repos/teamniteo/minisites/labels{/name}", | ||
"language": "Python", | ||
"languages_url": "https://api.github.com/repos/teamniteo/minisites/languages", | ||
"license": null, | ||
"master_branch": "master", | ||
"merges_url": "https://api.github.com/repos/teamniteo/minisites/merges", | ||
"milestones_url": "https://api.github.com/repos/teamniteo/minisites/milestones{/number}", | ||
"mirror_url": null, | ||
"name": "minisites", | ||
"node_id": "MDEwOlJlcG9zaXRvcnk5MDczNjUxNg==", | ||
"notifications_url": "https://api.github.com/repos/teamniteo/minisites/notifications{?since,all,participating}", | ||
"open_issues": 3, | ||
"open_issues_count": 3, | ||
"organization": "teamniteo", | ||
"owner": { | ||
"avatar_url": "https://avatars.githubusercontent.com/u/1309418?v=4", | ||
"email": "[email protected]", | ||
"events_url": "https://api.github.com/users/teamniteo/events{/privacy}", | ||
"followers_url": "https://api.github.com/users/teamniteo/followers", | ||
"following_url": "https://api.github.com/users/teamniteo/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/teamniteo/gists{/gist_id}", | ||
"gravatar_id": "", | ||
"html_url": "https://github.com/teamniteo", | ||
"id": 1309418, | ||
"login": "teamniteo", | ||
"name": "teamniteo", | ||
"node_id": "MDEyOk9yZ2FuaXphdGlvbjEzMDk0MTg=", | ||
"organizations_url": "https://api.github.com/users/teamniteo/orgs", | ||
"received_events_url": "https://api.github.com/users/teamniteo/received_events", | ||
"repos_url": "https://api.github.com/users/teamniteo/repos", | ||
"site_admin": false, | ||
"starred_url": "https://api.github.com/users/teamniteo/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/teamniteo/subscriptions", | ||
"type": "Organization", | ||
"url": "https://api.github.com/users/teamniteo" | ||
}, | ||
"private": true, | ||
"pulls_url": "https://api.github.com/repos/teamniteo/minisites/pulls{/number}", | ||
"pushed_at": 1659966424, | ||
"releases_url": "https://api.github.com/repos/teamniteo/minisites/releases{/id}", | ||
"size": 504209, | ||
"ssh_url": "[email protected]:teamniteo/minisites.git", | ||
"stargazers": 0, | ||
"stargazers_count": 0, | ||
"stargazers_url": "https://api.github.com/repos/teamniteo/minisites/stargazers", | ||
"statuses_url": "https://api.github.com/repos/teamniteo/minisites/statuses/{sha}", | ||
"subscribers_url": "https://api.github.com/repos/teamniteo/minisites/subscribers", | ||
"subscription_url": "https://api.github.com/repos/teamniteo/minisites/subscription", | ||
"svn_url": "https://github.com/teamniteo/minisites", | ||
"tags_url": "https://api.github.com/repos/teamniteo/minisites/tags", | ||
"teams_url": "https://api.github.com/repos/teamniteo/minisites/teams", | ||
"topics": [], | ||
"trees_url": "https://api.github.com/repos/teamniteo/minisites/git/trees{/sha}", | ||
"updated_at": "2022-04-18T15:58:59Z", | ||
"url": "https://github.com/teamniteo/minisites", | ||
"visibility": "private", | ||
"watchers": 0, | ||
"watchers_count": 0, | ||
"web_commit_signoff_required": false | ||
}, | ||
"sender": { | ||
"avatar_url": "https://avatars.githubusercontent.com/u/239513?v=4", | ||
"events_url": "https://api.github.com/users/dz0ny/events{/privacy}", | ||
"followers_url": "https://api.github.com/users/dz0ny/followers", | ||
"following_url": "https://api.github.com/users/dz0ny/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/dz0ny/gists{/gist_id}", | ||
"gravatar_id": "", | ||
"html_url": "https://github.com/dz0ny", | ||
"id": 239513, | ||
"login": "dz0ny", | ||
"node_id": "MDQ6VXNlcjIzOTUxMw==", | ||
"organizations_url": "https://api.github.com/users/dz0ny/orgs", | ||
"received_events_url": "https://api.github.com/users/dz0ny/received_events", | ||
"repos_url": "https://api.github.com/users/dz0ny/repos", | ||
"site_admin": false, | ||
"starred_url": "https://api.github.com/users/dz0ny/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/dz0ny/subscriptions", | ||
"type": "User", | ||
"url": "https://api.github.com/users/dz0ny" | ||
} | ||
}, | ||
"eventName": "push", | ||
"sha": "b629b84bdcfd917ded87409cd7406712ae7e1dad", | ||
"ref": "refs/heads/master", | ||
"workflow": "Run tests and BlueRacer report", | ||
"action": "blueracer", | ||
"actor": "dz0ny", | ||
"job": "test", | ||
"runNumber": 92, | ||
"runId": 2818378521, | ||
"apiUrl": "https://api.github.com", | ||
"serverUrl": "https://github.com", | ||
"graphqlUrl": "https://api.github.com/graphql" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import {fromTemplate} from '../src/templates' | ||
import {expect, test} from '@jest/globals' | ||
import dedent from 'dedent' | ||
import * as github from '@actions/github' | ||
import * as fs from 'fs' | ||
import * as path from 'path' | ||
|
||
const PR = JSON.parse( | ||
fs.readFileSync(path.resolve(__dirname, 'pr.json')).toString() | ||
) | ||
|
||
github.context.ref = PR.ref | ||
github.context.sha = PR.sha | ||
github.context.payload = PR.payload | ||
|
||
test('fromTemplate rendering ok', async () => { | ||
const res = fromTemplate(200, 300, 42, 250, 190, 10, 30) | ||
expect(res).toEqual(dedent`### BlueRacer unit tests performance report: ✅ | ||
Everything looks great, carry on! | ||
Here are some details: | ||
| Branch | Number of tests | Total duration | Duration per 100 tests | | ||
|-|-|-|-| | ||
| \`master\`[^1]|200|300.0s | 150s | | ||
| \`test/blueracer-v1\`[^2]|190 (-5%)|250.0s (-18%) | 131.6s (-13%) | | ||
[^1]: The previous 42 runs. | ||
[^2]: More specifically, [commit \`f9a8408029fa50468a4c98fefa42b8acd6eb8220\`](https://github.com/teamniteo/minisites/commit/f9a8408029fa50468a4c98fefa42b8acd6eb8220).`) | ||
}) | ||
|
||
test('fromTemplate rendering meh', async () => { | ||
const res = fromTemplate(200, 300, 42, 350, 215, 10, 30) | ||
expect(res).toEqual(dedent`### BlueRacer unit tests performance report: 👀 | ||
Your tests appear to be *a bit slower* than average in the \`master\` branch. Could be worth a look? | ||
Here are some details: | ||
| Branch | Number of tests | Total duration | Duration per 100 tests | | ||
|-|-|-|-| | ||
| \`master\`[^1]|200|300.0s | 150s | | ||
| \`test/blueracer-v1\`[^2]|215 (7%)|350.0s (15%) | 162.8s (8%) | | ||
[^1]: The previous 42 runs. | ||
[^2]: More specifically, [commit \`f9a8408029fa50468a4c98fefa42b8acd6eb8220\`](https://github.com/teamniteo/minisites/commit/f9a8408029fa50468a4c98fefa42b8acd6eb8220).`) | ||
}) | ||
|
||
test('fromTemplate rendering fail', async () => { | ||
const res = fromTemplate(200, 300, 42, 950, 215, 10, 30) | ||
expect(res).toEqual(dedent`### BlueRacer unit tests performance report: ❌ | ||
Whoa, hold your horses! This pull request is really slowing down your tests! Are you sure you want to merge it? | ||
Here are some details: | ||
| Branch | Number of tests | Total duration | Duration per 100 tests | | ||
|-|-|-|-| | ||
| \`master\`[^1]|200|300.0s | 150s | | ||
| \`test/blueracer-v1\`[^2]|215 (7%)|950.0s (104%) | 441.9s (99%) | | ||
[^1]: The previous 42 runs. | ||
[^2]: More specifically, [commit \`f9a8408029fa50468a4c98fefa42b8acd6eb8220\`](https://github.com/teamniteo/minisites/commit/f9a8408029fa50468a4c98fefa42b8acd6eb8220).`) | ||
}) |
Oops, something went wrong.