Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianCArnold committed Mar 13, 2023
0 parents commit 8c422c1
Show file tree
Hide file tree
Showing 14 changed files with 6,808 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
module.exports = {
parserOptions: {
ecmaVersion: 2020,
},
env: {
es6: true,
node: true,
mocha: true,
},
root: true,
extends: 'eslint:recommended',
rules: {
'array-bracket-spacing': [ 'error', 'always' ],
'array-callback-return': 'error',
'arrow-parens': 'error',
'arrow-spacing': 'error',
'block-spacing': 'error',
'brace-style': [ 'error', '1tbs', { allowSingleLine: false } ],
'comma-dangle': [ 'error', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'never',
} ],
'comma-spacing': 'error',
'comma-style': 'error',
'curly': 'error',
'dot-notation': 'error',
'eol-last': 'error',
'eqeqeq': [ 'error', 'always' ],
'func-call-spacing': 'error',
'id-length': 'error',
'indent': [ 'error', 2, { SwitchCase: 1 } ],
'key-spacing': 'error',
'keyword-spacing': 'error',
'linebreak-style': 'error',
'no-array-constructor': 'error',
'no-else-return': 'error',
'no-eval': 'error',
'no-multi-spaces': 'error',
'no-multiple-empty-lines': [ 'error', { max: 2, maxEOF: 1, maxBOF: 1 } ],
'no-new-object': 'error',
'no-param-reassign': 'error',
'no-plusplus': 'error',
'no-restricted-globals': [ 'error', 'isNaN', 'isFinite' ],
'no-spaced-func': 'error',
'no-trailing-spaces': 'error',
'no-underscore-dangle': [ 'error', { allowAfterThis: true } ],
'no-var': 'error',
'object-curly-spacing': [ 'error', 'always' ],
'operator-linebreak': [ 'error', 'before' ],
'prefer-const': 'error',
'prefer-rest-params': 'error',
'quote-props': [ 'error', 'consistent-as-needed' ],
'quotes': [ 'error', 'single', {
avoidEscape: true,
} ],
'radix': 'error',
'rest-spread-spacing': 'error',
'semi': [ 'error', 'always' ],
'space-before-blocks': 'error',
'space-in-parens': 'error',
'space-infix-ops': 'error',
'spaced-comment': [ 'error', 'always', { block: { balanced: true } } ],
},
};
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/** linguist-generated=true
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @necojackarc
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: ['**']

jobs:
test:
name: Run linter and tests
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm install

- name: Check if dist is updated
run: |
npm run build
set -e # exit immediatel if a command below returns a non-zero status
git status # display the reuslts for debugging
test -z "$(git status --porcelain)"
- name: Run linter and tests
run: |
npm run lint
npm test
npm run coverage
- name: Send test coverage report to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.node-version
.nyc_output
coverage
node_modules
1 change: 1 addition & 0 deletions .mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive: true
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Taka

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Require User Approval

![CI](https://github.com/BrianCArnold/require-user-approval/workflows/CI/badge.svg)

A GitHub Action automatically checks to make sure that certain required users have approved a pull request.

## Configuration
You need to prepare two YAML files for:

- Reviewers configuration
- Workflow configuration

### Reviewers configuration

The format of a configuration file is as follows:

```yaml
groups:
# The default reviewers
review-group-all: # This group requires all 4 users to approve a PR.
members:
- username1
- username2
- username3
- username4
required: 4 # the number of members from this group that need to approve a PR.

review-group-some: # This group requires any 2 users to approve a PR.
members:
- username5
- username6
- username7
required: 2

review-group-any: #This only requires any one user from this group to approve a PR.
members:
- username8
- username9
required: 1 # the number of members from this group that need to approve a PR.

```

Important note: Currently, this doesn't check to make sure that the number of required approvals for a group is less than or equal to the number of members specified. Don't set it to require more users than are in the group.

The default configuration file location is `.github/require_reviewers.yml` but you can override it in your workflow configuration file.

### Workflow configuration
Create a workflow file in `.github/workflows` (e.g. `.github/workflows/require_reviewers.yml`):

```yaml
name: Require User Approval

on:
pull_request_review:
types: [editted, submitted]

jobs:
require_user_approval:
name: Require User Approval
runs-on: ubuntu-latest
steps:
- name: Request review based on files changes and/or groups the author belongs to
uses: BrianCArnold/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
config: .github/require_reviewers.yml # Config file location override
```
### Thanks to necojackarc's auto-request-review, which this is largely based on.
14 changes: 14 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: 'Auto Request Review'
description: 'Automatically requests review of a pull request based on files changes and/or groups the author belongs to 🤖'
branding:
icon: 'at-sign'
color: 'green'
inputs:
token:
required: true
config:
required: false
default: '.github/require_reviewers.yml'
runs:
using: 'node16'
main: 'dist/index.js'
Loading

0 comments on commit 8c422c1

Please sign in to comment.