Open1
GitHug Actions
テストが失敗するPull Requestのマージを防ぐ
- テストを実行するGitHub Actionsのworkflowを作成
- workflowをstatus checkに設定する
1. テストを実行するGitHub Actionsのworkflowを作成
name: Run Test
on:
pull_request: # このworkflowを実行するトリガー
# Documentation: https://docs.github.com/ja/actions/reference/events-that-trigger-workflows#
# typesが具体的に何を示しているのかDocumentationに記載がないのでそれらしいものを列挙する
types: [ opened, reopened, edited, synchronize ]
jobs:
test: # ジョブ名: 任意でつけていいらしい
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn install
- run: yarn jest
master or mainブランチに取り込まれなくとも、pushされた and or PullRequestが作成された時点でworkflowは有効化する
2. workflowをstatus checkに設定する
- GitHubのリポジトリページの Settings -> Branches からAdd ruleでBranch Protection Ruleを作成する
- Branch name patternに保護したいブランチ名を入力する
- Require status checks to pass before mergingにチェックを入れる
- 2により現れたサブメニューに先程作成したworkflow名が出てくるのでチェックを入れる