From a461390d929e0c1a1f2d16c740b9d7bffdca4da0 Mon Sep 17 00:00:00 2001 From: madhan Date: Thu, 23 Mar 2023 00:59:36 +0100 Subject: [PATCH] code review comments fixed --- src/interfaces.ts | 1 - .../__tests__/fixtures/mocked-package.json | 56 --- .../mocked-workflow-job-test-coverage.json | 349 ++++++++++-------- .../test_coverage/metricsConditions.ts | 2 +- 4 files changed, 205 insertions(+), 203 deletions(-) delete mode 100644 src/metrics/test_coverage/__tests__/fixtures/mocked-package.json diff --git a/src/interfaces.ts b/src/interfaces.ts index dd40613..256476e 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -19,7 +19,6 @@ import { export enum DataEventSignature { WorkflowJob = "workflow-job", - TestCoverage = "workflow-job", ToolingUsage = "deven-tooling-usage", PullRequest = "pull-request", CheckSuite = "check-suite", diff --git a/src/metrics/test_coverage/__tests__/fixtures/mocked-package.json b/src/metrics/test_coverage/__tests__/fixtures/mocked-package.json deleted file mode 100644 index 358c485..0000000 --- a/src/metrics/test_coverage/__tests__/fixtures/mocked-package.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "@deven-org/telemetry-functions", - "version": "1.5.0", - "description": "@deven-org/telemetry-functions", - "repository": { - "type": "git", - "url": "https://github.com/deven-org/telemetry-functions.git" - }, - "publishConfig": { - "@deven-org:registry": "https://npm.pkg.github.com" - }, - "keywords": [ - "deven", - "telemetry", - "functions", - "serverless" - ], - "homepage": "https://github.com/deven-org/telemetry-functions", - "engines": { - "node": ">= 16" - }, - "author": "Deven Team", - "license": "MIT", - "bugs": { - "url": "https://github.com/deven-org/telemetry-functions/issues" - }, - "scripts": { - "build": "rm -fr dist && microbundle --target node -f umd", - "prettier": "prettier --config .prettierrc.js 'src/**/*.ts' --write", - "lint": "eslint --fix --max-warnings 0 **/*.ts", - "test": "jest", - "test:coverage": "jest --coverage", - "test:dev": "jest --watch", - "doc:install": "deven-documentation-skeleton install", - "doc:check": "deven-documentation-skeleton check", - "doc:update": "deven-documentation-skeleton update" - }, - "dependencies": { - "@netlify/functions": "^1.4.0", - "@octokit/rest": "^19.0.7", - "dotenv": "^16.0.3", - "js-base64": "^3.7.5" - }, - "devDependencies": { - "@types/jest": "^29.4.1", - "@types/node": "^18.13.0", - "deven-documentation-skeleton": "^2.0.0", - "moment": "^2.29.4", - "netlify": "^13.1.2", - "netlify-cli": "^13.0.1", - "ramda": "^0.28.0", - "semver": "^7.3.8", - "signale": "^1.4.0", - "ts-jest": "^29.0.5" - } -} diff --git a/src/metrics/test_coverage/__tests__/fixtures/mocked-workflow-job-test-coverage.json b/src/metrics/test_coverage/__tests__/fixtures/mocked-workflow-job-test-coverage.json index cb2d7cd..fc9ae51 100644 --- a/src/metrics/test_coverage/__tests__/fixtures/mocked-workflow-job-test-coverage.json +++ b/src/metrics/test_coverage/__tests__/fixtures/mocked-workflow-job-test-coverage.json @@ -1,154 +1,214 @@ { - "action": "completed", - "workflow_job": { - "id": 12126810024, - "run_id": 4467668082, - "workflow_name": "Parse Data", + "action": "completed", + "workflow_job": { + "id": 12134495892, + "run_id": 4470121878, + "workflow_name": "Unit Test", "head_branch": "main", - "run_url": "https://api.github.com/repos/deven-org/telemetry-data/actions/runs/4467668082", - "run_attempt": 1, - "node_id": "CR_kwDOI9y5wM8AAAAC0tBvqA", - "head_sha": "46e80a657c72cc311954c8e810c9f1516b74954a", - "url": "https://api.github.com/repos/deven-org/telemetry-data/actions/jobs/12126810024", - "html_url": "https://github.com/deven-org/telemetry-data/actions/runs/4467668082/jobs/7847418049", + "run_url": "https://api.github.com/repos/deven-org/telemetry-functions/actions/runs/4470121878", + "run_attempt": 2, + "node_id": "CR_kwDOI7W9J88AAAAC00W2lA", + "head_sha": "40ca7f59356451c3e0b1875a654027ed9bbf00fd", + "url": "https://api.github.com/repos/deven-org/telemetry-functions/actions/jobs/12134495892", + "html_url": "https://github.com/deven-org/telemetry-functions/actions/runs/4470121878/jobs/7853296527", "status": "completed", - "conclusion": "failure", - "created_at": "2023-03-20T11:26:58Z", - "started_at": "2023-03-20T11:27:04Z", - "completed_at": "2023-03-20T11:27:14Z", - "name": "Parse-Data", + "conclusion": "success", + "created_at": "2023-03-20T15:49:36Z", + "started_at": "2023-03-20T15:49:44Z", + "completed_at": "2023-03-20T15:50:14Z", + "name": "Unit-Test", "steps": [ - { - "name": "Set up job", - "status": "completed", - "conclusion": "success", - "number": 1, - "started_at": "2023-03-20T11:27:03.000Z", - "completed_at": "2023-03-20T11:27:05.000Z" - }, - { - "name": "Check out repository code", - "status": "completed", - "conclusion": "success", - "number": 2, - "started_at": "2023-03-20T11:27:05.000Z", - "completed_at": "2023-03-20T11:27:06.000Z" - } + { + "name": "Set up job", + "status": "completed", + "conclusion": "success", + "number": 1, + "started_at": "2023-03-20T15:49:43.000Z", + "completed_at": "2023-03-20T15:49:46.000Z" + }, + { + "name": "Check out repository code", + "status": "completed", + "conclusion": "success", + "number": 2, + "started_at": "2023-03-20T15:49:46.000Z", + "completed_at": "2023-03-20T15:49:47.000Z" + }, + { + "name": "Setup node environment", + "status": "completed", + "conclusion": "success", + "number": 3, + "started_at": "2023-03-20T15:49:48.000Z", + "completed_at": "2023-03-20T15:49:53.000Z" + }, + { + "name": "Cache dependencies", + "status": "completed", + "conclusion": "success", + "number": 4, + "started_at": "2023-03-20T15:49:53.000Z", + "completed_at": "2023-03-20T15:49:59.000Z" + }, + { + "name": "Install Dependencies", + "status": "completed", + "conclusion": "skipped", + "number": 5, + "started_at": "2023-03-20T15:50:00.000Z", + "completed_at": "2023-03-20T15:50:00.000Z" + }, + { + "name": "Run test", + "status": "completed", + "conclusion": "success", + "number": 6, + "started_at": "2023-03-20T15:50:00.000Z", + "completed_at": "2023-03-20T15:50:11.000Z" + }, + { + "name": "Post Cache dependencies", + "status": "completed", + "conclusion": "success", + "number": 10, + "started_at": "2023-03-20T15:50:11.000Z", + "completed_at": "2023-03-20T15:50:11.000Z" + }, + { + "name": "Post Setup node environment", + "status": "completed", + "conclusion": "success", + "number": 11, + "started_at": "2023-03-20T15:50:12.000Z", + "completed_at": "2023-03-20T15:50:12.000Z" + }, + { + "name": "Post Check out repository code", + "status": "completed", + "conclusion": "success", + "number": 12, + "started_at": "2023-03-20T15:50:12.000Z", + "completed_at": "2023-03-20T15:50:12.000Z" + }, + { + "name": "Complete job", + "status": "completed", + "conclusion": "success", + "number": 13, + "started_at": "2023-03-20T15:50:12.000Z", + "completed_at": "2023-03-20T15:50:12.000Z" + } ], - "check_run_url": "https://api.github.com/repos/deven-org/telemetry-data/check-runs/12126810024", - "labels": ["ubuntu-latest"], - "runner_id": 3, - "runner_name": "GitHub Actions 3", + "check_run_url": "https://api.github.com/repos/deven-org/telemetry-functions/check-runs/12134495892", + "labels": [ + "ubuntu-latest" + ], + "runner_id": 2, + "runner_name": "GitHub Actions 2", "runner_group_id": 2, "runner_group_name": "GitHub Actions" - }, - "repository": { - "id": 601668032, - "node_id": "R_kgDOI9y5wA", - "name": "telemetry-data", - "full_name": "deven-org/telemetry-data", - "private": true, + }, + "repository": { + "id": 599112999, + "node_id": "R_kgDOI7W9Jw", + "name": "telemetry-functions", + "full_name": "deven-org/telemetry-functions", + "private": false, "owner": { - "login": "deven-org", - "id": 118735834, - "node_id": "O_kgDOBxPD2g", - "avatar_url": "https://avatars.githubusercontent.com/u/118735834?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/deven-org", - "html_url": "https://github.com/deven-org", - "followers_url": "https://api.github.com/users/deven-org/followers", - "following_url": "https://api.github.com/users/deven-org/following{/other_user}", - "gists_url": "https://api.github.com/users/deven-org/gists{/gist_id}", - "starred_url": "https://api.github.com/users/deven-org/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/deven-org/subscriptions", - "organizations_url": "https://api.github.com/users/deven-org/orgs", - "repos_url": "https://api.github.com/users/deven-org/repos", - "events_url": "https://api.github.com/users/deven-org/events{/privacy}", - "received_events_url": "https://api.github.com/users/deven-org/received_events", - "type": "Organization", - "site_admin": false + "login": "deven-org", + "id": 118735834, + "node_id": "O_kgDOBxPD2g", + "avatar_url": "https://avatars.githubusercontent.com/u/118735834?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/deven-org", + "html_url": "https://github.com/deven-org", + "followers_url": "https://api.github.com/users/deven-org/followers", + "following_url": "https://api.github.com/users/deven-org/following{/other_user}", + "gists_url": "https://api.github.com/users/deven-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/deven-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/deven-org/subscriptions", + "organizations_url": "https://api.github.com/users/deven-org/orgs", + "repos_url": "https://api.github.com/users/deven-org/repos", + "events_url": "https://api.github.com/users/deven-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/deven-org/received_events", + "type": "Organization", + "site_admin": false }, - "html_url": "https://github.com/deven-org/telemetry-data", - "description": "Repository to store collected metrics as JSON files ", + "html_url": "https://github.com/deven-org/telemetry-functions", + "description": null, "fork": false, - "url": "https://api.github.com/repos/deven-org/telemetry-data", - "forks_url": "https://api.github.com/repos/deven-org/telemetry-data/forks", - "keys_url": "https://api.github.com/repos/deven-org/telemetry-data/keys{/key_id}", - "collaborators_url": "https://api.github.com/repos/deven-org/telemetry-data/collaborators{/collaborator}", - "teams_url": "https://api.github.com/repos/deven-org/telemetry-data/teams", - "hooks_url": "https://api.github.com/repos/deven-org/telemetry-data/hooks", - "issue_events_url": "https://api.github.com/repos/deven-org/telemetry-data/issues/events{/number}", - "events_url": "https://api.github.com/repos/deven-org/telemetry-data/events", - "assignees_url": "https://api.github.com/repos/deven-org/telemetry-data/assignees{/user}", - "branches_url": "https://api.github.com/repos/deven-org/telemetry-data/branches{/branch}", - "tags_url": "https://api.github.com/repos/deven-org/telemetry-data/tags", - "blobs_url": "https://api.github.com/repos/deven-org/telemetry-data/git/blobs{/sha}", - "git_tags_url": "https://api.github.com/repos/deven-org/telemetry-data/git/tags{/sha}", - "git_refs_url": "https://api.github.com/repos/deven-org/telemetry-data/git/refs{/sha}", - "trees_url": "https://api.github.com/repos/deven-org/telemetry-data/git/trees{/sha}", - "statuses_url": "https://api.github.com/repos/deven-org/telemetry-data/statuses/{sha}", - "languages_url": "https://api.github.com/repos/deven-org/telemetry-data/languages", - "stargazers_url": "https://api.github.com/repos/deven-org/telemetry-data/stargazers", - "contributors_url": "https://api.github.com/repos/deven-org/telemetry-data/contributors", - "subscribers_url": "https://api.github.com/repos/deven-org/telemetry-data/subscribers", - "subscription_url": "https://api.github.com/repos/deven-org/telemetry-data/subscription", - "commits_url": "https://api.github.com/repos/deven-org/telemetry-data/commits{/sha}", - "git_commits_url": "https://api.github.com/repos/deven-org/telemetry-data/git/commits{/sha}", - "comments_url": "https://api.github.com/repos/deven-org/telemetry-data/comments{/number}", - "issue_comment_url": "https://api.github.com/repos/deven-org/telemetry-data/issues/comments{/number}", - "contents_url": "https://api.github.com/repos/deven-org/telemetry-data/contents/{+path}", - "compare_url": "https://api.github.com/repos/deven-org/telemetry-data/compare/{base}...{head}", - "merges_url": "https://api.github.com/repos/deven-org/telemetry-data/merges", - "archive_url": "https://api.github.com/repos/deven-org/telemetry-data/{archive_format}{/ref}", - "downloads_url": "https://api.github.com/repos/deven-org/telemetry-data/downloads", - "issues_url": "https://api.github.com/repos/deven-org/telemetry-data/issues{/number}", - "pulls_url": "https://api.github.com/repos/deven-org/telemetry-data/pulls{/number}", - "milestones_url": "https://api.github.com/repos/deven-org/telemetry-data/milestones{/number}", - "notifications_url": "https://api.github.com/repos/deven-org/telemetry-data/notifications{?since,all,participating}", - "labels_url": "https://api.github.com/repos/deven-org/telemetry-data/labels{/name}", - "releases_url": "https://api.github.com/repos/deven-org/telemetry-data/releases{/id}", - "deployments_url": "https://api.github.com/repos/deven-org/telemetry-data/deployments", - "created_at": "2023-02-14T15:05:07Z", - "updated_at": "2023-02-28T14:58:09Z", - "pushed_at": "2023-03-20T11:26:54Z", - "git_url": "git://github.com/deven-org/telemetry-data.git", - "ssh_url": "git@github.com:deven-org/telemetry-data.git", - "clone_url": "https://github.com/deven-org/telemetry-data.git", - "svn_url": "https://github.com/deven-org/telemetry-data", + "url": "https://api.github.com/repos/deven-org/telemetry-functions", + "forks_url": "https://api.github.com/repos/deven-org/telemetry-functions/forks", + "keys_url": "https://api.github.com/repos/deven-org/telemetry-functions/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/deven-org/telemetry-functions/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/deven-org/telemetry-functions/teams", + "hooks_url": "https://api.github.com/repos/deven-org/telemetry-functions/hooks", + "issue_events_url": "https://api.github.com/repos/deven-org/telemetry-functions/issues/events{/number}", + "events_url": "https://api.github.com/repos/deven-org/telemetry-functions/events", + "assignees_url": "https://api.github.com/repos/deven-org/telemetry-functions/assignees{/user}", + "branches_url": "https://api.github.com/repos/deven-org/telemetry-functions/branches{/branch}", + "tags_url": "https://api.github.com/repos/deven-org/telemetry-functions/tags", + "blobs_url": "https://api.github.com/repos/deven-org/telemetry-functions/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/deven-org/telemetry-functions/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/deven-org/telemetry-functions/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/deven-org/telemetry-functions/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/deven-org/telemetry-functions/statuses/{sha}", + "languages_url": "https://api.github.com/repos/deven-org/telemetry-functions/languages", + "stargazers_url": "https://api.github.com/repos/deven-org/telemetry-functions/stargazers", + "contributors_url": "https://api.github.com/repos/deven-org/telemetry-functions/contributors", + "subscribers_url": "https://api.github.com/repos/deven-org/telemetry-functions/subscribers", + "subscription_url": "https://api.github.com/repos/deven-org/telemetry-functions/subscription", + "commits_url": "https://api.github.com/repos/deven-org/telemetry-functions/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/deven-org/telemetry-functions/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/deven-org/telemetry-functions/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/deven-org/telemetry-functions/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/deven-org/telemetry-functions/contents/{+path}", + "compare_url": "https://api.github.com/repos/deven-org/telemetry-functions/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/deven-org/telemetry-functions/merges", + "archive_url": "https://api.github.com/repos/deven-org/telemetry-functions/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/deven-org/telemetry-functions/downloads", + "issues_url": "https://api.github.com/repos/deven-org/telemetry-functions/issues{/number}", + "pulls_url": "https://api.github.com/repos/deven-org/telemetry-functions/pulls{/number}", + "milestones_url": "https://api.github.com/repos/deven-org/telemetry-functions/milestones{/number}", + "notifications_url": "https://api.github.com/repos/deven-org/telemetry-functions/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/deven-org/telemetry-functions/labels{/name}", + "releases_url": "https://api.github.com/repos/deven-org/telemetry-functions/releases{/id}", + "deployments_url": "https://api.github.com/repos/deven-org/telemetry-functions/deployments", + "created_at": "2023-02-08T13:35:04Z", + "updated_at": "2023-03-17T12:40:26Z", + "pushed_at": "2023-03-20T15:43:15Z", + "git_url": "git://github.com/deven-org/telemetry-functions.git", + "ssh_url": "git@github.com:deven-org/telemetry-functions.git", + "clone_url": "https://github.com/deven-org/telemetry-functions.git", + "svn_url": "https://github.com/deven-org/telemetry-functions", "homepage": null, - "size": 1371, - "stargazers_count": 0, - "watchers_count": 0, - "language": "JavaScript", + "size": 1215, + "stargazers_count": 1, + "watchers_count": 1, + "language": "TypeScript", "has_issues": true, "has_projects": true, "has_downloads": true, - "has_wiki": false, + "has_wiki": true, "has_pages": false, "has_discussions": false, "forks_count": 0, "mirror_url": null, "archived": false, "disabled": false, - "open_issues_count": 2, - "license": { - "key": "mit", - "name": "MIT License", - "spdx_id": "MIT", - "url": "https://api.github.com/licenses/mit", - "node_id": "MDc6TGljZW5zZTEz" - }, - "allow_forking": false, + "open_issues_count": 13, + "license": null, + "allow_forking": true, "is_template": false, "web_commit_signoff_required": false, "topics": [], - "visibility": "private", + "visibility": "public", "forks": 0, - "open_issues": 2, - "watchers": 0, + "open_issues": 13, + "watchers": 1, "default_branch": "main" - }, - "organization": { + }, + "organization": { "login": "deven-org", "id": 118735834, "node_id": "O_kgDOBxPD2g", @@ -161,26 +221,25 @@ "public_members_url": "https://api.github.com/orgs/deven-org/public_members{/member}", "avatar_url": "https://avatars.githubusercontent.com/u/118735834?v=4", "description": "Developer Enviroment / Enablement / Enhancement" - }, - "sender": { - "login": "r-l-d", - "id": 54277333, - "node_id": "MDQ6VXNlcjU0Mjc3MzMz", - "avatar_url": "https://avatars.githubusercontent.com/u/54277333?v=4", + }, + "sender": { + "login": "pixari", + "id": 7393475, + "node_id": "MDQ6VXNlcjczOTM0NzU=", + "avatar_url": "https://avatars.githubusercontent.com/u/7393475?v=4", "gravatar_id": "", - "url": "https://api.github.com/users/r-l-d", - "html_url": "https://github.com/r-l-d", - "followers_url": "https://api.github.com/users/r-l-d/followers", - "following_url": "https://api.github.com/users/r-l-d/following{/other_user}", - "gists_url": "https://api.github.com/users/r-l-d/gists{/gist_id}", - "starred_url": "https://api.github.com/users/r-l-d/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/r-l-d/subscriptions", - "organizations_url": "https://api.github.com/users/r-l-d/orgs", - "repos_url": "https://api.github.com/users/r-l-d/repos", - "events_url": "https://api.github.com/users/r-l-d/events{/privacy}", - "received_events_url": "https://api.github.com/users/r-l-d/received_events", + "url": "https://api.github.com/users/pixari", + "html_url": "https://github.com/pixari", + "followers_url": "https://api.github.com/users/pixari/followers", + "following_url": "https://api.github.com/users/pixari/following{/other_user}", + "gists_url": "https://api.github.com/users/pixari/gists{/gist_id}", + "starred_url": "https://api.github.com/users/pixari/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/pixari/subscriptions", + "organizations_url": "https://api.github.com/users/pixari/orgs", + "repos_url": "https://api.github.com/users/pixari/repos", + "events_url": "https://api.github.com/users/pixari/events{/privacy}", + "received_events_url": "https://api.github.com/users/pixari/received_events", "type": "User", "site_admin": false - } } - \ No newline at end of file +} \ No newline at end of file diff --git a/src/metrics/test_coverage/metricsConditions.ts b/src/metrics/test_coverage/metricsConditions.ts index fdf0270..cfde362 100644 --- a/src/metrics/test_coverage/metricsConditions.ts +++ b/src/metrics/test_coverage/metricsConditions.ts @@ -3,7 +3,7 @@ import { Conditions, DataEvent, DataEventSignature } from "../../interfaces"; import { WorkflowJobCompletedPayload } from "../workflows/interfaces"; const isSignedAsWorkflowJobTestCoverage = (dataEvent: DataEvent) => { - if (dataEvent.dataEventSignature !== DataEventSignature.TestCoverage) { + if (dataEvent.dataEventSignature !== DataEventSignature.WorkflowJob) { return false; } else { }