Skip to content

Commit

Permalink
Merge pull request #94 from check-run-reporter/user-agent
Browse files Browse the repository at this point in the history
user agent
  • Loading branch information
ianwremmel authored Mar 9, 2022
2 parents 1b3601b + ea79545 commit d67acbe
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
1 change: 0 additions & 1 deletion integrations/action/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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() }}
Expand Down
4 changes: 2 additions & 2 deletions scripts/get-action-version
Original file line number Diff line number Diff line change
@@ -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.
*/

Expand Down
2 changes: 1 addition & 1 deletion scripts/get-buildkite-version
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

Expand Down
6 changes: 2 additions & 4 deletions src/commands/split.ts
Original file line number Diff line number Diff line change
@@ -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[];
Expand Down Expand Up @@ -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'},
});

Expand Down
8 changes: 3 additions & 5 deletions src/commands/submit.ts
Original file line number Diff line number Diff line change
@@ -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> = T | undefined;

Expand Down Expand Up @@ -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(),
Expand Down
16 changes: 16 additions & 0 deletions src/lib/axios.ts
Original file line number Diff line number Diff line change
@@ -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});

0 comments on commit d67acbe

Please sign in to comment.