diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index de0fa39d..f68b9656 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -4,11 +4,23 @@ on: [push, pull_request] jobs: - style: + sanity_check: needs: [macOS, linux, windows] runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v1 + with: + submodules: recursive + # needed because of commit-lint, see https://github.com/conventional-changelog/commitlint/issues/3376 + fetch-depth: 0 + + - name: Install dependencies of commitlint + run: sudo apt install --yes npm && npm install @commitlint/config-conventional + - name: Pull our commitlint configuration + run: sudo apt install wget && wget https://raw.githubusercontent.com/nblockchain/conventions/master/commitlint.config.ts + - name: Validate current commit (last commit) with commitlint + run: npx commitlint --from HEAD~1 --to HEAD --verbose + - name: Setup .NET SDK 5.0.x uses: actions/setup-dotnet@v1.7.2 with: diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml new file mode 100644 index 00000000..8191600f --- /dev/null +++ b/.github/workflows/commitlint.yml @@ -0,0 +1,19 @@ +name: Lint commit messages + +on: pull_request + +jobs: + commitlint: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Install dependencies of commitlint + run: sudo apt install --yes npm && npm install @commitlint/config-conventional + - name: Pull our commitlint configuration + run: sudo apt install --yes wget && wget https://raw.githubusercontent.com/nblockchain/conventions/master/commitlint.config.ts + - name: Validate all commits from PR + run: | + echo 'Going to run commitlint for ${{ github.event.pull_request.commits }} commits' + npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 924bfe21..a3ce4cc7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,3 +23,5 @@ https://github.com/nblockchain/fantomless/commit/138146e3e8fc7e8d9d8404ef9956ace For reference on how we like commit messages to be formatted, and other recommendations, please read our [Workflow guidelines](https://github.com/nblockchain/conventions/blob/master/WorkflowGuidelines.md). +We even have a CI step that checks for common mistakes in commit messages, +based on a tool called 'commitlint'.