diff --git a/integrations/action/README.md b/integrations/action/README.md index e479588..164ced9 100644 --- a/integrations/action/README.md +++ b/integrations/action/README.md @@ -48,7 +48,6 @@ jobs: node-version: '12.x' - run: npm ci - run: npm test - # Please replace "master" with the latest git tag - uses: check-run-reporter/action@v0.0.0 # always run, otherwise you'll only see results for passing builds if: ${{ always() }} diff --git a/scripts/get-action-version b/scripts/get-action-version index ba8cd71..96903b9 100755 --- a/scripts/get-action-version +++ b/scripts/get-action-version @@ -1,8 +1,8 @@ #!/usr/bin/env node /** - * @file This file produces new version for the buildkite plugin based on the - * repo versoin. The buildkite plugin was already at version 1 when this repo + * @file This file produces new version for the action plugin based on the + * repo version. The buildkite plugin was already at version 1 when this repo * was created. */ diff --git a/scripts/get-buildkite-version b/scripts/get-buildkite-version index ba8cd71..6368fa0 100755 --- a/scripts/get-buildkite-version +++ b/scripts/get-buildkite-version @@ -2,7 +2,7 @@ /** * @file This file produces new version for the buildkite plugin based on the - * repo versoin. The buildkite plugin was already at version 1 when this repo + * repo version. The buildkite plugin was already at version 1 when this repo * was created. */ diff --git a/src/commands/split.ts b/src/commands/split.ts index d2804a1..cae2375 100644 --- a/src/commands/split.ts +++ b/src/commands/split.ts @@ -1,13 +1,11 @@ import util from 'util'; import axios from 'axios'; -import axiosRetry from 'axios-retry'; +import {client} from '../lib/axios'; import {multiGlob} from '../lib/file'; import {Context} from '../lib/types'; -axiosRetry(axios, {retries: 3}); - interface SplitArgs { /** list of filenames or globs that match all available test files */ readonly tests: readonly string[]; @@ -71,7 +69,7 @@ export async function split( logger.info(`Tests: ${filenames}`); logger.debug(`URL: ${url}`); - const response = await axios.post(url, params, { + const response = await client.post(url, params, { auth: {password: token, username: 'token'}, }); diff --git a/src/commands/submit.ts b/src/commands/submit.ts index 19b8ca5..83341af 100644 --- a/src/commands/submit.ts +++ b/src/commands/submit.ts @@ -1,14 +1,12 @@ import fs from 'fs'; import util from 'util'; -import axios from 'axios'; import FormData from 'form-data'; -import axiosRetry from 'axios-retry'; +import axios from 'axios'; import {multiGlob} from '../lib/file'; import {Context} from '../lib/types'; - -axiosRetry(axios, {retries: 3}); +import {client} from '../lib/axios'; type Optional = T | undefined; @@ -50,7 +48,7 @@ export async function submit( logger.info(`SHA: ${sha}`); logger.debug(`URL: ${url}`); - const response = await axios.post(url, formData, { + const response = await client.post(url, formData, { auth: {password: token, username: 'token'}, headers: { ...formData.getHeaders(), diff --git a/src/lib/axios.ts b/src/lib/axios.ts new file mode 100644 index 0000000..afd4063 --- /dev/null +++ b/src/lib/axios.ts @@ -0,0 +1,16 @@ +import axiosRetry from 'axios-retry'; +import axios from 'axios'; +import ci from 'ci-info'; + +import pkg from '../../package.json'; + +const {version} = pkg; + +const prInfo = typeof ci.isPR === 'boolean' ? `(PR: ${ci.isPR})` : ''; + +export const client = axios.create({ + headers: { + 'user-agent': `crr/${version} ${ci.name} ${prInfo}`, + }, +}); +axiosRetry(client, {retries: 3});