Skip to content

Commit 091841f

Browse files
authored
fix: A few quick tweaks (#20)
Update url that we fetch presigned url from, and clean up data being passed to the api in that request.
1 parent e224faf commit 091841f

File tree

13 files changed

+7
-91
lines changed

13 files changed

+7
-91
lines changed

packages/bundler-plugin-core/src/errors/NoCommitShaError.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/bundler-plugin-core/src/types.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,12 @@ export interface UploadOverrides {
106106
branch?: string;
107107
/** Specify the build number manually. */
108108
build?: string;
109-
/** The commit SHA of the parent for which you are uploading coverage. */
110-
parent?: string;
111109
/** Specify the pull request number manually. */
112110
pr?: string;
113111
/** Specify the commit SHA manually. */
114112
sha?: string;
115113
/** Specify the slug manually. */
116114
slug?: string;
117-
/** Specify the tag manually. */
118-
tag?: string;
119115
/** Change the upload host (Enterprise use). */
120116
url?: string;
121117
}
@@ -145,9 +141,4 @@ export interface ProviderServiceParams {
145141
pr: string;
146142
service: string;
147143
slug: string;
148-
name?: string;
149-
tag?: string;
150-
parent?: string;
151-
project?: string;
152-
server_uri?: string;
153144
}

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

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { getPreSignedURL } from "../getPreSignedURL.ts";
55
import { FailedFetchError } from "../../errors/FailedFetchError.ts";
66
import { NoUploadTokenError } from "../../errors/NoUploadTokenError.ts";
77
import { UploadLimitReachedError } from "../../errors/UploadLimitReachedError.ts";
8-
import { NoCommitShaError } from "../../errors/NoCommitShaError.ts";
98

109
const server = setupServer();
1110

@@ -35,15 +34,12 @@ describe("getPreSignedURL", () => {
3534
consoleSpy = jest.spyOn(console, "log").mockImplementation(() => null);
3635

3736
server.use(
38-
http.post(
39-
"http://localhost/upload/service/commits/:commitSha/bundle_analysis",
40-
({}) => {
41-
if (sendError) {
42-
return HttpResponse.error();
43-
}
44-
return HttpResponse.json(data, { status });
45-
},
46-
),
37+
http.post("http://localhost/upload/bundle_analysis/v1", ({}) => {
38+
if (sendError) {
39+
return HttpResponse.error();
40+
}
41+
return HttpResponse.json(data, { status });
42+
}),
4743
);
4844

4945
return {
@@ -143,28 +139,6 @@ describe("getPreSignedURL", () => {
143139
});
144140
});
145141

146-
describe("no commit sha found", () => {
147-
it("throws an error", async () => {
148-
const { consoleSpy } = setup({
149-
data: { url: "http://example.com" },
150-
});
151-
152-
let error;
153-
try {
154-
await getPreSignedURL({
155-
apiURL: "http://localhost",
156-
globalUploadToken: "global-upload-token",
157-
serviceParams: {},
158-
});
159-
} catch (e) {
160-
error = e;
161-
}
162-
163-
expect(consoleSpy).toHaveBeenCalled();
164-
expect(error).toBeInstanceOf(NoCommitShaError);
165-
});
166-
});
167-
168142
describe("return body does not match schema", () => {
169143
it("throws an error", async () => {
170144
const { consoleSpy } = setup({

packages/bundler-plugin-core/src/utils/getPreSignedURL.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { DEFAULT_RETRY_COUNT } from "./constants.ts";
88
import { fetchWithRetry } from "./fetchWithRetry.ts";
99
import { green, red, yellow } from "./logging.ts";
1010
import { preProcessBody } from "./preProcessBody.ts";
11-
import { NoCommitShaError } from "../errors/NoCommitShaError.ts";
1211

1312
interface GetPreSignedURLArgs {
1413
apiURL: string;
@@ -35,14 +34,7 @@ export const getPreSignedURL = async ({
3534
throw new NoUploadTokenError("No upload token found");
3635
}
3736

38-
const commitSha = serviceParams?.commit;
39-
40-
if (!commitSha) {
41-
red("No commit found");
42-
throw new NoCommitShaError("No commit found");
43-
}
44-
45-
const url = `${apiURL}/upload/service/commits/${commitSha}/bundle_analysis`;
37+
const url = `${apiURL}/upload/bundle_analysis/v1`;
4638

4739
let response: Response;
4840
try {

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,6 @@ function _getSHA(inputs: ProviderUtilInputs): string {
8282
return commit ?? "";
8383
}
8484

85-
function _getProject(inputs: ProviderUtilInputs): string {
86-
const { envs } = inputs;
87-
return envs?.SYSTEM_TEAMPROJECT ?? "";
88-
}
89-
90-
function _getServerURI(inputs: ProviderUtilInputs): string {
91-
const { envs } = inputs;
92-
return envs?.SYSTEM_TEAMFOUNDATIONSERVERURI ?? "";
93-
}
94-
9585
function _getSlug(inputs: ProviderUtilInputs): string {
9686
const { args, envs } = inputs;
9787

@@ -114,8 +104,6 @@ export async function getServiceParams(
114104
commit: _getSHA(inputs),
115105
job: _getJob(inputs.envs),
116106
pr: _getPR(inputs),
117-
project: _getProject(inputs),
118-
server_uri: _getServerURI(inputs),
119107
service: _getService(),
120108
slug: _getSlug(inputs),
121109
};

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ function _getSHA(inputs: ProviderUtilInputs): string {
5151
return args?.sha ?? envs?.CI_COMMIT_SHA ?? "";
5252
}
5353

54-
function _getTag(inputs: ProviderUtilInputs): string {
55-
const { args, envs } = inputs;
56-
return args?.tag ?? envs?.CI_COMMIT_TAG ?? "";
57-
}
58-
5954
function _getSlug(inputs: ProviderUtilInputs): string {
6055
const { args, envs } = inputs;
6156
if (args?.slug && args?.slug !== "") return args?.slug;
@@ -71,7 +66,6 @@ export async function getServiceParams(
7166
build: _getBuild(inputs),
7267
buildURL: _getBuildURL(inputs),
7368
commit: _getSHA(inputs),
74-
tag: _getTag(inputs),
7569
pr: _getPR(inputs),
7670
job: _getJob(inputs),
7771
service: _getService(),

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ describe("Azure Pipelines CI Params", () => {
4646
commit: "",
4747
job: "",
4848
pr: "",
49-
project: "",
50-
server_uri: "https://example.azure.com",
5149
service: "azure_pipelines",
5250
slug: "",
5351
};
@@ -84,8 +82,6 @@ describe("Azure Pipelines CI Params", () => {
8482
commit: "testingsha",
8583
job: "2",
8684
pr: "3",
87-
project: "testOrg",
88-
server_uri: "https://example.azure.com",
8985
service: "azure_pipelines",
9086
slug: "testOrg/testRepo",
9187
};
@@ -119,8 +115,6 @@ describe("Azure Pipelines CI Params", () => {
119115
commit: "testingsha",
120116
job: "2",
121117
pr: "3",
122-
project: "testOrg",
123-
server_uri: "https://example.azure.com",
124118
service: "azure_pipelines",
125119
slug: "testOrg/testRepo",
126120
};
@@ -152,8 +146,6 @@ describe("Azure Pipelines CI Params", () => {
152146
commit: "testingsha",
153147
job: "2",
154148
pr: "",
155-
project: "testOrg",
156-
server_uri: "https://example.azure.com",
157149
service: "azure_pipelines",
158150
slug: "testOrg/testRepo",
159151
};
@@ -192,8 +184,6 @@ describe("Azure Pipelines CI Params", () => {
192184
commit: "testingmergecommitsha2345678901234567890",
193185
job: "2",
194186
pr: "3",
195-
project: "testOrg",
196-
server_uri: "https://example.azure.com",
197187
service: "azure_pipelines",
198188
slug: "testOrg/testRepo",
199189
};
@@ -233,8 +223,6 @@ describe("Azure Pipelines CI Params", () => {
233223
commit: "testsha",
234224
job: "",
235225
pr: "2",
236-
project: "",
237-
server_uri: "https://example.azure.com",
238226
service: "azure_pipelines",
239227
slug: "testOrg/otherTestRepo",
240228
};

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ describe("CircleCI Params", () => {
101101
args: {
102102
branch: "main",
103103
build: "2",
104-
parent: "parent-build-sha",
105104
pr: "1",
106105
sha: "cool-commit-sha",
107106
slug: "testOrg/testRepo",

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ describe("CloudflarePages Params", () => {
6666
args: {
6767
branch: "main",
6868
build: "2",
69-
parent: "parent-build-sha",
7069
pr: "1",
7170
sha: "cool-commit-sha",
7271
slug: "testOrg/testRepo",

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ describe("Netlify Params", () => {
6767
args: {
6868
branch: "main",
6969
build: "2",
70-
parent: "parent-build-sha",
7170
pr: "1",
7271
sha: "cool-commit-sha",
7372
slug: "testOrg/testRepo",

0 commit comments

Comments
 (0)