@allurereport/ci 3.0.0-beta.22 → 3.0.0-beta.24

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/dist/detect.js CHANGED
@@ -6,6 +6,8 @@ import { drone } from "./detectors/drone.js";
6
6
  import { github } from "./detectors/github.js";
7
7
  import { gitlab } from "./detectors/gitlab.js";
8
8
  import { jenkins } from "./detectors/jenkins.js";
9
+ import { local } from "./detectors/local.js";
9
10
  export const detect = () => {
10
- return [amazon, azure, bitbucket, circle, drone, github, gitlab, jenkins].find((descriptor) => descriptor.detected);
11
+ return ([amazon, azure, bitbucket, circle, drone, github, gitlab, jenkins].find((descriptor) => descriptor.detected) ??
12
+ local);
11
13
  };
@@ -1,5 +1,5 @@
1
1
  import { CiType } from "@allurereport/core-api";
2
- import { getEnv } from "../utils.js";
2
+ import { getEnv, getReponameFromRepoUrl } from "../utils.js";
3
3
  const AMAZON_REGEXP = /^arn:aws:codebuild:([^:]+):([\d]+):(?:build|build-batch)\/([^:]+):([\da-f-]+)$/;
4
4
  const PIPELINE_REGEXP = /^(?:codepipeline\/)(.+)$/;
