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 8198271
Show file tree
Hide file tree
Showing 7 changed files with 7,369 additions and 2,742 deletions.
102 changes: 102 additions & 0 deletions .res/labels.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
[
{
"name": ":bell: automerge",
"color": "8f4fbc",
"description": ""
},
{
"name": ":bug: bug",
"color": "b60205",
"description": ""
},
{
"name": ":bulb: feature request",
"color": "0e8a16",
"description": ""
},
{
"name": ":busts_in_silhouette: duplicate",
"color": "cccccc",
"description": ""
},
{
"name": ":coffin: wontfix",
"color": "ffffff",
"description": ""
},
{
"name": ":eyes: upstream",
"color": "fbca04",
"description": ""
},
{
"name": ":game_die: dependencies",
"color": "0366d6",
"description": ""
},
{
"name": ":hand: hold",
"color": "24292f",
"description": ""
},
{
"name": ":hatching_chick: good first issue",
"color": "7057ff",
"description": ""
},
{
"name": ":interrobang: maybe bug",
"color": "ff5722",
"description": ""
},
{
"name": ":mega: feedback",
"color": "03a9f4",
"description": ""
},
{
"name": ":memo: documentation",
"color": "c5def5",
"description": ""
},
{
"name": ":no_entry_sign: invalid",
"color": "e6e6e6",
"description": ""
},
{
"name": ":pray: help wanted",
"color": "4caf50",
"description": ""
},
{
"name": ":question: question",
"color": "3f51b5",
"description": ""
},
{
"name": ":robot: bot",
"color": "69cde9",
"description": ""
},
{
"name": ":rocket: future maybe",
"color": "fef2c0",
"description": ""
},
{
"name": ":skull: stale",
"color": "ffffff",
"description": null
},
{
"name": ":sparkles: enhancement",
"color": "0054ca",
"description": ""
},
{
"name": ":thinking: needs more info",
"color": "795548",
"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 8198271

Please sign in to comment.