Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/shared-configs/scripts/validate-branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
# Branch name validation script
# Enforces conventional branch naming patterns

BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)

# Allowed patterns
PATTERN="^(feat|fix|perf|refactor|docs|chore|hotfix|release)\/[a-z0-9._-]+$"

if [[ ! $BRANCH_NAME =~ $PATTERN ]]; then
echo "❌ ERROR: Invalid branch name: '$BRANCH_NAME'"
echo ""
echo "Branch names must follow the pattern:"
echo " <type>/<name>"
echo ""
echo "Allowed types:"
echo " • feat/<name> - New features"
echo " • fix/<name> - Bug fixes"
echo " • perf/<name> - Performance improvements"
echo " • refactor/<name> - Code refactoring"
echo " • docs/<name> - Documentation changes"
echo " • chore/<name> - Maintenance tasks"
echo " • hotfix/<name> - Critical fixes"
echo " • release/<version> - Release preparation"
echo ""
echo "Examples:"
echo " ✅ feat/user-authentication"
echo " ✅ fix/login-bug"
echo " ✅ docs/api-documentation"
echo " ❌ feature/new-thing (wrong type)"
echo " ❌ random-branch-name (no type)"
echo ""
exit 1
fi

echo "✅ Branch name '$BRANCH_NAME' is valid"
exit 0
44 changes: 44 additions & 0 deletions .github/shared-configs/scripts/validate-pr-title.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
# PR title validation script
# Enforces conventional PR title format

PR_TITLE="$1"

if [ -z "$PR_TITLE" ]; then
echo "❌ ERROR: PR title not provided"
exit 1
fi

# Allowed patterns: type: message or type(scope): message
PATTERN="^(feat|fix|perf|refactor|docs|chore|hotfix|release)(\(.+\))?: .+$"

if [[ ! $PR_TITLE =~ $PATTERN ]]; then
echo "❌ ERROR: Invalid PR title: '$PR_TITLE'"
echo ""
echo "PR titles must follow the Conventional Commits format:"
echo " <type>: <message>"
echo " or"
echo " <type>(<scope>): <message>"
echo ""
echo "Allowed types:"
echo " • feat: New features"
echo " • fix: Bug fixes"
echo " • perf: Performance improvements"
echo " • refactor: Code refactoring"
echo " • docs: Documentation changes"
echo " • chore: Maintenance tasks"
echo " • hotfix: Critical fixes"
echo " • release: Release preparation"
echo ""
echo "Examples:"
echo " ✅ feat: Add user authentication"
echo " ✅ fix(api): Resolve login timeout issue"
echo " ✅ docs: Update API documentation"
echo " ❌ Added new feature (no type prefix)"
echo " ❌ feat - new thing (wrong separator)"
echo ""
exit 1
fi

echo "✅ PR title '$PR_TITLE' is valid"
exit 0
43 changes: 43 additions & 0 deletions .github/shared-configs/templates/flutter/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Pre-commit configuration for Flutter projects

repos:
# Dart formatter
- repo: local
hooks:
- id: dart-format
name: Dart format
entry: dart format
language: system
files: \.dart$
pass_filenames: true

# Dart analyzer
- repo: local
hooks:
- id: dart-analyze
name: Dart analyze
entry: dart analyze
language: system
pass_filenames: false
always_run: false
files: \.dart$

# Secret scanning
- repo: https://github.com/gitleaks/gitleaks
rev: v8.21.2
hooks:
- id: gitleaks
name: Detect secrets

# General file checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-merge-conflict
- id: check-added-large-files
args: [--maxkb=1000]
- id: mixed-line-ending
args: [--fix=lf]
101 changes: 101 additions & 0 deletions .github/shared-configs/templates/flutter/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: CI

on:
pull_request:
branches: [main, dev]
push:
branches: [main, dev]