5
5
  export const parseArnValues = (source) => {
@@ -27,6 +27,13 @@ export const amazon = {
27
27
  const buildArn = getEnv("CODEBUILD_BUILD_ARN");
28
28
  return buildArn !== "" && parseArnValues(buildArn).length > 0;
29
29
  },
30
+ get repoName() {
31
+ const repoUrl = getEnv("CODEBUILD_SOURCE_REPO_URL");
32
+ if (!repoUrl) {
33
+ return "";
34
+ }
35
+ return getReponameFromRepoUrl(repoUrl);
36
+ },
30
37
  get jobUid() {
31
38
  const buildArn = getEnv("CODEBUILD_BUILD_ARN");
32
39
  const pipelineName = getPipelineName();
@@ -9,6 +9,10 @@ export const azure = {
9
9
  get detected() {
10
10
  return getEnv("SYSTEM_DEFINITIONID") !== "";
11
11
  },
12
+ get repoName() {
13
+ const repoName = getEnv("BUILD_REPOSITORY_NAME");
14
+ return repoName.split("/")?.[1] ?? repoName;
15
+ },
12
16
  get jobUid() {
13
17
  return `${getProjectID()}_${getDefinitionID()}`;
14
18
  },
@@ -9,6 +9,9 @@ export const bitbucket = {
9
9
  get detected() {
10
10
  return getEnv("BITBUCKET_PIPELINE_UUID") !== "";
11
11
  },
12
+ get repoName() {
13
+ return getEnv("BITBUCKET_REPO_SLUG");
14
+ },
12
15
  get jobUid() {
13
16
  return getEnv("BITBUCKET_REPO_FULL_NAME");
14
17
  },
@@ -15,6 +15,9 @@ export const circle = {
15
15
  const path = parseURLPath(jobURL);
16
16
  return hasEnv && path !== "";
17
17
  },
18
+ get repoName() {
19
+ return getEnv("CIRCLE_PROJECT_REPONAME");
20
+ },
18
21
  get jobUid() {
19
22
  const jobURL = getJobURL();
20
23
  return parseURLPath(jobURL);
@@ -12,6 +12,9 @@ export const drone = {
12
12
  get detected() {
13
13
  return getEnv("DRONE_SYSTEM_HOST") !== "";
14
14
  },
15
+ get repoName() {
16
+ return getEnv("DRONE_REPO_NAME");
17
+ },
15
18
  get jobUid() {
16
19
  return getEnv("DRONE_REPO");
17
20
  },
@@ -11,6 +11,10 @@ export const github = {
11
11
  get detected() {
12
12
  return getEnv("GITHUB_ACTIONS") !== "";
13
13
  },
14
+ get repoName() {
15
+ const repo = getRepo();
16
+ return repo.split("/")?.[1] ?? repo;
17
+ },
14
18
  get jobUid() {
15
19
  return `${getRepo()}_${getWorkflow()}`;
16
20
  },
@@ -33,7 +37,7 @@ export const github = {
33
37
  return `${job} #${runNumber}`;
34
38
  },
35
39
  get jobRunBranch() {
36
- return getEnv("GITHUB_REF");
40
+ return getEnv("GITHUB_HEAD_REF") || getEnv("GITHUB_REF");
37
41
  },
38
42
  get pullRequestUrl() {
39
43
  const refName = getEnv("GITHUB_REF_NAME");
@@ -5,6 +5,9 @@ export const gitlab = {
5
5
  get detected() {
6
6
  return getEnv("GITLAB_CI") !== "";
7
7
  },
8
+ get repoName() {
9
+ return getEnv("CI_PROJECT_NAME");
10
+ },
8
11
  get jobUid() {
9
12
  return getEnv("CI_PROJECT_ID");
10
13
  },
@@ -0,0 +1,9 @@
1
+ export { amazon } from "./amazon.js";
2
+ export { azure } from "./azure.js";
3
+ export { bitbucket } from "./bitbucket.js";
4
+ export { circle } from "./circle.js";
5
+ export { drone } from "./drone.js";
6
+ export { github } from "./github.js";
7
+ export { gitlab } from "./gitlab.js";
8
+ export { jenkins } from "./jenkins.js";
9
+ export { local } from "./local.js";
@@ -0,0 +1,9 @@
1
+ export { amazon } from "./amazon.js";
2
+ export { azure } from "./azure.js";
3
+ export { bitbucket } from "./bitbucket.js";
4
+ export { circle } from "./circle.js";
5
+ export { drone } from "./drone.js";
6
+ export { github } from "./github.js";
7
+ export { gitlab } from "./gitlab.js";
8
+ export { jenkins } from "./jenkins.js";
9
+ export { local } from "./local.js";
@@ -1,10 +1,17 @@
1
1
  import { CiType } from "@allurereport/core-api";
2
- import { getEnv } from "../utils.js";
2
+ import { getEnv, getReponameFromRepoUrl } from "../utils.js";
3
3
  export const jenkins = {
4
4
  type: CiType.Jenkins,
5
5
  get detected() {
6
6
  return getEnv("JENKINS_URL") !== "";
7
7
  },
8
+ get repoName() {
9
+ const gitUrl = getEnv("GIT_URL");
10
+ if (!gitUrl) {
11
+ return "";
12
+ }
13
+ return getReponameFromRepoUrl(gitUrl);
14
+ },
8
15
  get jobUid() {
9
16
  return getEnv("JOB_NAME");
10
17
  },
@@ -0,0 +1,2 @@
1
+ import { type CiDescriptor } from "@allurereport/core-api";
2
+ export declare const local: CiDescriptor;
@@ -0,0 +1,47 @@
1
+ import { CiType } from "@allurereport/core-api";
2
+ import { spawnSync } from "node:child_process";
3
+ import { basename } from "node:path";
4
+ export const local = {
5
+ type: CiType.Local,
6
+ get detected() {
7
+ return true;
8
+ },
9
+ get repoName() {
10
+ const output = spawnSync("git", ["rev-parse", "--show-toplevel"]);
11
+ if (output.error) {
12
+ return "";
13
+ }
14
+ return basename(output.stdout.toString().trim());
15
+ },
16
+ get jobUid() {
17
+ return "";
18
+ },
19
+ get jobUrl() {
20
+ return "";
21
+ },
22
+ get jobName() {
23
+ return "";
24
+ },
25
+ get jobRunUid() {
26
+ return "";
27
+ },
28
+ get jobRunUrl() {
29
+ return "";
30
+ },
31
+ get jobRunName() {
32
+ return "";
33
+ },
34
+ get jobRunBranch() {
35
+ const output = spawnSync("git", ["rev-parse", "--abbrev-ref", "HEAD"]);
36
+ if (output.error) {
37
+ return "";
38
+ }
39
+ return output.stdout.toString().trim();
40
+ },
41
+ get pullRequestUrl() {
42
+ return "";
43
+ },
44
+ get pullRequestName() {
45
+ return "";
46
+ },
47
+ };
package/dist/utils.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export declare const getEnv: (key: string) => string;
2
2
  export declare const parseURLPath: (urlString: string) => string;
3
+ export declare const getReponameFromRepoUrl: (repoUrl: string) => string;
package/dist/utils.js CHANGED
@@ -9,3 +9,4 @@ export const parseURLPath = (urlString) => {
9
9
  return "";
10
10
  }
11
11
  };
12
+ export const getReponameFromRepoUrl = (repoUrl) => repoUrl.match(/\/([^/]+?)(\.git)?$/)?.[1] ?? "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/ci",
3
- "version": "3.0.0-beta.22",
3
+ "version": "3.0.0-beta.24",
4
4
  "description": "Utilities set to get useful report data from different CI",
5
5
  "keywords": [
6
6
  "allure",
@@ -30,7 +30,7 @@
30
30
  "test": "rimraf ./out && vitest run"
31
31
  },
32
32
  "dependencies": {
33
- "@allurereport/core-api": "3.0.0-beta.22"
33
+ "@allurereport/core-api": "3.0.0-beta.24"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@stylistic/eslint-plugin": "^2.6.1",