-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial import of check_labels action
- Loading branch information
Showing
7 changed files
with
620 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
language: python | ||
python: | ||
- "3.8" | ||
- "3.8-dev" | ||
- "nightly" | ||
jobs: | ||
allow_failures: | ||
- python: "nightly" | ||
# command to install dependencies | ||
install: | ||
- pip install -r requirements.txt | ||
- pip install pytest pytest-cov codecov pylint flake8 | ||
# command to run tests | ||
script: | ||
- flake8 check_labels.py | ||
- pylint check_labels.py | ||
- pytest | ||
after_success: | ||
- codecov |
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,8 @@ | ||
FROM python:3.8-alpine | ||
|
||
COPY requirements.txt /tmp/requirements.txt | ||
RUN pip3 install -r /tmp/requirements.txt | ||
|
||
COPY check_labels.py /check_labels.py | ||
|
||
ENTRYPOINT ["/check_labels.py"] |
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,58 @@ | ||
Check Labels Action | ||
=================== | ||
|
||
This action checks the labels of a Pull Request and will succeed or fail based | ||
on the configuration. | ||
|
||
Inputs | ||
------ | ||
|
||
### `access_token` | ||
An optional [personal access token], required for private repositories and to | ||
decrease rate limiting. | ||
|
||
[personal access token]: https://github.com/settings/tokens | ||
|
||
### `set_labels` | ||
Comma-separated list of labels required to be set. Optional. Globing syntax is | ||
possible for the label name, as defined in [fnmatch]. | ||
|
||
### `unset_labels` | ||
Comma-separated list of labels required not to be set. Optional. Globing syntax | ||
is possible for the label name, as defined in [fnmatch]. | ||
|
||
### `cond_labels` | ||
Comma-separated list of (label,condition) tuples for labels introducing a | ||
condition. Optional. Globing syntax is possible for the label name, as defined | ||
in [fnmatch]. | ||
|
||
#### Supported conditions | ||
- `review.approvals>x`: If the label is set in the Pull Request it requires more | ||
than `x` approving reviews for the action to succeed | ||
|
||
[fnmatch]: https://docs.python.org/3/library/fnmatch.html | ||
|
||
# Examples | ||
|
||
We recommend the following workflow triggers: | ||
|
||
```yml | ||
on: | ||
pull_request: | ||
types: [opened, reopened, labeled, unlabeled] | ||
pull_request_review: | ||
types: [submitted, dismissed] | ||
``` | ||
The action will fail if "REQUIRE" and "MANDATORY" are not set, if any label | ||
starting with "INVALID" is set, or if "NEEDS >1 ACK" is set, but the PR only has | ||
one or no approval: | ||
```yml | ||
uses: RIOT-OS/[email protected] | ||
with: | ||
access_token: '${{ secrets.GITHUB_ACCESS_TOKEN }}' | ||
set_labels: 'REQUIRE, MANDATORY' | ||
unset_labels: 'INVALID*' | ||
cond_labels: '(NEEDS >1 ACK,review.approvals > 1)' | ||
``` |
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,27 @@ | ||
name: 'Check Pull Request Labels' | ||
author: 'Martine S. Lenders' | ||
description: 'Checks if certain labels are set or not set and allows conditions' | ||
inputs: | ||
set_labels: | ||
description: 'List of labels required to be set' | ||
required: false | ||
default: '' | ||
unset_labels: | ||
description: 'List of labels required not to be set' | ||
required: false | ||
default: '' | ||
cond_labels: | ||
description: 'List of (label,condition) tuples for labels introducing a condition' | ||
required: false | ||
default: '' | ||
access_token: | ||
description: 'A GitHub personal access tokens for private repositories' | ||
required: false | ||
default: '' | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
args: | ||
- ${{ inputs.set_labels }} | ||
- ${{ inputs.unset_labels }} | ||
- ${{ inputs.cond_labels }} |
Oops, something went wrong.