name: Format Check

on:
  pull_request:
  workflow_dispatch:

jobs:
  format-check:
    name: format-check
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v6
        with:
          fetch-depth: 0

      - name: Fetch base branch
        run: git fetch origin ${{ github.base_ref }}

      - name: Set up JDK 21
        uses: actions/setup-java@v5
        with:
          java-version: '21'
          distribution: 'temurin'

      - name: Setup Gradle
        uses: gradle/actions/setup-gradle@v5
        with:
          cache-read-only: true

      - name: Check formatting
        run: ./gradlew --no-daemon spotlessCheck -PspotlessRatchetFrom=origin/${{ github.base_ref }}

      - name: Check i18n keys
        run: ./gradlew --no-daemon desktop:checkI18nKeys

