| name: AndroidX Presubmits |
| on: |
| push: |
| pull_request: |
| |
| env: |
| # Allow precise monitoring of the save/restore of Gradle User Home by `gradle-build-action` |
| # See https://github.com/marketplace/actions/gradle-build-action?version=v2.1.1#cache-debugging-and-analysis |
| GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true |
| GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: "2022.07.23" |
| jobs: |
| setup: |
| runs-on: ubuntu-latest |
| outputs: |
| gradlew_flags: ${{ steps.global-constants.outputs.gradlew_flags }} |
| steps: |
| - name: "Setup global constants" |
| id: global-constants |
| run: | |
| set -x |
| GRADLEW_FLAGS="-Dorg.gradle.internal.http.connectionTimeout=60000 \ |
| -Dorg.gradle.internal.http.socketTimeout=60000 \ |
| -Dorg.gradle.internal.repository.max.retries=20 \ |
| -Dorg.gradle.internal.repository.initial.backoff=500 \ |
| --stacktrace" |
| echo "gradlew_flags=$GRADLEW_FLAGS" >> $GITHUB_OUTPUT |
| - name: Publish build scans link |
| # No scans are produced for PRs from forked repos, so omit this notice for forked PRs. |
| if: ${{ !(github.event.pull_request && github.event.pull_request.head.repo.fork) }} |
| run: echo "::notice title=All build scans for workflow::https://ge.androidx.dev/scans?search.names=CI%20run&search.values=$GITHUB_RUN_ID" |
| |
| lint: |
| runs-on: ubuntu-latest |
| needs: [setup] |
| outputs: |
| status: ${{ steps.output-status.outputs.status }} |
| affectedFileArgs: ${{ steps.affected-file-args.outputs.files }} |
| env: |
| GRADLE_BUILD_CACHE_PASSWORD: ${{ secrets.GRADLE_BUILD_CACHE_PASSWORD }} |
| GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} |
| GRADLE_ENCRYPTION_KEY: ${{ secrets.GRADLE_ENCRYPTION_KEY }} |
| steps: |
| - name: Pull request format |
| uses: 'androidx/check-pr-format-action@main' |
| with: |
| # Enforces a `Test: <stanza>` in the pull request |
| checks: '["(.*)?Test:(.*)?"]' |
| |
| - name: "Setup JDK 17 and 21" |
| id: setup-java |
| uses: actions/setup-java@v4 |
| with: |
| distribution: "zulu" |
| java-version: | |
| 17 |
| 21 |
| |
| - name: "Set environment variables" |
| shell: bash |
| run: | |
| set -x |
| echo "DIST_DIR=$HOME/dist" >> $GITHUB_ENV |
| |
| - name: "Checkout androidx repo" |
| uses: actions/checkout@v4 |
| |
| - name: "Get changed files in push or pull_request" |
| id: changed-files |
| uses: androidx/changed-files-action@main |
| with: |
| github-token: ${{ secrets.GITHUB_TOKEN }} |
| |
| - name: "Warn on missing updateApi" |
| run: | |
| set -x |
| ./development/apilint.py -f ${{ steps.changed-files.outputs.files }} |
| |
| - name: "Parse changed-files as ktfmt args" |
| id: ktfmt-file-args |
| run: | |
| set -x |
| KTFMT_FILES=`echo "${{ steps.changed-files.outputs.files }}" | sed 's|[^ ]* *|--file=../&|g' | grep -v "*.txt"` |
| echo "ktfmt-file-args=$KTFMT_FILES" >> $GITHUB_OUTPUT |
| |
| - name: "Parse changed-files as affected files args" |
| id: affected-file-args |
| run: | |
| set -x |
| AFFECTED_FILES=`echo "${{ steps.changed-files.outputs.files_including_removals }}" | sed 's|\([^ ]\+\)|--changedFilePath=\1|g'` |
| echo "files=$AFFECTED_FILES" >> $GITHUB_OUTPUT |
| |
| - name: "Setup Gradle" |
| uses: gradle/gradle-build-action@v3-beta |
| with: |
| # Only save Gradle User Home state for builds on the 'androidx-main' branch. |
| # Builds on other branches will only read existing entries from the cache. |
| cache-read-only: ${{ github.ref != 'refs/heads/androidx-main' }} |
| |
| # Don't reuse cache entries from any other Job. |
| gradle-home-cache-strict-match: true |
| |
| cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} |
| |
| # Limit the size of the cache entry. |
| # These directories contain instrumented/transformed dependency jars which can be reconstructed relatively quickly. |
| gradle-home-cache-excludes: | |
| caches/jars-9 |
| caches/transforms-3 |
| |
| - name: "ktfmt" |
| env: |
| JAVA_HOME: ${{ steps.setup-java.outputs.path }} |
| working-directory: playground-projects/ktfmt-playground |
| run: ./gradlew -q :ktCheckFile ${{ steps.ktfmt-file-args.outputs.ktfmt-file-args }} ${{ needs.setup.outputs.gradlew_flags }} |
| |
| build-modules: |
| strategy: |
| fail-fast: false |
| matrix: |
| os: [ubuntu-latest] |
| # If you would like to remove some projects temporarily, use .github/ci-control/ci-config.json instead. |
| # Keep these in alphabetical order. |
| project: ["activity", "appcompat", "biometric", "collection", "compose-runtime", "core", "datastore", "fragment", "lifecycle", "lint", "navigation", "paging", "room", "sqlite", "work"] |
| include: |
| - project: "compose-runtime" |
| project-root: "compose/runtime" |
| - project: "collection" |
| custom-os: "macos-latest" |
| - project: "sqlite" |
| custom-os: "macos-latest" |
| runs-on: ${{ matrix.custom-os || matrix.os }} |
| needs: [setup, lint] |
| env: |
| artifact-id: ${{matrix.project}} |
| project-root: playground-projects/${{matrix.project-root || matrix.project}}-playground |
| GRADLE_BUILD_CACHE_PASSWORD: ${{ secrets.GRADLE_BUILD_CACHE_PASSWORD }} |
| GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} |
| GRADLE_ENCRYPTION_KEY: ${{ secrets.GRADLE_ENCRYPTION_KEY }} |
| steps: |
| - name: "Checkout androidx repo" |
| uses: actions/checkout@v4 |
| - name: "Check if the project should be built" |
| id: check-ci-config |
| env: |
| BRANCH_REF: ${{ github.head_ref || github.ref }} |
| run: | |
| set -x |
| RESULT=`.github/ci-control/should_run_project.py --project ${{ matrix.project }} --branch "$BRANCH_REF"` |
| echo "enabled=$RESULT" >> $GITHUB_OUTPUT |
| - name: "Run build" |
| uses: ./.github/actions/build-single-project |
| if: ${{ steps.check-ci-config.outputs.enabled == 'true' }} |
| with: |
| project: ${{ matrix.project }} |
| project-root: ${{ env.project-root }} |
| gradle-cache-password: ${{ secrets.GRADLE_BUILD_CACHE_PASSWORD }} |
| gradle-enterprise-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} |
| gradle-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} |
| gradle-flags: ${{ needs.setup.outputs.gradlew_flags }} |
| # Upload artifacts task should be in the build-single-project |
| # action but they have a tendency to fail and continue-on-error |
| # is not supported there yet. |
| # https://github.com/actions/runner/issues/1457 |
| - name: "Upload build artifacts" |
| continue-on-error: true |
| if: ${{ steps.check-ci-config.outputs.enabled == 'true' }} |
| uses: actions/upload-artifact@v4 |
| with: |
| name: artifacts_${{ matrix.project }} |
| path: ~/dist |
| - name: "Upload daemon logs" |
| continue-on-error: true |
| if: failure() |
| uses: actions/upload-artifact@v4 |
| with: |
| name: gradle-daemon-logs_${{ matrix.project }} |
| path: ~/.gradle/daemon |