name: troubleshooting

on: workflow_dispatch

permissions:
  contents: read

jobs:
  build:
    runs-on: ${{ matrix.os }}
    continue-on-error: false
    strategy:
      matrix:
        #os: [ ubuntu-latest, windows-latest, macos-latest ]
        os: [ ubuntu-latest ]

    steps:
      - uses: actions/checkout@v4
      - uses: actions/cache@v4
        with:
          path: |
              ~/.m2/repository
              ~/.gradle/caches
              ~/.cache
              ~/work/pmd/target/repositories
              vendor/bundle
          key: v3-${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            v3-${{ runner.os }}-
      - name: Set up Ruby 3.3
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: 3.3
      - name: Setup Environment
        shell: bash
        run: |
          echo "LANG=en_US.UTF-8" >> $GITHUB_ENV
          echo "MAVEN_OPTS=-Daether.connector.http.connectionMaxTtl=180 -DstagingProgressTimeoutMinutes=30" >> $GITHUB_ENV
          echo "PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/26/scripts" >> $GITHUB_ENV
      - name: Check Environment
        shell: bash
        run: |
          f=check-environment.sh; \
          mkdir -p .ci && \
          ( [ -e .ci/$f ] || curl -sSL "${PMD_CI_SCRIPTS_URL}/$f" > ".ci/$f" ) && \
          chmod 755 .ci/$f && \
          .ci/$f
      - name: Build
        run: |
          f=openjdk.bash; \
          mkdir -p .ci/inc && \
          ( [ -e .ci/inc/$f ] || curl -sSL "${PMD_CI_SCRIPTS_URL}/inc/$f" > ".ci/inc/$f" ) && \
          source .ci/inc/$f ; \
          pmd_ci_openjdk_install_adoptium 11 ; \
          pmd_ci_openjdk_setdefault 11
        shell: bash
      - name: Setup tmate session
        uses: mxschmitt/action-tmate@v3
