Skip to content

Commit 4c7e187

Browse files
1 parent c569ba3 commit 4c7e187

File tree

14 files changed

+232
-114
lines changed

14 files changed

+232
-114
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
node-version: '12.x'
4949
- run: npm ci
5050
- run: npm test
51-
- uses: check-run-reporter/action@v2.10.3
51+
- uses: check-run-reporter/action@v2.11.0
5252
# always run, otherwise you'll only see results for passing builds
5353
if: ${{ always() }}
5454
with:

action.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ branding:
66
color: 'orange'
77
inputs:
88
hostname:
9-
default: api.check-run-reporter.com
109
description: Internal. Do not use unless directed. Supercedes --url
1110
required: false
1211
label:
@@ -37,13 +36,6 @@ inputs:
3736
Repo token to authenticate the upload. You can get your tokens from
3837
[https://www.check-run-reporter.com/repos](https://www.check-run-reporter.com/repos).
3938
required: true
40-
url:
41-
default: 'https://api.check-run-reporter.com/api/v1'
42-
description:
43-
Mostly here for future use, this let's us specify an alternate endpoint
44-
for testing new features. Unless specifically told to do so by support,
45-
please don't change this value.
46-
required: false
4739
outputs:
4840
tests:
4941
description: The names of the test files to test on this node

dist/index.js

Lines changed: 186 additions & 75 deletions
Large diffs are not rendered by default.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/commands/split.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import { Context } from '../lib/types';
22
interface SplitArgs {
3-
readonly hostname: string;
43
/** list of filenames or globs that match all available test files */
54
readonly tests: readonly string[];
65
readonly label: string;
76
readonly nodeCount: number;
87
readonly nodeIndex: number;
98
readonly token: string;
10-
readonly url: string;
119
}
1210
/**
1311
* Send the full list of available test files and get back the filees
1412
* appropriate to this node.
1513
*/
16-
export declare function split({ hostname, tests, label, nodeCount, nodeIndex, token, url }: SplitArgs, context: Context): Promise<any>;
14+
export declare function split({ tests, label, nodeCount, nodeIndex, token }: SplitArgs, context: Context): Promise<any>;
1715
export {};

dist/src/commands/submit.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { Context, Optional } from '../lib/types';
22
interface SubmitArgs {
3-
readonly hostname: string;
43
readonly label: Optional<string>;
54
readonly report: readonly string[];
65
readonly root: string;
76
readonly sha: string;
87
readonly token: string;
9-
readonly url: string;
108
}
119
/**
1210
* Submit report files to Check Run Reporter

dist/src/constants.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export declare const HOSTNAME = "api.check-run-reporter.com";
2+
export declare const BASEPATH = "/";
3+
export declare const PATH_MULTI_STEP_UPLOAD = "/api/v1/submissions/upload";
4+
export declare const PATH_SINGLE_STEP_UPLOAD = "/api/v1/submissions";
5+
export declare const PATH_SPLIT = "/api/v1/split";

dist/src/lib/axios.d.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
import { AxiosResponse } from 'axios';
2-
export declare const client: import("axios").AxiosInstance;
1+
import 'axios-debug-log';
2+
import { AxiosInstance, AxiosResponse } from 'axios';
3+
/**
4+
* Creates a new http client with configuration
5+
*/
6+
export declare function makeClient({ hostname }: {
7+
hostname?: string;
8+
}): AxiosInstance;
39
/**
410
* extract the request id from the response object
511
*/

dist/src/lib/logger.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export declare type Logger = Pick<Console, LogLevel | 'group' | 'groupEnd'>;
1010
* @param input input to sanitize into a string
1111
* @see https://github.com/actions/toolkit/blob/ea81280a4d48fb0308d40f8f12ae00d117f8acb9/packages/core/src/utils.ts#L11-L18
1212
*/
13-
export declare function toCommandValue(input: any): string;
13+
export declare function toCommandValue(input: unknown): string;
1414
export declare const logger: Logger;
1515
export declare const silentLogger: Logger;
1616
export {};

dist/src/lib/types.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { AxiosInstance } from 'axios';
12
import { Logger } from './logger';
23
export interface Context {
34
readonly logger: Logger;
5+
readonly client: AxiosInstance;
46
}
57
export declare type Optional<T> = T | undefined;

dist/src/lib/upload.d.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ interface UploadArgs {
55
readonly root: string;
66
readonly sha: string;
77
readonly token: string;
8-
readonly url: string;
98
}
109
declare type URLs = Record<string, string>;
1110
/**
@@ -15,24 +14,24 @@ declare type URLs = Record<string, string>;
1514
* is the preferred method going forward.
1615
* @deprecated use multiStepUpload instead
1716
*/
18-
export declare function singleStepUpload({ label, report, root, sha, token, url }: UploadArgs, context: Context): Promise<import("axios").AxiosResponse<any, any>>;
17+
export declare function singleStepUpload({ label, report, root, sha, token }: UploadArgs, context: Context): Promise<import("axios").AxiosResponse<any, any>>;
1918
/**
2019
* Orchestrates the multi-step upload process.
2120
* @param args
2221
* @param context
2322
*/
2423
export declare function multiStepUpload(args: UploadArgs, context: Context): Promise<void>;
2524
/** Fetches signed URLs */
26-
export declare function getSignedUploadUrls(args: UploadArgs, filenames: readonly string[]): Promise<{
25+
export declare function getSignedUploadUrls(args: UploadArgs, filenames: readonly string[], { client }: Context): Promise<{
2726
keys: string[];
2827
signature: string;
2928
urls: Record<string, string>;
3029
}>;
3130
/** Uploads directly to S3. */
32-
export declare function uploadToSignedUrls(filenames: readonly string[], urls: URLs): Promise<void>;
31+
export declare function uploadToSignedUrls(filenames: readonly string[], urls: URLs, { client }: Context): Promise<void>;
3332
/**
3433
* Informs Check Run Reporter that all files have been uploaded and that
3534
* processing may begin.
3635
*/
37-
export declare function finishMultistepUpload(args: UploadArgs, keys: readonly string[], signature: string): Promise<import("axios").AxiosResponse<any, any>>;
36+
export declare function finishMultistepUpload(args: UploadArgs, keys: readonly string[], signature: string, { client }: Context): Promise<import("axios").AxiosResponse<any, any>>;
3837
export {};

dist/src/test/context.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { Context } from '../lib/types';
2+
/**
3+
* Creates a (semi) mocked context for use in tests.
4+
*/
5+
export declare function makeTestContext(): Context;
File renamed without changes.

src/index.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import axios from 'axios';
1212

1313
import {submit} from '../../../src';
1414
import {split} from '../../../src/commands/split';
15+
import {makeClient} from '../../../src/lib/axios';
16+
import {Context} from '../../../src/lib/types';
1517

1618
const logger = {
1719
debug: core.debug.bind(core),
@@ -88,17 +90,15 @@ export async function findReports(): Promise<string[]> {
8890
}
8991

9092
interface DoSplitInput {
91-
readonly hostname: string;
9293
readonly label: string;
9394
readonly tests: string;
9495
readonly token: string;
95-
readonly url: string;
9696
}
9797

9898
/**
9999
* Wrapper around split to adapt it for github actions
100100
*/
101-
async function doSplit({hostname, label, tests, token, url}: DoSplitInput) {
101+
async function doSplit({label, tests, token}: DoSplitInput, {client}: Context) {
102102
const nodeCount = core.getInput('nodeCount');
103103
const nodeIndex = core.getInput('nodeIndex');
104104

@@ -113,15 +113,13 @@ async function doSplit({hostname, label, tests, token, url}: DoSplitInput) {
113113
try {
114114
const {filenames} = await split(
115115
{
116-
hostname,
117116
label,
118117
nodeCount: Number(nodeCount),
119118
nodeIndex: Number(nodeIndex),
120119
tests: [tests],
121120
token,
122-
url,
123121
},
124-
{logger}
122+
{client, logger}
125123
);
126124

127125
core.info(
@@ -155,17 +153,22 @@ async function main() {
155153

156154
const hostname = core.getInput('hostname');
157155
const token = core.getInput('token');
158-
const url = core.getInput('url');
156+
157+
const client = makeClient({hostname});
159158

160159
const tests = core.getInput('tests');
161160
if (tests) {
162-
return await doSplit({
163-
hostname,
164-
label,
165-
tests,
166-
token,
167-
url: `${url}/split`,
168-
});
161+
return await doSplit(
162+
{
163+
label,
164+
tests,
165+
token,
166+
},
167+
{
168+
client,
169+
logger,
170+
}
171+
);
169172
}
170173

171174
const root = determineRoot();
@@ -175,15 +178,14 @@ async function main() {
175178

176179
await submit(
177180
{
178-
hostname,
179181
label,
180182
report: files,
181183
root,
182184
sha,
183185
token,
184-
url: `${url}/submissions`,
185186
},
186187
{
188+
client,
187189
logger,
188190
}
189191
);

0 commit comments

Comments
 (0)