name: on-pr

permissions:
  contents: read

on:
  workflow_dispatch:
  pull_request:

jobs:
  format_check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7

      - name: Verify Gradle Wrapper
        uses: gradle/actions/wrapper-validation@v6

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

      - name: Grant execute permission for gradlew
        run: chmod +x gradlew

      - name: Run ktfmt
        run: ./gradlew ktfmtCheck