Skip to content

Commit 8198271

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

File tree

7 files changed

+7369
-2742
lines changed

7 files changed

+7369
-2742
lines changed

.res/labels.json

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
[
2+
{
3+
"name": ":bell: automerge",
4+
"color": "8f4fbc",
5+
"description": ""
6+
},
7+
{
8+
"name": ":bug: bug",
9+
"color": "b60205",
10+
"description": ""
11+
},
12+
{
13+
"name": ":bulb: feature request",
14+
"color": "0e8a16",
15+
"description": ""
16+
},
17+
{
18+
"name": ":busts_in_silhouette: duplicate",
19+
"color": "cccccc",
20+
"description": ""
21+
},
22+
{
23+
"name": ":coffin: wontfix",
24+
"color": "ffffff",
25+
"description": ""
26+
},
27+
{
28+
"name": ":eyes: upstream",
29+
"color": "fbca04",
30+
"description": ""
31+
},
32+
{
33+
"name": ":game_die: dependencies",
34+
"color": "0366d6",
35+
"description": ""
36+
},
37+
{
38+
"name": ":hand: hold",
39+
"color": "24292f",
40+
"description": ""
41+
},
42+
{
43+
"name": ":hatching_chick: good first issue",
44+
"color": "7057ff",
45+
"description": ""
46+
},
47+
{
48+
"name": ":interrobang: maybe bug",
49+
"color": "ff5722",
50+
"description": ""
51+
},
52+
{
53+
"name": ":mega: feedback",
54+
"color": "03a9f4",
55+
"description": ""
56+
},
57+
{
58+
"name": ":memo: documentation",
59+
"color": "c5def5",
60+
"description": ""
61+
},
62+
{
63+
"name": ":no_entry_sign: invalid",
64+
"color": "e6e6e6",
65+
"description": ""
66+
},
67+
{
68+
"name": ":pray: help wanted",
69+
"color": "4caf50",
70+
"description": ""
71+
},
72+
{
73+
"name": ":question: question",
74+
"color": "3f51b5",
75+
"description": ""
76+
},
77+
{
78+
"name": ":robot: bot",
79+
"color": "69cde9",
80+
"description": ""
81+
},
82+
{
83+
"name": ":rocket: future maybe",
84+
"color": "fef2c0",
85+
"description": ""
86+
},
87+
{
88+
"name": ":skull: stale",
89+
"color": "ffffff",
90+
"description": null
91+
},
92+
{
93+
"name": ":sparkles: enhancement",
94+
"color": "0054ca",
95+
"description": ""
96+
},
97+
{
98+
"name": ":thinking: needs more info",
99+
"color": "795548",
100+
"description": ""
101+
}
102+
]

README.md

Lines changed: 9 additions & 11 deletions
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()

__tests__/labeler.test.ts

Lines changed: 34 additions & 4 deletions
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)