Skip to content

Commit

Permalink
add: Initial commit (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenc-nanashi authored Dec 31, 2024
1 parent c5718a1 commit 6fa22ea
Show file tree
Hide file tree
Showing 19 changed files with 2,392 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/*.js linguist-generated binary
18 changes: 18 additions & 0 deletions .github/workflows/merge_gatekeeper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Merge Gatekeeper"
on:
pull_request_target:
types: [auto_merge_enabled]
merge_group:
types: [checks_requested]

jobs:
merge_gatekeeper:
runs-on: ubuntu-latest
steps:
- uses: voicevox/merge-gatekeeper@main
with:
token: ${{ secrets.GATEKEEPER_TOKEN }}
required_score: 2
score_rules: |
#maintainer: 2
#reviewer: 1
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Test
on:
push:
branches:
- main
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install pnpm
run: corepack enable

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".node-version"
cache: "pnpm"

- name: Install Dependencies
run: |
pnpm install
- name: Check
run: |
pnpm run check
144 changes: 144 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# Created by https://www.toptal.com/developers/gitignore/api/node
# Edit at https://www.toptal.com/developers/gitignore?templates=node

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
# dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

### Node Patch ###
# Serverless Webpack directories
.webpack/

# Optional stylelint cache

# SvelteKit build / generate output
.svelte-kit

# End of https://www.toptal.com/developers/gitignore/api/node
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.18.1
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) 2024 VOICEVOX

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.
76 changes: 75 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,75 @@
# merge-gatekeeper
# Merge Gatekeeper

人やチームによって重みを付けられるApprove数チェッカーです。

## プロジェクトに貢献したいと考えている方へ

このリポジトリは主にVOICEVOX内部での利用を想定しています。
そのため、大きな機能追加は受け付けていませんが、バグ報告や小さな改善は歓迎します。

## 使い方

以下のようなWorkflowを作成してください:

```yaml
name: Merge Gatekeeper
on:
pull_request_target:
types: [auto_merge_enabled]
merge_group:
types: [checks_requested]

jobs:
merge_gatekeeper:
runs-on: ubuntu-latest
steps:
- uses: voicevox/merge-gatekeeper@main
with:
# GitHubのトークン。
# チームを指定する時に必要です。
# OrgnizationのMember権限が必要です。
token: ${{ secrets.GATEKEEPER_TOKEN }}

# 失敗時の挙動。
# fail: Workflowを失敗させる。(デフォルト)
# none: 何もしない。独自の条件を作りたい時に使います。
# outputs.scoreにスコア、outputs.resultに結果(true/false)が入ります。
on_fail: fail

# マージに必要なスコア。
required_score: 2

# ユーザー/チームとポイントの関連付け。
score_rules: |
// チームの場合は#から始めてください。
#maintainer: 2
#reviewer: 1
// ユーザーの場合は@から始めてください。
@sevenc-nanashi: 2
// それ以外の行は無視されます。
```
その後、Ruleset のRequire status checks to passに`merge_gatekeeper`を追加してください。

## 注意点

- Review when Readyボタンを押した人もApproveしたものとしてカウントされます。

## コマンド

```bash
# インストール
pnpm install
# ビルド
pnpm run build
# ビルドがされているかのチェック
pnpm run build:check
# フォーマットの確認やテストの実行
pnpm run check
```

## ライセンス

MIT Licenseで公開しています。
34 changes: 34 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "Merge Gatekeeper"
description: "マージキューのためのスコアベースのApprove数チェッカー。"
branding:
icon: "check-circle"
color: "green"
inputs:
token:
description: "APIに使うアクセストークン。"
default: "${{ github.token }}"
event:
description: "github.event。"
default: "${{ toJson(github.event) }}"
ref:
description: "github.ref。"
default: "${{ github.ref }}"
score_rules:
description: "スコアのルール。"
required: true
required_score:
description: "必要なスコア。"
required: true
on_fail:
description: "失敗時の挙動。"
default: "fail"

outputs:
score:
description: "スコア。"
result:
description: "結果。"

runs:
using: node20
main: "dist/index.js"
33 changes: 33 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"ignore": ["./dist"]
},
"formatter": {
"enabled": true,
"indentStyle": "space"
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": {
"useImportExtensions": "error"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
}
}
Loading

0 comments on commit 6fa22ea

Please sign in to comment.