name: CI
on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main
      - next

jobs:
  lint:
    name: lint
    runs-on: ubuntu-latest
    if: github.repository == 'openai/openai-java'

    steps:
      - uses: actions/checkout@v4

      - name: Validate Gradle wrapper
        uses: gradle/actions/wrapper-validation@v3

      - name: Set up Java
        uses: actions/setup-java@v4
        with:
          distribution: temurin
          java-version: |
            8
            17
          cache: gradle

      - name: Set up Gradle
        uses: gradle/gradle-build-action@v2

      - name: Run lints
        run: ./scripts/lint
  test:
    name: test
    runs-on: ubuntu-latest
    if: github.repository == 'openai/openai-java'

    steps:
      - uses: actions/checkout@v4

      - name: Set up Java
        uses: actions/setup-java@v4
        with:
          distribution: temurin
          java-version: |
            8
            17
          cache: gradle

      - name: Set up Gradle
        uses: gradle/gradle-build-action@v2

      - name: Run tests
        run: ./scripts/test

