aboutsummaryrefslogtreecommitdiff
on:
  workflow_dispatch:
  schedule:
    - cron: '0 12 * * 1'

env:
  SENTRY_DSN: 'https://public_key@example.com/project_id'

name: Shadow job
jobs:
  provide-agp-version-matrix:
    runs-on: ubuntu-latest
    outputs:
      agp-versions: ${{ steps.build-agp-matrix.outputs.agp-versions }}
    steps:
      - id: agp-version-finder
        uses: usefulness/agp-version-finder-action@aecea9c2f6cb188f39f5512d1d2e0bd4afda89e1 # v1
      - id: build-agp-matrix
        shell: bash
        run: echo 'agp-versions=["${{ steps.agp-version-finder.outputs.latest-beta }}","${{ steps.agp-version-finder.outputs.latest-alpha }}"]' >> $GITHUB_OUTPUT

  shadow-job:
    needs: [provide-agp-version-matrix]
    strategy:
      fail-fast: false
      matrix:
        agp-version: ${{ fromJSON(needs.provide-agp-version-matrix.outputs.agp-versions) }}
        gradle-version:
          - wrapper
          - release-nightly
          - nightly
        java-version:
          - 20
    runs-on: ubuntu-latest
    name: Run Gradle-${{ matrix.gradle-version }}, AGP-${{ matrix.agp-version }}, Java-${{ matrix.java-version }}
    steps:
    - name: Setup build environment
      uses: android-password-store/android-password-store/.github/reusable-workflows/setup-gradle@develop
      with:
        cache-read-only: true
        gradle-version: ${{ matrix.gradle-version }}
        java-version: ${{ matrix.java-version }}

    - name: Run checks
      shell: bash
      run: ./gradlew check
      env:
        DEP_OVERRIDE: true
        DEP_OVERRIDE_agp: ${{ matrix.agp-version }}

  results:
    if: ${{ always() }}
    runs-on: ubuntu-latest
    name: Final Results
    needs: [shadow-job]
    steps:
    - name: Report failure to healthchecks.io
      # see https://stackoverflow.com/a/67532120/4907315
      if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
      shell: bash
      run: curl --retry 3 "https://hc-ping.com/${HC_PING_SLUG}/fail"
      env:
        HC_PING_SLUG: ${{ secrets.HC_PING_SLUG }}

    - name: Report success to healthchecks.io
      if: ${{ contains(needs.*.result, 'success') }}
      shell: bash
      run: curl --retry 3 "https://hc-ping.com/${HC_PING_SLUG}"
      env:
        HC_PING_SLUG: ${{ secrets.HC_PING_SLUG }}