Skip to content

Commit c46e06e

Browse files
committed
add logs to appveyorci
1 parent 948da4a commit c46e06e

File tree

2 files changed

+59
-23
lines changed

2 files changed

+59
-23
lines changed

packages/bundler-plugin-core/src/utils/providers/AppVeyorCI.ts

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,56 +13,87 @@ export function detect(envs: ProviderEnvs): boolean {
1313
);
1414
}
1515

16-
function _getBuild(inputs: ProviderUtilInputs): ProviderServiceParams["build"] {
16+
function _getBuild(
17+
inputs: ProviderUtilInputs,
18+
output: Output,
19+
): ProviderServiceParams["build"] {
1720
const { args, envs } = inputs;
1821
if (args?.build && args.build !== "") {
22+
debug(`Using build: ${args.build}`, { enabled: output.debug });
1923
return args.build;
2024
}
21-
return envs?.APPVEYOR_JOB_ID ?? null;
25+
26+
const build = envs?.APPVEYOR_BUILD_ID ?? null;
27+
debug(`Using build: ${build}`, { enabled: output.debug });
28+
29+
return build;
2230
}
2331

2432
function _getBuildURL(
2533
inputs: ProviderUtilInputs,
34+
output: Output,
2635
): ProviderServiceParams["buildURL"] {
2736
const { envs } = inputs;
37+
let buildUrl: string | null = null;
38+
2839
if (
2940
envs?.APPVEYOR_URL &&
3041
envs?.APPVEYOR_REPO_NAME &&
3142
envs?.APPVEYOR_BUILD_ID &&
3243
envs?.APPVEYOR_JOB_ID
3344
) {
34-
return `${envs?.APPVEYOR_URL}/project/${envs?.APPVEYOR_REPO_NAME}/builds/${envs?.APPVEYOR_BUILD_ID}/job/${envs?.APPVEYOR_JOB_ID}`;
45+
buildUrl = `${envs?.APPVEYOR_URL}/project/${envs?.APPVEYOR_REPO_NAME}/builds/${envs?.APPVEYOR_BUILD_ID}/job/${envs?.APPVEYOR_JOB_ID}`;
3546
}
36-
return null;
47+
48+
debug(`Using build URL: ${buildUrl}`, { enabled: output.debug });
49+
return buildUrl;
3750
}
3851

3952
function _getBranch(
4053
inputs: ProviderUtilInputs,
54+
output: Output,
4155
): ProviderServiceParams["branch"] {
4256
const { args, envs } = inputs;
4357
if (args?.branch && args.branch !== "") {
58+
debug(`Using branch: ${args.branch}`, { enabled: output.debug });
4459
return args.branch;
4560
}
46-
return envs?.APPVEYOR_REPO_BRANCH ?? null;
61+
const branch = envs?.APPVEYOR_REPO_BRANCH ?? null;
62+
debug(`Using branch: ${branch}`, { enabled: output.debug });
63+
return branch;
4764
}
4865

49-
function _getJob(envs: ProviderEnvs): ProviderServiceParams["job"] {
66+
function _getJob(
67+
envs: ProviderEnvs,
68+
output: Output,
69+
): ProviderServiceParams["job"] {
70+
let job: string | null = null;
71+
5072
if (
5173
envs?.APPVEYOR_ACCOUNT_NAME &&
5274
envs?.APPVEYOR_PROJECT_SLUG &&
5375
envs?.APPVEYOR_BUILD_VERSION
5476
) {
55-
return `${envs?.APPVEYOR_ACCOUNT_NAME}/${envs?.APPVEYOR_PROJECT_SLUG}/${envs?.APPVEYOR_BUILD_VERSION}`;
77+
job = `${envs.APPVEYOR_ACCOUNT_NAME}/${envs.APPVEYOR_PROJECT_SLUG}/${envs.APPVEYOR_BUILD_VERSION}`;
5678
}
57-
return null;
79+
80+
debug(`Using job: ${job}`, { enabled: output.debug });
81+
return job;
5882
}
5983

60-
function _getPR(inputs: ProviderUtilInputs): ProviderServiceParams["pr"] {
84+
function _getPR(
85+
inputs: ProviderUtilInputs,
86+
output: Output,
87+
): ProviderServiceParams["pr"] {
6188
const { args, envs } = inputs;
6289
if (args?.pr && args.pr !== "") {
90+
debug(`Using PR number: ${args.pr}`, { enabled: output.debug });
6391
return args.pr;
6492
}
65-
return envs?.APPVEYOR_PULL_REQUEST_NUMBER ?? null;
93+
94+
const pr = envs?.APPVEYOR_PULL_REQUEST_NUMBER ?? null;
95+
debug(`Using PR number: ${pr}`, { enabled: output.debug });
96+
return pr;
6697
}
6798

6899
function _getService(): ProviderServiceParams["service"] {
@@ -86,19 +117,24 @@ function _getSHA(
86117
const commitSha =
87118
envs?.APPVEYOR_PULL_REQUEST_HEAD_COMMIT ?? envs?.APPVEYOR_REPO_COMMIT;
88119

89-
debug(`Using commit: ${commitSha ?? ""}`, {
90-
enabled: output.debug,
91-
});
120+
debug(`Using commit: ${commitSha}`, { enabled: output.debug });
92121

93122
return commitSha ?? null;
94123
}
95124

96-
function _getSlug(inputs: ProviderUtilInputs): ProviderServiceParams["slug"] {
125+
function _getSlug(
126+
inputs: ProviderUtilInputs,
127+
output: Output,
128+
): ProviderServiceParams["slug"] {
97129
const { args, envs } = inputs;
98130
if (args?.slug && args.slug !== "") {
131+
debug(`Using slug: ${args.slug}`, { enabled: output.debug });
99132
return args.slug;
100133
}
101-
return envs?.APPVEYOR_REPO_NAME ?? null;
134+
135+
const slug = envs?.APPVEYOR_REPO_NAME ?? null;
136+
debug(`Using slug: ${slug}`, { enabled: output.debug });
137+
return slug;
102138
}
103139

104140
// eslint-disable-next-line @typescript-eslint/require-await
@@ -107,14 +143,14 @@ export async function getServiceParams(
107143
output: Output,
108144
): Promise<ProviderServiceParams> {
109145
return {
110-
branch: _getBranch(inputs),
111-
build: _getBuild(inputs),
112-
buildURL: _getBuildURL(inputs),
146+
branch: _getBranch(inputs, output),
147+
build: _getBuild(inputs, output),
148+
buildURL: _getBuildURL(inputs, output),
113149
commit: _getSHA(inputs, output),
114-
job: _getJob(inputs.envs),
115-
pr: _getPR(inputs),
150+
job: _getJob(inputs.envs, output),
151+
pr: _getPR(inputs, output),
116152
service: _getService(),
117-
slug: _getSlug(inputs),
153+
slug: _getSlug(inputs, output),
118154
};
119155
}
120156

packages/bundler-plugin-core/src/utils/providers/__tests__/AppVeyorCI.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe("AppveyorCI Params", () => {
7272
};
7373
const expected: ProviderServiceParams = {
7474
branch: "main",
75-
build: "1",
75+
build: "2",
7676
buildURL: "https://appveyor.com/project/testOrg/testRepo/builds/2/job/1",
7777
commit: "testingsha",
7878
job: "testOrg/testRepo/3",
@@ -114,7 +114,7 @@ describe("AppveyorCI Params", () => {
114114
};
115115
const expected: ProviderServiceParams = {
116116
branch: "main",
117-
build: "1",
117+
build: "2",
118118
buildURL: "https://appveyor.com/project/testOrg/testRepo/builds/2/job/1",
119119
commit: "testingsha",
120120
job: "testOrg/testRepo/3",

0 commit comments

Comments
 (0)