Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use octokit plugin config from probot #125

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"env": {
"node": true,
"es2021": true,
"es2022": true,
"jest/globals": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
"plugin:prettier/recommended"
"plugin:prettier/recommended",
"plugin:unicorn/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
Expand All @@ -19,5 +20,11 @@
"@typescript-eslint",
"jest",
"prettier"
],
"ignorePatterns": [
"node_modules",
"dist",
"lib",
"coverage"
]
}
107 changes: 107 additions & 0 deletions .res/labels.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
[
{
"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": ":hatching_chick: good first issue",
"color": "7057ff",
"description": ""
},
{
"name": ":mag: investigate",
"color": "e6625b",
"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": ":pushpin: pinned",
"color": "28008e",
"description": ""
},
{
"name": ":question: question",
"color": "3f51b5",
"description": ""
},
{
"name": ":robot: bot",
"color": "69cde9",
"description": ""
},
{
"name": ":rocket: future maybe",
"color": "fef2c0",
"description": ""
},
{
"name": ":skull: stale",
"color": "237da0",
"description": ""
},
{
"name": ":sparkles: enhancement",
"color": "0054ca",
"description": ""
},
{
"name": ":sparkling_heart: sponsor",
"color": "fedbf0",
"description": ""
},
{
"name": ":thinking: needs more info",
"color": "795548",
"description": ""
}
]
75 changes: 75 additions & 0 deletions .res/labels.merge1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
- # bot
name: ":robot: bot"
color: "69cde9"
description: ""
- # bug
name: ":bug: bug"
color: "b60205"
description: ""
## 'dependencies', 'documentation' and 'duplicate' would be deleted if not excluded
#- # dependencies
# name: ":game_die: dependencies"
# color: "0366d6"
# description: ""
#- # documentation
# name: ":memo: documentation"
# color: "c5def5"
# description: ""
#- # duplicate
# name: ":busts_in_silhouette: duplicate"
# color: "cccccc"
# description: ""
- # enhancement
name: ":sparkles: enhancement"
color: "0054ca"
description: ""
- # feature request
name: ":bulb: feature request"
color: "0e8a16"
description: ""
## 'feedback' would be updated if not excluded
- # feedback
name: ":mega: feedback"
color: "034879"
description: "Excluded"
- # future maybe
name: ":rocket: future maybe"
color: "fef2c0"
description: ""
- # good first issue
name: ":hatching_chick: good first issue"
color: "7057ff"
description: ""
- # help wanted
name: ":pray: help wanted"
color: "4caf50"
description: ""
- # hold
name: ":hand: hold"
color: "24292f"
description: ""
- # invalid
name: ":no_entry_sign: invalid"
color: "e6e6e6"
description: ""
- # maybe bug
name: ":interrobang: maybe bug"
color: "ff5722"
description: ""
- # needs more info
name: ":thinking: needs more info"
color: "795548"
description: ""
- # question
name: ":question: question"
color: "3f51b5"
description: ""
- # upstream
name: ":eyes: upstream"
color: "fbca04"
description: ""
## ':coffin: wontfix' would be renamed if not excluded
- # wontfix_it
name: "wontfix_it"
color: "000000"
from_name: ":coffin: wontfix"
14 changes: 14 additions & 0 deletions .res/labels.merge2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
_extends: ghaction-github-labeler:.res/labels.merge1.yml
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the context of ghaction-github-labeler:? Repo? Org?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the context is a bit odd indeed

usually you can simply refer to .github if you follow the pattern of using the same filename.
however in this case I chose to pick out the file and repo.

You can see the full regex here:
https://github.com/probot/octokit-plugin-config/blob/8443c9a4a2659f2f8661d4d496a62531edeca8ce/src/util/extends-to-get-content-params.ts#L8-L15

also docced at: https://github.com/probot/octokit-plugin-config#the-_extends-key

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the context is repo on a specific file.

You can also pull from another org as long as you have read permissions.
This is meant to satisfy a merge test.

labels:
- # bot
name: ":robot: bot"
color: "69cde9"
description: "I am robot"
- # bug
name: ":bug: bug"
color: "b60205"
description: "Damn bugs"
- # unicorn
name: ":unicorn: Special"
color: "ffffff"
description: ""
1 change: 1 addition & 0 deletions .res/labels.merge3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_extends: ghaction-github-labeler:.res/labels.merge1.yml
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ jobs:
labeler:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Run Labeler
if: success()
Expand Down
86 changes: 74 additions & 12 deletions __tests__/context.test.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,97 @@
import {describe, expect, it} from '@jest/globals';
import * as context from '../src/context';
import {describe, expect, it, beforeEach} from '@jest/globals';
import path from 'node:path';
import {getInputList, getInputs} from '../src/context.js';

describe('getInputList', () => {
it('handles single line correctly', async () => {
await setInput('foo', 'bar');
const res = await context.getInputList('foo');
expect(res).toEqual(['bar']);
const actual = await getInputList('foo');
expect(actual).toEqual(['bar']);
});

it('handles multiple lines correctly', async () => {
setInput('foo', 'bar\nbaz');
const res = await context.getInputList('foo');
expect(res).toEqual(['bar', 'baz']);
const actual = await getInputList('foo');
expect(actual).toEqual(['bar', 'baz']);
});

it('handles comma correctly', async () => {
setInput('foo', 'bar,baz');
const res = await context.getInputList('foo');
expect(res).toEqual(['bar', 'baz']);
const actual = await getInputList('foo');
expect(actual).toEqual(['bar', 'baz']);
});

it('handles different new lines correctly', async () => {
setInput('foo', 'bar\r\nbaz');
const res = await context.getInputList('foo');
expect(res).toEqual(['bar', 'baz']);
const actual = await getInputList('foo');
expect(actual).toEqual(['bar', 'baz']);
});

it('handles different new lines and comma correctly', async () => {
setInput('foo', 'bar\r\nbaz,bat');
const res = await context.getInputList('foo');
expect(res).toEqual(['bar', 'baz', 'bat']);
const actual = await getInputList('foo');
expect(actual).toEqual(['bar', 'baz', 'bat']);
});

it('handles empty lines correctly', async () => {
setInput('foo', '');
const actual = await getInputList('foo');
expect(actual).toEqual([]);
});
});
describe('getInputs', () => {
beforeEach(() => {
setInput('skip-delete', 'false');
setInput('dry-run', 'false');
});
it('handles inputs correctly', async () => {
const actual = await getInputs();
expect(actual).toEqual({
dryRun: false,
exclude: [],
githubToken: '',
skipDelete: false,
yamlFile: path.join('.github/labels.yml')
});
});

it('handles github token', async () => {
setInput('github-token', 'foo');
const actual = await getInputs();
expect(actual).toEqual({
dryRun: false,
exclude: [],
githubToken: 'foo',
skipDelete: false,
yamlFile: path.join('.github/labels.yml')
});
setInput('github-token', '');
});

it('handles multiple lines correctly', async () => {
setInput('exclude', 'foo\nbar');
const actual = await getInputs();
expect(actual).toEqual({
dryRun: false,
exclude: ['foo', 'bar'],
githubToken: '',
skipDelete: false,
yamlFile: path.join('.github/labels.yml')
});
setInput('exclude', '');
});

it('handles boolean inputs correctly', async () => {
setInput('skip-delete', 'true');
setInput('dry-run', 'true');
const actual = await getInputs();
expect(actual).toEqual({
dryRun: true,
exclude: [],
githubToken: '',
skipDelete: true,
yamlFile: path.join('.github/labels.yml')
});
});
});

Expand Down
Loading