Skip to content

Commit

Permalink
use octokit plugin config from probot
Browse files Browse the repository at this point in the history
  • Loading branch information
jetersen committed Jan 8, 2021
1 parent e3f5171 commit 5ffd82b
Show file tree
Hide file tree
Showing 7 changed files with 7,449 additions and 2,742 deletions.
182 changes: 182 additions & 0 deletions .res/labels.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
[
{
"id": 2128338229,
"node_id": "MDU6TGFiZWwyMTI4MzM4MjI5",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:bell:%20automerge",
"name": ":bell: automerge",
"color": "8f4fbc",
"default": false,
"description": ""
},
{
"id": 1972539243,
"node_id": "MDU6TGFiZWwxOTcyNTM5MjQz",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:bug:%20bug",
"name": ":bug: bug",
"color": "b60205",
"default": false,
"description": ""
},
{
"id": 1972539282,
"node_id": "MDU6TGFiZWwxOTcyNTM5Mjgy",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:bulb:%20feature%20request",
"name": ":bulb: feature request",
"color": "0e8a16",
"default": false,
"description": ""
},
{
"id": 1972539271,
"node_id": "MDU6TGFiZWwxOTcyNTM5Mjcx",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:busts_in_silhouette:%20duplicate",
"name": ":busts_in_silhouette: duplicate",
"color": "cccccc",
"default": false,
"description": ""
},
{
"id": 1972539332,
"node_id": "MDU6TGFiZWwxOTcyNTM5MzMy",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:coffin:%20wontfix",
"name": ":coffin: wontfix",
"color": "ffffff",
"default": false,
"description": ""
},
{
"id": 1972539331,
"node_id": "MDU6TGFiZWwxOTcyNTM5MzMx",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:eyes:%20upstream",
"name": ":eyes: upstream",
"color": "fbca04",
"default": false,
"description": ""
},
{
"id": 1972539259,
"node_id": "MDU6TGFiZWwxOTcyNTM5MjU5",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:game_die:%20dependencies",
"name": ":game_die: dependencies",
"color": "0366d6",
"default": false,
"description": ""
},
{
"id": 1972539312,
"node_id": "MDU6TGFiZWwxOTcyNTM5MzEy",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:hand:%20hold",
"name": ":hand: hold",
"color": "24292f",
"default": false,
"description": ""
},
{
"id": 1972539298,
"node_id": "MDU6TGFiZWwxOTcyNTM5Mjk4",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:hatching_chick:%20good%20first%20issue",
"name": ":hatching_chick: good first issue",
"color": "7057ff",
"default": false,
"description": ""
},
{
"id": 1972539319,
"node_id": "MDU6TGFiZWwxOTcyNTM5MzE5",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:interrobang:%20maybe%20bug",
"name": ":interrobang: maybe bug",
"color": "ff5722",
"default": false,
"description": ""
},
{
"id": 1972539285,
"node_id": "MDU6TGFiZWwxOTcyNTM5Mjg1",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:mega:%20feedback",
"name": ":mega: feedback",
"color": "03a9f4",
"default": false,
"description": ""
},
{
"id": 1972539263,
"node_id": "MDU6TGFiZWwxOTcyNTM5MjYz",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:memo:%20documentation",
"name": ":memo: documentation",
"color": "c5def5",
"default": false,
"description": ""
},
{
"id": 1972539318,
"node_id": "MDU6TGFiZWwxOTcyNTM5MzE4",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:no_entry_sign:%20invalid",
"name": ":no_entry_sign: invalid",
"color": "e6e6e6",
"default": false,
"description": ""
},
{
"id": 1972539306,
"node_id": "MDU6TGFiZWwxOTcyNTM5MzA2",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:pray:%20help%20wanted",
"name": ":pray: help wanted",
"color": "4caf50",
"default": false,
"description": ""
},
{
"id": 1972539330,
"node_id": "MDU6TGFiZWwxOTcyNTM5MzMw",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:question:%20question",
"name": ":question: question",
"color": "3f51b5",
"default": false,
"description": ""
},
{
"id": 1972539239,
"node_id": "MDU6TGFiZWwxOTcyNTM5MjM5",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:robot:%20bot",
"name": ":robot: bot",
"color": "69cde9",
"default": false,
"description": ""
},
{
"id": 1972539291,
"node_id": "MDU6TGFiZWwxOTcyNTM5Mjkx",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:rocket:%20future%20maybe",
"name": ":rocket: future maybe",
"color": "fef2c0",
"default": false,
"description": ""
},
{
"id": 2488477631,
"node_id": "MDU6TGFiZWwyNDg4NDc3NjMx",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:skull:%20stale",
"name": ":skull: stale",
"color": "ffffff",
"default": false,
"description": null
},
{
"id": 1972539273,
"node_id": "MDU6TGFiZWwxOTcyNTM5Mjcz",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:sparkles:%20enhancement",
"name": ":sparkles: enhancement",
"color": "0054ca",
"default": false,
"description": ""
},
{
"id": 1972539327,
"node_id": "MDU6TGFiZWwxOTcyNTM5MzI3",
"url": "https://api.github.com/repos/crazy-max/ghaction-github-labeler/labels/:thinking:%20needs%20more%20info",
"name": ":thinking: needs more info",
"color": "795548",
"default": false,
"description": ""
}
]
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ If you are interested, [check out](https://git.io/Je09Y) my other :octocat: GitH

___

* [Usage](#usage)
* [YAML configuration](#yaml-configuration)
* [Workflow](#workflow)
* [Customizing](#customizing)
* [inputs](#inputs)
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
* [How can I help?](#how-can-i-help)
* [License](#license)
- [About](#about)
- [Usage](#usage)
- [YAML configuration](#yaml-configuration)
- [Workflow](#workflow)
- [Customizing](#customizing)
- [inputs](#inputs)
- [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
- [How can I help?](#how-can-i-help)
- [License](#license)

## Usage

Expand Down Expand Up @@ -63,9 +64,6 @@ jobs:
labeler:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Run Labeler
if: success()
Expand Down
38 changes: 34 additions & 4 deletions __tests__/labeler.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import fs from 'fs';
import nock from 'nock';
import {Inputs} from '../src/context';
import {Labeler, LabelStatus} from '../src/labeler';

process.env.GITHUB_REPOSITORY = 'crazy-max/ghaction-github-labeler';

function configFixture(fileName: string) {
return fs.readFileSync(`${__dirname}/../${fileName}`);
}

function labelsFixture() {
const content = fs.readFileSync(`${__dirname}/../.res/labels.json`).toString();
return JSON.parse(content);
}

const cases = [
[
'labels.update.yml',
{
githubToken: process.env.GITHUB_TOKEN || '',
githubToken: process.env.GITHUB_TOKEN || 'test',
yamlFile: '.res/labels.update.yml',
skipDelete: true,
dryRun: true,
Expand All @@ -24,7 +37,7 @@ const cases = [
[
'labels.exclude1.yml',
{
githubToken: process.env.GITHUB_TOKEN || '',
githubToken: process.env.GITHUB_TOKEN || 'test',
yamlFile: '.res/labels.exclude1.yml',
skipDelete: true,
dryRun: true,
Expand All @@ -43,7 +56,7 @@ const cases = [
[
'labels.exclude2.yml',
{
githubToken: process.env.GITHUB_TOKEN || '',
githubToken: process.env.GITHUB_TOKEN || 'test',
yamlFile: '.res/labels.exclude2.yml',
skipDelete: true,
dryRun: true,
Expand All @@ -62,8 +75,25 @@ const cases = [
];

describe('run', () => {
beforeAll(() => {
nock.disableNetConnect();
// nock.recorder.rec();
});
afterAll(() => {
// nock.restore()
nock.cleanAll();
nock.enableNetConnect();
});
test.each(cases)('given %p', async (name, inputs, expected) => {
const labeler = new Labeler(inputs as Inputs);
const input = inputs as Inputs;

nock('https://api.github.com').get('/repos/crazy-max/ghaction-github-labeler/labels').reply(200, labelsFixture());

nock('https://api.github.com')
.get(`/repos/crazy-max/ghaction-github-labeler/contents/${encodeURIComponent(input.yamlFile as string)}`)
.reply(200, configFixture(input.yamlFile as string));

const labeler = new Labeler(input);
await labeler.printRepoLabels();
console.log(
(await labeler.labels).map(label => {
Expand Down
Loading

0 comments on commit 5ffd82b

Please sign in to comment.