testbeats 2.1.6 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/helpers/ci.js DELETED
@@ -1,140 +0,0 @@
1
- const os = require('os');
2
- const pkg = require('../../package.json');
3
-
4
- const ENV = process.env;
5
-
6
- /**
7
- * @returns {import('../extensions/extensions').ICIInfo}
8
- */
9
- function getCIInformation() {
10
- const ci_info = getBaseCIInfo();
11
- const system_info = getSystemInfo();
12
- return {
13
- ...ci_info,
14
- ...system_info
15
- }
16
- }
17
-
18
- function getBaseCIInfo() {
19
- if (ENV.GITHUB_ACTIONS) {
20
- return getGitHubActionsInformation();
21
- }
22
- if (ENV.GITLAB_CI) {
23
- return getGitLabInformation();
24
- }
25
- if (ENV.JENKINS_URL) {
26
- return getJenkinsInformation();
27
- }
28
- if (ENV.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI) {
29
- return getAzureDevOpsInformation();
30
- }
31
- return getDefaultInformation();
32
- }
33
-
34
- function getGitHubActionsInformation() {
35
- return {
36
- ci: 'GITHUB_ACTIONS',
37
- git: 'GITHUB',
38
- repository_url: ENV.GITHUB_SERVER_URL + '/' + ENV.GITHUB_REPOSITORY,
39
- repository_name: ENV.GITHUB_REPOSITORY,
40
- repository_ref: ENV.GITHUB_REF,
41
- repository_commit_sha: ENV.GITHUB_SHA,
42
- build_url: ENV.GITHUB_SERVER_URL + '/' + ENV.GITHUB_REPOSITORY + '/actions/runs/' + ENV.GITHUB_RUN_ID,
43
- build_number: ENV.GITHUB_RUN_NUMBER,
44
- build_name: ENV.GITHUB_WORKFLOW,
45
- build_reason: ENV.GITHUB_EVENT_NAME,
46
- user: ENV.GITHUB_ACTOR,
47
- }
48
- }
49
-
50
- function getAzureDevOpsInformation() {
51
- return {
52
- ci: 'AZURE_DEVOPS_PIPELINES',
53
- git: 'AZURE_DEVOPS_REPOS',
54
- repository_url: ENV.BUILD_REPOSITORY_URI,
55
- repository_name: ENV.BUILD_REPOSITORY_NAME,
56
- repository_ref: ENV.BUILD_SOURCEBRANCH,
57
- repository_commit_sha: ENV.BUILD_SOURCEVERSION,
58
- build_url: ENV.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI + ENV.SYSTEM_TEAMPROJECT + '/_build/results?buildId=' + ENV.BUILD_BUILDID,
59
- build_number: ENV.BUILD_BUILDNUMBER,
60
- build_name: ENV.BUILD_DEFINITIONNAME,
61
- build_reason: ENV.BUILD_REASON,
62
- user: ENV.BUILD_REQUESTEDFOR
63
- }
64
- }
65
-
66
- function getJenkinsInformation() {
67
- return {
68
- ci: 'JENKINS',
69
- git: '',
70
- repository_url: ENV.GIT_URL || ENV.GITHUB_URL || ENV.BITBUCKET_URL,
71
- repository_name: ENV.JOB_NAME,
72
- repository_ref: ENV.BRANCH || ENV.BRANCH_NAME,
73
- repository_commit_sha: ENV.GIT_COMMIT || ENV.GIT_COMMIT_SHA || ENV.GITHUB_SHA || ENV.BITBUCKET_COMMIT,
74
- build_url: ENV.BUILD_URL,
75
- build_number: ENV.BUILD_NUMBER,
76
- build_name: ENV.JOB_NAME,
77
- build_reason: ENV.BUILD_CAUSE,
78
- user: ENV.USER || ENV.USERNAME
79
- }
80
- }
81
-
82
- function getGitLabInformation() {
83
- return {
84
- ci: 'GITLAB',
85
- git: 'GITLAB',
86
- repository_url: ENV.CI_PROJECT_URL,
87
- repository_name: ENV.CI_PROJECT_NAME,
88
- repository_ref: ENV.CI_MERGE_REQUEST_SOURCE_BRANCH_NAME || ENV.CI_COMMIT_REF_NAME,
89
- repository_commit_sha:ENV.CI_MERGE_REQUEST_SOURCE_BRANCH_SHA || ENV.CI_COMMIT_SHA,
90
- build_url: ENV.CI_JOB_URL,
91
- build_number: ENV.CI_JOB_ID,
92
- build_name: ENV.CI_JOB_NAME,
93
- build_reason: ENV.CI_PIPELINE_SOURCE,
94
- user: ENV.GITLAB_USER_LOGIN || ENV.CI_COMMIT_AUTHOR
95
- }
96
- }
97
-
98
- function getDefaultInformation() {
99
- return {
100
- ci: ENV.TEST_BEATS_CI_NAME,
101
- git: ENV.TEST_BEATS_CI_GIT,
102
- repository_url: ENV.TEST_BEATS_CI_REPOSITORY_URL,
103
- repository_name: ENV.TEST_BEATS_CI_REPOSITORY_NAME,
104
- repository_ref: ENV.TEST_BEATS_CI_REPOSITORY_REF,
105
- repository_commit_sha: ENV.TEST_BEATS_CI_REPOSITORY_COMMIT_SHA,
106
- build_url: ENV.TEST_BEATS_CI_BUILD_URL,
107
- build_number: ENV.TEST_BEATS_CI_BUILD_NUMBER,
108
- build_name: ENV.TEST_BEATS_CI_BUILD_NAME,
109
- build_reason: ENV.TEST_BEATS_CI_BUILD_REASON,
110
- user: ENV.TEST_BEATS_CI_USER || os.userInfo().username
111
- }
112
- }
113
-
114
- function getSystemInfo() {
115
- function getRuntimeInfo() {
116
- if (typeof process !== 'undefined' && process.versions && process.versions.node) {
117
- return { name: 'node', version: process.versions.node };
118
- } else if (typeof Deno !== 'undefined') {
119
- return { name: 'deno', version: Deno.version.deno };
120
- } else if (typeof Bun !== 'undefined') {
121
- return { name: 'bun', version: Bun.version };
122
- } else {
123
- return { name: 'unknown', version: 'unknown' };
124
- }
125
- }
126
-
127
- const runtime = getRuntimeInfo();
128
-
129
- return {
130
- runtime: runtime.name,
131
- runtime_version: runtime.version,
132
- os: os.platform(),
133
- os_version: os.release(),
134
- testbeats_version: pkg.version
135
- }
136
- }
137
-
138
- module.exports = {
139
- getCIInformation
140
- }