Skip to content

Commit 5ffd82b

Browse files
committed
use octokit plugin config from probot
1 parent e3f5171 commit 5ffd82b

File tree

7 files changed

+7449
-2742
lines changed

7 files changed

+7449
-2742
lines changed

Diff for: .res/labels.json

+182
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
[
2+
{
3+
"id": 2128338229,
4+
"node_id": "MDU6TGFiZWwyMTI4MzM4MjI5",
5+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:bell:%20automerge",
6+
"name": ":bell: automerge",
7+
"color": "8f4fbc",
8+
"default": false,
9+
"description": ""
10+
},
11+
{
12+
"id": 1972539243,
13+
"node_id": "MDU6TGFiZWwxOTcyNTM5MjQz",
14+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:bug:%20bug",
15+
"name": ":bug: bug",
16+
"color": "b60205",
17+
"default": false,
18+
"description": ""
19+
},
20+
{
21+
"id": 1972539282,
22+
"node_id": "MDU6TGFiZWwxOTcyNTM5Mjgy",
23+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:bulb:%20feature%20request",
24+
"name": ":bulb: feature request",
25+
"color": "0e8a16",
26+
"default": false,
27+
"description": ""
28+
},
29+
{
30+
"id": 1972539271,
31+
"node_id": "MDU6TGFiZWwxOTcyNTM5Mjcx",
32+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:busts_in_silhouette:%20duplicate",
33+
"name": ":busts_in_silhouette: duplicate",
34+
"color": "cccccc",
35+
"default": false,
36+
"description": ""
37+
},
38+
{
39+
"id": 1972539332,
40+
"node_id": "MDU6TGFiZWwxOTcyNTM5MzMy",
41+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:coffin:%20wontfix",
42+
"name": ":coffin: wontfix",
43+
"color": "ffffff",
44+
"default": false,
45+
"description": ""
46+
},
47+
{
48+
"id": 1972539331,
49+
"node_id": "MDU6TGFiZWwxOTcyNTM5MzMx",
50+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:eyes:%20upstream",
51+
"name": ":eyes: upstream",
52+
"color": "fbca04",
53+
"default": false,
54+
"description": ""
55+
},
56+
{
57+
"id": 1972539259,
58+
"node_id": "MDU6TGFiZWwxOTcyNTM5MjU5",
59+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:game_die:%20dependencies",
60+
"name": ":game_die: dependencies",
61+
"color": "0366d6",
62+
"default": false,
63+
"description": ""
64+
},
65+
{
66+
"id": 1972539312,
67+
"node_id": "MDU6TGFiZWwxOTcyNTM5MzEy",
68+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:hand:%20hold",
69+
"name": ":hand: hold",
70+
"color": "24292f",
71+
"default": false,
72+
"description": ""
73+
},
74+
{
75+
"id": 1972539298,
76+
"node_id": "MDU6TGFiZWwxOTcyNTM5Mjk4",
77+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:hatching_chick:%20good%20first%20issue",
78+
"name": ":hatching_chick: good first issue",
79+
"color": "7057ff",
80+
"default": false,
81+
"description": ""
82+
},
83+
{
84+
"id": 1972539319,
85+
"node_id": "MDU6TGFiZWwxOTcyNTM5MzE5",
86+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:interrobang:%20maybe%20bug",
87+
"name": ":interrobang: maybe bug",
88+
"color": "ff5722",
89+
"default": false,
90+
"description": ""
91+
},
92+
{
93+
"id": 1972539285,
94+
"node_id": "MDU6TGFiZWwxOTcyNTM5Mjg1",
95+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:mega:%20feedback",
96+
"name": ":mega: feedback",
97+
"color": "03a9f4",
98+
"default": false,
99+
"description": ""
100+
},
101+
{
102+
"id": 1972539263,
103+
"node_id": "MDU6TGFiZWwxOTcyNTM5MjYz",
104+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:memo:%20documentation",
105+
"name": ":memo: documentation",
106+
"color": "c5def5",
107+
"default": false,
108+
"description": ""
109+
},
110+
{
111+
"id": 1972539318,
112+
"node_id": "MDU6TGFiZWwxOTcyNTM5MzE4",
113+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:no_entry_sign:%20invalid",
114+
"name": ":no_entry_sign: invalid",
115+
"color": "e6e6e6",
116+
"default": false,
117+
"description": ""
118+
},
119+
{
120+
"id": 1972539306,
121+
"node_id": "MDU6TGFiZWwxOTcyNTM5MzA2",
122+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:pray:%20help%20wanted",
123+
"name": ":pray: help wanted",
124+
"color": "4caf50",
125+
"default": false,
126+
"description": ""
127+
},
128+
{
129+
"id": 1972539330,
130+
"node_id": "MDU6TGFiZWwxOTcyNTM5MzMw",
131+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:question:%20question",
132+
"name": ":question: question",
133+
"color": "3f51b5",
134+
"default": false,
135+
"description": ""
136+
},
137+
{
138+
"id": 1972539239,
139+
"node_id": "MDU6TGFiZWwxOTcyNTM5MjM5",
140+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:robot:%20bot",
141+
"name": ":robot: bot",
142+
"color": "69cde9",
143+
"default": false,
144+
"description": ""
145+
},
146+
{
147+
"id": 1972539291,
148+
"node_id": "MDU6TGFiZWwxOTcyNTM5Mjkx",
149+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:rocket:%20future%20maybe",
150+
"name": ":rocket: future maybe",
151+
"color": "fef2c0",
152+
"default": false,
153+
"description": ""
154+
},
155+
{
156+
"id": 2488477631,
157+
"node_id": "MDU6TGFiZWwyNDg4NDc3NjMx",
158+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:skull:%20stale",
159+
"name": ":skull: stale",
160+
"color": "ffffff",
161+
"default": false,
162+
"description": null
163+
},
164+
{
165+
"id": 1972539273,
166+
"node_id": "MDU6TGFiZWwxOTcyNTM5Mjcz",
167+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:sparkles:%20enhancement",
168+
"name": ":sparkles: enhancement",
169+
"color": "0054ca",
170+
"default": false,
171+
"description": ""
172+
},
173+
{
174+
"id": 1972539327,
175+
"node_id": "MDU6TGFiZWwxOTcyNTM5MzI3",
176+
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:thinking:%20needs%20more%20info",
177+
"name": ":thinking: needs more info",
178+
"color": "795548",
179+
"default": false,
180+
"description": ""
181+
}
182+
]

