Skip to content

Commit

Permalink
(#1) WIP: Adding GitHub Action to validate PRs too and to prohibit WI…
Browse files Browse the repository at this point in the history
…P commits in PRs to prevent them from being merged.
  • Loading branch information
danrivett committed Feb 23, 2020
1 parent 115e606 commit 46bb582
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/workflows/commitlint.pr.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
plugins: ['@elevai/commitlint-plugin-github'],
extends: ['@elevai/commitlint-config-github'],
rules: {
// To disallow WIP commits
'wip-allowed': [2, 'never'],
},
};
52 changes: 52 additions & 0 deletions .github/workflows/validate-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Validate Pull Request
on: [pull_request]

jobs:
run-tests-and-linters:
name: All tests and linters
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Check out Git repository
uses: actions/checkout@v2
# We don't just checkout the last commit, but all commits
# This is so the commitlint GitHub Action below can lint commit messages
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 12

- name: npm install and build
run: |
npm install
npm run link:packages
npm run build:packages
env:
CI: true

- name: Run Tests
run: npm run test:packages
env:
CI: true

- name: Run linters
uses: samuelmeuli/lint-action@v1
with:
github_token: ${{ secrets.github_token }}
# Enable linters
eslint: true
prettier: true

- name: Set NODE_PATH so the commitlint action picks up the custom commitlint plugin from the Node.js dependencies
# $GITHUB_WORKSPACE is the path to your repository
run: echo "::set-env name=NODE_PATH::${GITHUB_WORKSPACE}/node_modules"

- name: Run commitlint action
uses: wagoid/commitlint-github-action@v1
with:
configFile: "${GITHUB_WORKSPACE}/.github/workflows/commitlint.pr.config.js"
11 changes: 10 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,14 @@
"jsxSingleQuote": true,
"jsxBracketSameLine": false,
"arrowParens": "avoid",
"trailingComma": "all"
"trailingComma": "all",

"overrides": [
{
"files": "**/*.yml",
"options": {
"singleQuote": false
}
}
]
}

0 comments on commit 46bb582

Please sign in to comment.