-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow custom rules from configuration (#98)
- Loading branch information
Showing
11 changed files
with
626 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,54 @@ | ||
# Configuration | ||
The bot can be configured with a file located at `.github/in-solidarity.yml` in the target repo or at the same path in a repo named `.github` in the organization. | ||
The bot can be configured with a file located at `.github/in-solidarity.yml` in the target repo or at the same path in a repo named `.github` within the organization. The JSON schema is located at [docs/schema.json](https://github.com/jpoehnelt/in-solidarity-bot/blob/main/docs/schema.json). | ||
|
||
```yaml | ||
rules: | ||
master: | ||
level: off | ||
slave: | ||
level: failure | ||
foo: | ||
regex: | ||
- /foo/gi | ||
- /foobar/gi | ||
level: failure | ||
ignore: | ||
- ".github/in-solidarity.yml" # default | ||
- "**/*.yml" | ||
``` | ||
The possible levels are `['off', 'notice', 'warning', 'failure']`. These correspond to [annotation_level in the GitHub API](https://docs.github.com/en/rest/reference/checks#create-a-check-run). | ||
|
||
The default configuration can be ignored with `ignoreDefaults: true` such as in the following. | ||
|
||
```yaml | ||
rules: | ||
foo: | ||
regex: | ||
- /foo/gi | ||
- /foobar/gi | ||
level: failure | ||
ignoreDefaults: true | ||
``` | ||
This will only check the single rule. | ||
|
||
> **Note**: The merging of defaults uses array replacement. This means any array provided by the configuration will be used and default elements ignored. | ||
|
||
> **Note**: The bot uses the configuration from the default branch. Therefore any changes to the configuration in a pull request will not be used until merged. | ||
|
||
Read more about configuration for organizations at [Probot best practices](https://github.com/probot/probot/blob/master/docs/best-practices.md#store-configuration-in-the-repository). | ||
|
||
# Rules | ||
|
||
The following are the current rules. Additional rules are welcome! | ||
|
||
| rule | default level | | ||
|---|---| | ||
|[master](rules/master) | `warning` | | ||
|[slave](rules/slave) | `warning` | | ||
|[whitelist](rules/whitelist) | `warning` | | ||
|[blacklist](rules/blacklist) | `warning` | | ||
|[grandfathered](rules/grandfathered) | `warning` | | ||
|[sanity_check](rules/sanity_check) | `warning` | | ||
|[man_hours](rules/man_hours) | `warning` | | ||
|[master](rules/master.md) | `warning` | | ||
|[slave](rules/slave.md) | `warning` | | ||
|[whitelist](rules/whitelist.md) | `warning` | | ||
|[blacklist](rules/blacklist.md) | `warning` | | ||
|[grandfathered](rules/grandfathered.md) | `warning` | | ||
|[sanity_check](rules/sanity_check.md) | `warning` | | ||
|[man_hours](rules/man_hours.md) | `warning` | | ||
|
||
_This document is generated from a template using [rules.ts](https://github.com/jpoehnelt/in-solidarity-bot/blob/main/src/rules.ts) and [docs/index.ts](https://github.com/jpoehnelt/in-solidarity-bot/blob/main/docs/index.ts)._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"additionalProperties": false, | ||
"definitions": { | ||
"level": { | ||
"type": "string", | ||
"enum": [ | ||
"off", | ||
"notice", | ||
"warning", | ||
"failure" | ||
] | ||
}, | ||
"regex": { | ||
"type": "array", | ||
"minItems": 1, | ||
"items": { | ||
"type": "string", | ||
"pattern": "^/.+/[giu]*$" | ||
} | ||
}, | ||
"alternatives": { | ||
"type": "array", | ||
"items": { | ||
"type": "string", | ||
"minLength": 2 | ||
} | ||
} | ||
}, | ||
"properties": { | ||
"ignore": { | ||
"type": "array", | ||
"minitems": 1, | ||
"items": { | ||
"type": "string" | ||
} | ||
}, | ||
"ignoreDefaults": { | ||
"type": "boolean" | ||
}, | ||
"rules": { | ||
"type": "object", | ||
"properties": { | ||
"master": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"level": { | ||
"$ref": "#/definitions/level" | ||
}, | ||
"alternatives": { | ||
"$ref": "#/definitions/alternatives" | ||
}, | ||
"regex": { | ||
"$ref": "#/definitions/regex" | ||
} | ||
} | ||
}, | ||
"slave": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"level": { | ||
"$ref": "#/definitions/level" | ||
}, | ||
"alternatives": { | ||
"$ref": "#/definitions/alternatives" | ||
}, | ||
"regex": { | ||
"$ref": "#/definitions/regex" | ||
} | ||
} | ||
}, | ||
"whitelist": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"level": { | ||
"$ref": "#/definitions/level" | ||
}, | ||
"alternatives": { | ||
"$ref": "#/definitions/alternatives" | ||
}, | ||
"regex": { | ||
"$ref": "#/definitions/regex" | ||
} | ||
} | ||
}, | ||
"blacklist": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"level": { | ||
"$ref": "#/definitions/level" | ||
}, | ||
"alternatives": { | ||
"$ref": "#/definitions/alternatives" | ||
}, | ||
"regex": { | ||
"$ref": "#/definitions/regex" | ||
} | ||
} | ||
}, | ||
"grandfathered": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"level": { | ||
"$ref": "#/definitions/level" | ||
}, | ||
"alternatives": { | ||
"$ref": "#/definitions/alternatives" | ||
}, | ||
"regex": { | ||
"$ref": "#/definitions/regex" | ||
} | ||
} | ||
}, | ||
"sanity_check": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"level": { | ||
"$ref": "#/definitions/level" | ||
}, | ||
"alternatives": { | ||
"$ref": "#/definitions/alternatives" | ||
}, | ||
"regex": { | ||
"$ref": "#/definitions/regex" | ||
} | ||
} | ||
}, | ||
"man_hours": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"level": { | ||
"$ref": "#/definitions/level" | ||
}, | ||
"alternatives": { | ||
"$ref": "#/definitions/alternatives" | ||
}, | ||
"regex": { | ||
"$ref": "#/definitions/regex" | ||
} | ||
} | ||
} | ||
}, | ||
"additionalProperties": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"level": { | ||
"$ref": "#/definitions/level" | ||
}, | ||
"alternatives": { | ||
"$ref": "#/definitions/alternatives" | ||
}, | ||
"regex": { | ||
"$ref": "#/definitions/regex" | ||
} | ||
}, | ||
"required": [ | ||
"level", | ||
"regex" | ||
] | ||
} | ||
} | ||
}, | ||
"if": { | ||
"required": [ | ||
"ignoreDefaults" | ||
], | ||
"properties": { | ||
"ignoreDefaults": true | ||
} | ||
}, | ||
"then": { | ||
"required": [ | ||
"rules" | ||
], | ||
"properties": { | ||
"rules": { | ||
"type": "object", | ||
"properties": {}, | ||
"additionalProperties": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"level": { | ||
"$ref": "#/definitions/level" | ||
}, | ||
"alternatives": { | ||
"$ref": "#/definitions/alternatives" | ||
}, | ||
"regex": { | ||
"$ref": "#/definitions/regex" | ||
} | ||
}, | ||
"required": [ | ||
"level", | ||
"regex" | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,13 +13,13 @@ | |
"license": "Apache 2.0", | ||
"author": "Justin Poehnelt <[email protected]>", | ||
"scripts": { | ||
"build": "tsc -p tsconfig.json && cp -r src/templates dist/src/templates", | ||
"build": "rm -rf dist && tsc -p tsconfig.json && cp -avr src/templates/ dist/src/templates/", | ||
"format": "eslint src/*.ts --fix", | ||
"lint": "eslint src/*.ts", | ||
"start": "probot run ./dist/src/index.js", | ||
"test": "jest", | ||
"test:update": "jest --updateSnapshot", | ||
"docs": "node ./dist/src/docs/index.js" | ||
"docs": "rm -rf docs && node ./dist/src/docs/index.js" | ||
}, | ||
"jest": { | ||
"testEnvironment": "node" | ||
|
@@ -38,7 +38,8 @@ | |
"handlebars": "^4.7.6", | ||
"js-yaml": "^3.14.0", | ||
"minimatch": "^3.0.4", | ||
"probot": "^10.8.0" | ||
"probot": "^10.8.0", | ||
"regex-parser": "^2.2.11" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-node-resolve": "^9.0.0", | ||
|
Oops, something went wrong.