Diff for: README.md

+9-11
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ If you are interested, [check out](https://git.io/Je09Y) my other :octocat: GitH
1515

1616
___
1717

18-
* [Usage](#usage)
19-
* [YAML configuration](#yaml-configuration)
20-
* [Workflow](#workflow)
21-
* [Customizing](#customizing)
22-
* [inputs](#inputs)
23-
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
24-
* [How can I help?](#how-can-i-help)
25-
* [License](#license)
18+
- [About](#about)
19+
- [Usage](#usage)
20+
- [YAML configuration](#yaml-configuration)
21+
- [Workflow](#workflow)
22+
- [Customizing](#customizing)
23+
- [inputs](#inputs)
24+
- [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
25+
- [How can I help?](#how-can-i-help)
26+
- [License](#license)
2627

2728
## Usage
2829

@@ -63,9 +64,6 @@ jobs:
6364
labeler:
6465
runs-on: ubuntu-latest
6566
steps:
66-
-
67-
name: Checkout
68-
uses: actions/checkout@v2
6967
-
7068
name: Run Labeler
7169
if: success()

Diff for: __tests__/labeler.test.ts

+34-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1+
import fs from 'fs';
2+
import nock from 'nock';
13
import {Inputs} from '../src/context';
24
import {Labeler, LabelStatus} from '../src/labeler';
35

6+
process.env.GITHUB_REPOSITORY = 'crazy-max/ghaction-github-labeler';
7+
8+
function configFixture(fileName: string) {
9+
return fs.readFileSync(`${__dirname}/../${fileName}`);
10+
}
11+
12+
function labelsFixture() {
13+
const content = fs.readFileSync(`${__dirname}/../.res/labels.json`).toString();
14+
return JSON.parse(content);
15+
}
16+
417
const cases = [
518
[
619
'labels.update.yml',
720
{
8-
githubToken: process.env.GITHUB_TOKEN || '',
21+
githubToken: process.env.GITHUB_TOKEN || 'test',
922
yamlFile: '.res/labels.update.yml',
1023
skipDelete: true,
1124
dryRun: true,
@@ -24,7 +37,7 @@ const cases = [
2437
[
2538
'labels.exclude1.yml',
2639
{
27-
githubToken: process.env.GITHUB_TOKEN || '',
40+
githubToken: process.env.GITHUB_TOKEN || 'test',
2841
yamlFile: '.res/labels.exclude1.yml',
2942
skipDelete: true,
3043
dryRun: true,
@@ -43,7 +56,7 @@ const cases = [
4356
[
4457
'labels.exclude2.yml',
4558
{
46-
githubToken: process.env.GITHUB_TOKEN || '',
59+
githubToken: process.env.GITHUB_TOKEN || 'test',
4760
yamlFile: '.res/labels.exclude2.yml',
4861
skipDelete: true,
4962
dryRun: true,
@@ -62,8 +75,25 @@ const cases = [
6275
];
6376

6477
describe('run', () => {
78+
beforeAll(() => {
79+
nock.disableNetConnect();
80+
// nock.recorder.rec();
81+
});
82+
afterAll(() => {
83+
// nock.restore()
84+
nock.cleanAll();
85+
nock.enableNetConnect();
86+
});
6587
test.each(cases)('given %p', async (name, inputs, expected) => {
66-
const labeler = new Labeler(inputs as Inputs);
88+
const input = inputs as Inputs;
89+
90+
nock('https://api.github.com').get('/repos/crazy-max/ghaction-github-labeler/labels').reply(200, labelsFixture());
91+
92+
nock('https://api.github.com')
93+
.get(`/repos/crazy-max/ghaction-github-labeler/contents/${encodeURIComponent(input.yamlFile as string)}`)
94+
.reply(200, configFixture(input.yamlFile as string));
95+
96+
const labeler = new Labeler(input);
6797
await labeler.printRepoLabels();
6898
console.log(
6999
(await labeler.labels).map(label => {

0 commit comments

Comments
 (0)