jobs:
validate-branch:
name: Validate Branch Name
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Validate branch name
run: |
BRANCH_NAME="${{ github.head_ref }}"
PATTERN="^(feat|fix|perf|refactor|docs|chore|hotfix|release)\/[a-z0-9._-]+$"

if [[ ! $BRANCH_NAME =~ $PATTERN ]]; then
echo "❌ Invalid branch name: $BRANCH_NAME"
exit 1
fi

validate-pr-title:
name: Validate PR Title
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Validate PR title
run: |
PR_TITLE="${{ github.event.pull_request.title }}"
PATTERN="^(feat|fix|perf|refactor|docs|chore|hotfix|release)(\(.+\))?: .+$"

if [[ ! $PR_TITLE =~ $PATTERN ]]; then
echo "❌ Invalid PR title: $PR_TITLE"
exit 1
fi

analyze:
name: Dart Analyze & Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.0'
channel: 'stable'

- name: Get dependencies
run: flutter pub get

- name: Check formatting
run: dart format --set-exit-if-changed .

- name: Analyze code
run: dart analyze

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

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.0'
channel: 'stable'

- name: Get dependencies
run: flutter pub get

- name: Run tests
run: flutter test

build:
name: Build Verification
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.0'
channel: 'stable'

- name: Get dependencies
run: flutter pub get

- name: Build APK
run: flutter build apk --release
39 changes: 39 additions & 0 deletions .github/shared-configs/templates/mkdocs/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Pre-commit configuration for MkDocs documentation projects

repos:
# Markdown linting
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.42.0
hooks:
- id: markdownlint
args: [--fix]

# YAML linting
- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
args: [-c, .yamllint.yaml]

# General file checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-merge-conflict
- id: check-added-large-files
args: [--maxkb=1000]
- id: mixed-line-ending
args: [--fix=lf]

# MkDocs build check
- repo: local
hooks:
- id: mkdocs-build
name: MkDocs build check
entry: mkdocs build --strict
language: system
pass_filenames: false
files: (mkdocs\.yml|docs/.*)
15 changes: 15 additions & 0 deletions .github/shared-configs/templates/mkdocs/.yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# YAML Lint Configuration for MkDocs projects

extends: default

rules:
line-length:
max: 120
level: warning
indentation:
spaces: 2
comments:
min-spaces-from-content: 1
document-start: disable
truthy:
allowed-values: ['true', 'false', 'on', 'off']
98 changes: 98 additions & 0 deletions .github/shared-configs/templates/mkdocs/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: CI

on:
pull_request:
branches: [main, gh-pages]
push:
branches: [main, gh-pages]

jobs:
validate-branch:
name: Validate Branch Name
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Validate branch name
run: |
BRANCH_NAME="${{ github.head_ref }}"
PATTERN="^(feat|fix|perf|refactor|docs|chore|hotfix|release)\/[a-z0-9._-]+$"

if [[ ! $BRANCH_NAME =~ $PATTERN ]]; then
echo "❌ Invalid branch name: $BRANCH_NAME"
exit 1
fi

validate-pr-title:
name: Validate PR Title
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Validate PR title
run: |
PR_TITLE="${{ github.event.pull_request.title }}"
PATTERN="^(feat|fix|perf|refactor|docs|chore|hotfix|release)(\(.+\))?: .+$"

if [[ ! $PR_TITLE =~ $PATTERN ]]; then
echo "❌ Invalid PR title: $PR_TITLE"
exit 1
fi

lint:
name: Lint Markdown & YAML
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install yamllint
run: pip install yamllint

- name: Lint YAML files
run: yamllint -c .yamllint.yaml .
continue-on-error: true

- name: Setup Node.js for markdownlint
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install markdownlint
run: npm install -g markdownlint-cli

- name: Lint Markdown files
run: markdownlint docs/

build:
name: Build Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
pip install mkdocs-material
pip install -r requirements.txt
if: hashFiles('requirements.txt') != ''

- name: Build MkDocs site
run: mkdocs build --strict

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: site
path: site/
Loading
Loading