Skip to content

Commit

Permalink
See check-run-reporter/integrations@20a7e72 from refs/heads/main
Browse files Browse the repository at this point in the history
  • Loading branch information
semantic-release-bot committed Apr 19, 2022
1 parent c569ba3 commit 4c7e187
Show file tree
Hide file tree
Showing 14 changed files with 232 additions and 114 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
node-version: '12.x'
- run: npm ci
- run: npm test
- uses: check-run-reporter/action@v2.10.3
- uses: check-run-reporter/action@v2.11.0
# always run, otherwise you'll only see results for passing builds
if: ${{ always() }}
with:
Expand Down
8 changes: 0 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ branding:
color: 'orange'
inputs:
hostname:
default: api.check-run-reporter.com
description: Internal. Do not use unless directed. Supercedes --url
required: false
label:
Expand Down Expand Up @@ -37,13 +36,6 @@ inputs:
Repo token to authenticate the upload. You can get your tokens from
[https://www.check-run-reporter.com/repos](https://www.check-run-reporter.com/repos).
required: true
url:
default: 'https://api.check-run-reporter.com/api/v1'
description:
Mostly here for future use, this let's us specify an alternate endpoint
for testing new features. Unless specifically told to do so by support,
please don't change this value.
required: false
outputs:
tests:
description: The names of the test files to test on this node
Expand Down
261 changes: 186 additions & 75 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions dist/src/commands/split.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { Context } from '../lib/types';
interface SplitArgs {
readonly hostname: string;
/** list of filenames or globs that match all available test files */
readonly tests: readonly string[];
readonly label: string;
readonly nodeCount: number;
readonly nodeIndex: number;
readonly token: string;
readonly url: string;
}
/**
* Send the full list of available test files and get back the filees
* appropriate to this node.
*/
export declare function split({ hostname, tests, label, nodeCount, nodeIndex, token, url }: SplitArgs, context: Context): Promise<any>;
export declare function split({ tests, label, nodeCount, nodeIndex, token }: SplitArgs, context: Context): Promise<any>;
export {};
2 changes: 0 additions & 2 deletions dist/src/commands/submit.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { Context, Optional } from '../lib/types';
interface SubmitArgs {
readonly hostname: string;
readonly label: Optional<string>;
readonly report: readonly string[];
readonly root: string;
readonly sha: string;
readonly token: string;
readonly url: string;
}
/**
* Submit report files to Check Run Reporter
Expand Down
5 changes: 5 additions & 0 deletions dist/src/constants.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export declare const HOSTNAME = "api.check-run-reporter.com";
export declare const BASEPATH = "/";
export declare const PATH_MULTI_STEP_UPLOAD = "/api/v1/submissions/upload";
export declare const PATH_SINGLE_STEP_UPLOAD = "/api/v1/submissions";
export declare const PATH_SPLIT = "/api/v1/split";
10 changes: 8 additions & 2 deletions dist/src/lib/axios.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { AxiosResponse } from 'axios';
export declare const client: import("axios").AxiosInstance;
import 'axios-debug-log';
import { AxiosInstance, AxiosResponse } from 'axios';
/**
* Creates a new http client with configuration
*/
export declare function makeClient({ hostname }: {
hostname?: string;
}): AxiosInstance;
/**
* extract the request id from the response object
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/src/lib/logger.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export declare type Logger = Pick<Console, LogLevel | 'group' | 'groupEnd'>;
* @param input input to sanitize into a string
* @see https://github.com/actions/toolkit/blob/ea81280a4d48fb0308d40f8f12ae00d117f8acb9/packages/core/src/utils.ts#L11-L18
*/
export declare function toCommandValue(input: any): string;
export declare function toCommandValue(input: unknown): string;
export declare const logger: Logger;
export declare const silentLogger: Logger;
export {};
2 changes: 2 additions & 0 deletions dist/src/lib/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { AxiosInstance } from 'axios';
import { Logger } from './logger';
export interface Context {
readonly logger: Logger;
readonly client: AxiosInstance;
}
export declare type Optional<T> = T | undefined;
9 changes: 4 additions & 5 deletions dist/src/lib/upload.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ interface UploadArgs {
readonly root: string;
readonly sha: string;
readonly token: string;
readonly url: string;
}
declare type URLs = Record<string, string>;
/**
Expand All @@ -15,24 +14,24 @@ declare type URLs = Record<string, string>;
* is the preferred method going forward.
* @deprecated use multiStepUpload instead
*/
export declare function singleStepUpload({ label, report, root, sha, token, url }: UploadArgs, context: Context): Promise<import("axios").AxiosResponse<any, any>>;
export declare function singleStepUpload({ label, report, root, sha, token }: UploadArgs, context: Context): Promise<import("axios").AxiosResponse<any, any>>;
/**
* Orchestrates the multi-step upload process.
* @param args
* @param context
*/
export declare function multiStepUpload(args: UploadArgs, context: Context): Promise<void>;
/** Fetches signed URLs */
export declare function getSignedUploadUrls(args: UploadArgs, filenames: readonly string[]): Promise<{
export declare function getSignedUploadUrls(args: UploadArgs, filenames: readonly string[], { client }: Context): Promise<{
keys: string[];
signature: string;
urls: Record<string, string>;
}>;
/** Uploads directly to S3. */
export declare function uploadToSignedUrls(filenames: readonly string[], urls: URLs): Promise<void>;
export declare function uploadToSignedUrls(filenames: readonly string[], urls: URLs, { client }: Context): Promise<void>;
/**
* Informs Check Run Reporter that all files have been uploaded and that
* processing may begin.
*/
export declare function finishMultistepUpload(args: UploadArgs, keys: readonly string[], signature: string): Promise<import("axios").AxiosResponse<any, any>>;
export declare function finishMultistepUpload(args: UploadArgs, keys: readonly string[], signature: string, { client }: Context): Promise<import("axios").AxiosResponse<any, any>>;
export {};
5 changes: 5 additions & 0 deletions dist/src/test/context.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Context } from '../lib/types';
/**
* Creates a (semi) mocked context for use in tests.
*/
export declare function makeTestContext(): Context;
File renamed without changes.
34 changes: 18 additions & 16 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import axios from 'axios';

import {submit} from '../../../src';
import {split} from '../../../src/commands/split';
import {makeClient} from '../../../src/lib/axios';
import {Context} from '../../../src/lib/types';

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

interface DoSplitInput {
readonly hostname: string;
readonly label: string;
readonly tests: string;
readonly token: string;
readonly url: string;
}

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

Expand All @@ -113,15 +113,13 @@ async function doSplit({hostname, label, tests, token, url}: DoSplitInput) {
try {
const {filenames} = await split(
{
hostname,
label,
nodeCount: Number(nodeCount),
nodeIndex: Number(nodeIndex),
tests: [tests],
token,
url,
},
{logger}
{client, logger}
);

core.info(
Expand Down Expand Up @@ -155,17 +153,22 @@ async function main() {

const hostname = core.getInput('hostname');
const token = core.getInput('token');
const url = core.getInput('url');

const client = makeClient({hostname});

const tests = core.getInput('tests');
if (tests) {
return await doSplit({
hostname,
label,
tests,
token,
url: `${url}/split`,
});
return await doSplit(
{
label,
tests,
token,
},
{
client,
logger,
}
);
}

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

await submit(
{
hostname,
label,
report: files,
root,
sha,
token,
url: `${url}/submissions`,
},
{
client,
logger,
}
);
Expand Down

0 comments on commit 4c7e187

Please sign in to comment.