diff --git a/.github/workflows/conventional_commits.yaml b/.github/workflows/conventional_commits.yaml new file mode 100644 index 00000000..bfc5fa34 --- /dev/null +++ b/.github/workflows/conventional_commits.yaml @@ -0,0 +1,22 @@ +name: Conventional commits +on: + pull_request: + +jobs: + conventional-commits: + name: Conventional commits + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ github.head_ref }} + + - name: Install dart + uses: dart-lang/setup-dart@v1 + - name: Install commitlint_cli + run: dart pub get + + - name: Lint conventional commits + run: dart run commitlint_cli --from="origin/${{ github.base_ref }}" --to="${{ github.head_ref }}" diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 00000000..0f679104 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,5 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +# https://github.com/hyiso/commitlint/issues/6 +sed "s/^fixup! //" < "$1" | dart run commitlint_cli diff --git a/commitlint.yaml b/commitlint.yaml new file mode 100644 index 00000000..7bfe0a35 --- /dev/null +++ b/commitlint.yaml @@ -0,0 +1,24 @@ +include: package:commitlint_cli/commitlint.yaml + +rules: + scope-empty: + - 2 + - never + scope-enum: + - 2 + - always + - - ci + - deps + - docs + - tool + - app + - dynamite + - dynamite_runtime + - file_icons + - neon + - neon_files + - neon_news + - neon_notes + - neon_notifications + - nextcloud + - sort_box diff --git a/pubspec.yaml b/pubspec.yaml index 2abbb105..0d88afb6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,5 +4,7 @@ publish_to: none environment: sdk: '>=3.0.0 <4.0.0' dev_dependencies: + commitlint_cli: ^0.4.1 fvm: ^2.4.1 + husky: ^0.1.6 melos: ^3.1.0 diff --git a/tool/setup.sh b/tool/setup.sh index c092d266..f92e2636 100755 --- a/tool/setup.sh +++ b/tool/setup.sh @@ -6,3 +6,4 @@ dart pub global activate melos 3.1.0 dart pub global activate fvm 2.4.1 echo "y" | fvm install melos exec --concurrency=1 flutter pub get +dart run husky install