diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..67311ab --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,43 @@ +name: CI / Build & Test + +on: + push: + branches: [master] + pull_request: + branches: [master] + workflow_dispatch: {} + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name != 'master' && github.ref || github.run_id }} + cancel-in-progress: true + +jobs: + ci: + name: Check, Lint & Test (Python ${{ matrix.python-version }}) + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + python-version: ["3.11", "3.12", "3.13"] + + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v5 + + - name: Set up Python ${{ matrix.python-version }} + run: uv python install ${{ matrix.python-version }} + + - name: Install dependencies + run: uv sync --all-extras + + - name: Type check (pyrefly) + run: uv run pyrefly check + + - name: Lint (ruff) + run: uv run ruff check . + + - name: Test (pytest) + run: uv run pytest diff --git a/.github/workflows/conventional-commit.yml b/.github/workflows/conventional-commit.yml new file mode 100644 index 0000000..43253d0 --- /dev/null +++ b/.github/workflows/conventional-commit.yml @@ -0,0 +1,44 @@ +name: Conventional Commit Check + +on: + pull_request: + types: [opened, edited, synchronize] + +jobs: + validate_pr_title: + name: Validate PR Title + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Validate PR title + id: check_title + run: | + #!/bin/bash + set -euo pipefail + + # Allowed prefixes + PREFIXES=("feat" "fix" "docs" "style" "refactor" "test" "chore" "ci" "perf") + + # Get PR title + PR_TITLE=$(jq -r .pull_request.title "$GITHUB_EVENT_PATH") + echo "PR title: $PR_TITLE" + + # Regex for conventional commit: prefix[optional scope][optional !]: description + PREFIX_PATTERN=$(IFS="|"; echo "${PREFIXES[*]}") + REGEX="^(${PREFIX_PATTERN})(\\([a-zA-Z0-9_-]+\\))?(!)?: .+" + + if [[ "$PR_TITLE" =~ $REGEX ]]; then + echo "PR title follows Conventional Commits." + else + echo "PR title does NOT follow Conventional Commits." + echo "Expected format: [optional scope][!]: description" + echo "Allowed types: ${PREFIXES[*]}" + echo "Examples:" + echo " feat: add login endpoint" + echo " fix(auth)!: fix critical bug" + exit 1 + fi +