name: detekt with type resolution

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - '**'

jobs:
  plain:
    runs-on: ubuntu-latest
    if: ${{ !contains(github.event.head_commit.message, 'ci skip') }}
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v2

      - name: Setup Java
        uses: actions/setup-java@v2
        with:
          java-version: 17
          distribution: 'temurin'

      - name: Run detekt-cli with argsfile
        uses: gradle/gradle-build-action@v2
        with:
          arguments: --configuration-cache :detekt-cli:runWithArgsFile

      - name: Upload SARIF to Github using the upload-sarif action
        uses: github/codeql-action/upload-sarif@v1
        if: ${{ always() }}
        with:
          sarif_file: build/detekt-report.sarif


  gradle:
    runs-on: ubuntu-latest
    if: ${{ !contains(github.event.head_commit.message, 'ci skip') }}
    steps:
    - name: Checkout Repo
      uses: actions/checkout@v2

    - name: Setup Java
      uses: actions/setup-java@v2
      with:
        java-version: 17
        distribution: 'temurin'
    - name: Run analysis
      uses: gradle/gradle-build-action@v2
      with:
        arguments: --configuration-cache detektMain detektTest
