Skip to content

Commit 3ab61b3

Browse files
committed
disable octokit throttling in tests
1 parent c262250 commit 3ab61b3

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

Diff for: __tests__/labeler.test.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from 'fs';
22
import nock from 'nock';
3+
import {OctokitOptions} from '@octokit/core/dist-types/types';
34
import {Inputs} from '../src/context';
45
import {Labeler, LabelStatus} from '../src/labeler';
56

@@ -74,6 +75,11 @@ const cases = [
7475

7576
const orginalGitHubRepo = process.env.GITHUB_REPOSITORY;
7677

78+
const octokitOptions = {
79+
retry: {enabled: false},
80+
throttle: {enabled: false}
81+
} as OctokitOptions;
82+
7783
describe('run', () => {
7884
beforeAll(() => {
7985
process.env.GITHUB_REPOSITORY = 'crazy-max/ghaction-github-labeler';
@@ -95,7 +101,7 @@ describe('run', () => {
95101
.get(`/repos/crazy-max/ghaction-github-labeler/contents/${encodeURIComponent(input.yamlFile as string)}`)
96102
.reply(200, configFixture(input.yamlFile as string));
97103

98-
const labeler = new Labeler(input);
104+
const labeler = new Labeler(input, octokitOptions);
99105
await labeler.printRepoLabels();
100106
console.log(
101107
(await labeler.labels).map(label => {
@@ -166,7 +172,7 @@ describe('run', () => {
166172
.get(`/repos/crazy-max/ghaction-github-labeler/contents/${encodeURIComponent('.res/labels.merge1.yml')}`)
167173
.reply(200, configFixture('.res/labels.merge1.yml'));
168174

169-
const labeler = new Labeler(input);
175+
const labeler = new Labeler(input, octokitOptions);
170176
const fileLabels = await labeler.fileLabels;
171177
expect(fileLabels.length).toBe(16);
172178
expect(fileLabels[15]).toEqual(expect.objectContaining({name: ':unicorn: Special'}));

Diff for: dist/index.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/labeler.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as core from '@actions/core';
55
import {Inputs} from './context';
66
import {GitHub, getOctokitOptions, context} from '@actions/github/lib/utils';
77
import {config} from '@probot/octokit-plugin-config';
8-
import deepmerge from 'deepmerge';
8+
import {OctokitOptions} from '@octokit/core/dist-types/types';
99
export type Label = {
1010
name: string;
1111
color: string;
@@ -39,8 +39,8 @@ export class Labeler {
3939
private readonly repoLabels: Promise<Label[]>;
4040
readonly fileLabels: Promise<Label[]>;
4141

42-
constructor(inputs: Inputs) {
43-
const octokit = GitHub.plugin(config);
42+
constructor(inputs: Inputs, options: OctokitOptions = {}) {
43+
const octokit = GitHub.plugin(config).defaults(options);
4444
this.octokit = new octokit(getOctokitOptions(inputs.githubToken));
4545
this.dryRun = inputs.dryRun;
4646
this.skipDelete = inputs.skipDelete;
@@ -213,7 +213,7 @@ export class Labeler {
213213
configs
214214
.map(config => {
215215
const labels = config.labels ? config.labels : config;
216-
return {labels};
216+
return {labels: labels || []};
217217
})
218218
.map(config => {
219219
config.labels.forEach(function (item: Label) {

0 commit comments

Comments
 (0)