Rahul Ravikumar | 383c25a | 2020-05-27 12:11:02 -0700 | [diff] [blame] | 1 | name: AndroidX Presubmits |
Rahul Ravikumar | c170c56 | 2020-06-26 12:20:03 -0700 | [diff] [blame] | 2 | on: |
Rahul Ravikumar | 5cbb2b5 | 2020-08-04 09:37:35 -0700 | [diff] [blame] | 3 | push: |
Yigit Boyar | 092314ea | 2021-06-17 17:21:40 -0700 | [diff] [blame] | 4 | pull_request: |
Rahul Ravikumar | 383c25a | 2020-05-27 12:11:02 -0700 | [diff] [blame] | 5 | |
Daz DeBoer | f59373c | 2022-01-28 15:46:31 +0000 | [diff] [blame] | 6 | env: |
| 7 | # Allow precise monitoring of the save/restore of Gradle User Home by `gradle-build-action` |
| 8 | # See https://github.com/marketplace/actions/gradle-build-action?version=v2.1.1#cache-debugging-and-analysis |
| 9 | GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true |
Yigit Boyar | f104452 | 2022-06-23 08:27:01 -0700 | [diff] [blame] | 10 | GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: "2022.07.23" |
Rahul Ravikumar | 383c25a | 2020-05-27 12:11:02 -0700 | [diff] [blame] | 11 | jobs: |
Dustin Lam | c0f8f1a | 2020-10-30 09:59:40 -0700 | [diff] [blame] | 12 | setup: |
| 13 | runs-on: ubuntu-latest |
Dustin Lam | 860f8dd | 2021-04-12 16:45:58 -0700 | [diff] [blame] | 14 | outputs: |
| 15 | gradlew_flags: ${{ steps.global-constants.outputs.gradlew_flags }} |
Dustin Lam | c0f8f1a | 2020-10-30 09:59:40 -0700 | [diff] [blame] | 16 | steps: |
Dustin Lam | 860f8dd | 2021-04-12 16:45:58 -0700 | [diff] [blame] | 17 | - name: "Setup global constants" |
| 18 | id: global-constants |
Daz DeBoer | f59373c | 2022-01-28 15:46:31 +0000 | [diff] [blame] | 19 | # The configuration-cache cannot be used due to state excluded when caching Gradle User Home |
Dustin Lam | 860f8dd | 2021-04-12 16:45:58 -0700 | [diff] [blame] | 20 | run: | |
| 21 | set -x |
Yigit Boyar | 4adea49 | 2021-09-04 03:40:26 +0000 | [diff] [blame] | 22 | GRADLEW_FLAGS="-Dorg.gradle.internal.http.connectionTimeout=60000 \ |
Yigit Boyar | 9faf7fc | 2021-09-10 22:49:41 +0300 | [diff] [blame] | 23 | -Dorg.gradle.internal.http.socketTimeout=60000 \ |
| 24 | -Dorg.gradle.internal.repository.max.retries=20 \ |
| 25 | -Dorg.gradle.internal.repository.initial.backoff=500 \ |
Daz DeBoer | f59373c | 2022-01-28 15:46:31 +0000 | [diff] [blame] | 26 | --no-configuration-cache \ |
Dustin Lam | 860f8dd | 2021-04-12 16:45:58 -0700 | [diff] [blame] | 27 | --stacktrace" |
| 28 | echo "::set-output name=gradlew_flags::$GRADLEW_FLAGS" |
Daz DeBoer | f59373c | 2022-01-28 15:46:31 +0000 | [diff] [blame] | 29 | - name: Publish build scans link |
| 30 | # No scans are produced for PRs from forked repos, so omit this notice for forked PRs. |
| 31 | if: ${{ !(github.event.pull_request && github.event.pull_request.head.repo.fork) }} |
| 32 | run: echo "::notice title=All build scans for workflow::https://ge.androidx.dev/scans?search.names=CI%20run&search.values=$GITHUB_RUN_ID" |
Dustin Lam | c0f8f1a | 2020-10-30 09:59:40 -0700 | [diff] [blame] | 33 | |
| 34 | lint: |
| 35 | runs-on: ubuntu-latest |
Dustin Lam | 1c5a429 | 2021-01-06 18:35:17 +0000 | [diff] [blame] | 36 | needs: [setup] |
Dustin Lam | c0f8f1a | 2020-10-30 09:59:40 -0700 | [diff] [blame] | 37 | outputs: |
| 38 | status: ${{ steps.output-status.outputs.status }} |
Yigit Boyar | 2ca5170 | 2021-06-17 05:14:19 +0000 | [diff] [blame] | 39 | affectedFileArgs: ${{ steps.affected-file-args.outputs.files }} |
Daz DeBoer | f59373c | 2022-01-28 15:46:31 +0000 | [diff] [blame] | 40 | env: |
| 41 | GRADLE_BUILD_CACHE_PASSWORD: ${{ secrets.GRADLE_BUILD_CACHE_PASSWORD }} |
| 42 | GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} |
Dustin Lam | c0f8f1a | 2020-10-30 09:59:40 -0700 | [diff] [blame] | 43 | steps: |
| 44 | - name: Pull request format |
| 45 | uses: 'androidx/check-pr-format-action@main' |
| 46 | with: |
| 47 | # Enforces a `Test: <stanza>` in the pull request |
| 48 | checks: '["(.*)?Test:(.*)?"]' |
| 49 | |
Dustin Lam | 1c5a429 | 2021-01-06 18:35:17 +0000 | [diff] [blame] | 50 | - name: "Setup JDK 11" |
| 51 | id: setup-java |
| 52 | uses: actions/setup-java@v1 |
| 53 | with: |
| 54 | java-version: "11" |
| 55 | |
| 56 | - name: "Set environment variables" |
| 57 | shell: bash |
| 58 | run: | |
| 59 | set -x |
Dustin Lam | 1c5a429 | 2021-01-06 18:35:17 +0000 | [diff] [blame] | 60 | echo "DIST_DIR=$HOME/dist" >> $GITHUB_ENV |
| 61 | |
| 62 | - name: "Checkout androidx repo" |
| 63 | uses: actions/checkout@v2 |
Dustin Lam | 1c5a429 | 2021-01-06 18:35:17 +0000 | [diff] [blame] | 64 | |
| 65 | - name: "Get changed files in push or pull_request" |
| 66 | id: changed-files |
Dustin Lam | 522e2c1 | 2021-03-22 12:53:44 -0700 | [diff] [blame] | 67 | uses: androidx/changed-files-action@main |
Yigit Boyar | a986e04 | 2021-06-28 12:40:49 -0700 | [diff] [blame] | 68 | with: |
| 69 | github-token: ${{ secrets.GITHUB_TOKEN }} |
Dustin Lam | 1c5a429 | 2021-01-06 18:35:17 +0000 | [diff] [blame] | 70 | |
Dustin Lam | 1c5a429 | 2021-01-06 18:35:17 +0000 | [diff] [blame] | 71 | - name: "Warn on missing updateApi" |
| 72 | run: | |
| 73 | set -x |
Dustin Lam | 522e2c1 | 2021-03-22 12:53:44 -0700 | [diff] [blame] | 74 | ./development/apilint.py -f ${{ steps.changed-files.outputs.files }} |
Dustin Lam | 1c5a429 | 2021-01-06 18:35:17 +0000 | [diff] [blame] | 75 | |
| 76 | - name: "Parse changed-files as ktlint args" |
| 77 | id: ktlint-file-args |
| 78 | run: | |
| 79 | set -x |
Yigit Boyar | d5c8b4a | 2021-09-27 23:37:10 +0000 | [diff] [blame] | 80 | KTLINT_FILES=`echo "${{ steps.changed-files.outputs.files }}" | sed 's|[^ ]* *|--file=../&|g' | grep -v "*.txt"` |
Dustin Lam | 1c5a429 | 2021-01-06 18:35:17 +0000 | [diff] [blame] | 81 | echo "::set-output name=ktlint-file-args::$KTLINT_FILES" |
| 82 | |
Yigit Boyar | 2ca5170 | 2021-06-17 05:14:19 +0000 | [diff] [blame] | 83 | - name: "Parse changed-files as affected files args" |
| 84 | id: affected-file-args |
| 85 | run: | |
| 86 | set -x |
Dustin Lam | da5cefe | 2021-08-18 23:51:12 +0000 | [diff] [blame] | 87 | AFFECTED_FILES=`echo "${{ steps.changed-files.outputs.files_including_removals }}" | sed 's|\([^ ]\+\)|--changedFilePath=\1|g'` |
Yigit Boyar | 2ca5170 | 2021-06-17 05:14:19 +0000 | [diff] [blame] | 88 | echo "::set-output name=files::$AFFECTED_FILES" |
Daz DeBoer | f59373c | 2022-01-28 15:46:31 +0000 | [diff] [blame] | 89 | |
| 90 | - name: "Setup Gradle" |
| 91 | uses: gradle/gradle-build-action@v2 |
Yigit Boyar | 4adea49 | 2021-09-04 03:40:26 +0000 | [diff] [blame] | 92 | with: |
Daz DeBoer | f59373c | 2022-01-28 15:46:31 +0000 | [diff] [blame] | 93 | # Only save Gradle User Home state for builds on the 'androidx-main' branch. |
| 94 | # Builds on other branches will only read existing entries from the cache. |
| 95 | cache-read-only: ${{ github.ref != 'refs/heads/androidx-main' }} |
| 96 | |
| 97 | # Don't reuse cache entries from any other Job. |
| 98 | gradle-home-cache-strict-match: true |
| 99 | |
| 100 | # Limit the size of the cache entry. |
| 101 | # These directories contain instrumented/transformed dependency jars which can be reconstructed relatively quickly. |
| 102 | gradle-home-cache-excludes: | |
| 103 | caches/jars-9 |
| 104 | caches/transforms-3 |
| 105 | |
Dustin Lam | 1c5a429 | 2021-01-06 18:35:17 +0000 | [diff] [blame] | 106 | - name: "ktlint" |
Dustin Lam | 1c5a429 | 2021-01-06 18:35:17 +0000 | [diff] [blame] | 107 | env: |
| 108 | JAVA_HOME: ${{ steps.setup-java.outputs.path }} |
Daz DeBoer | f59373c | 2022-01-28 15:46:31 +0000 | [diff] [blame] | 109 | working-directory: activity |
| 110 | run: ./gradlew -q :ktlintCheckFile ${{ steps.ktlint-file-args.outputs.ktlint-file-args }} ${{ needs.setup.outputs.gradlew_flags }} |
| 111 | |
Yigit Boyar | 5a559f1 | 2021-06-01 00:27:32 +0200 | [diff] [blame] | 112 | build-modules: |
Dustin Lam | c93a99d | 2020-12-31 00:08:18 +0000 | [diff] [blame] | 113 | strategy: |
| 114 | fail-fast: false |
| 115 | matrix: |
| 116 | os: [ubuntu-latest] |
Alan Viverette | 63ba82e | 2022-04-25 11:24:03 -0400 | [diff] [blame] | 117 | # If you would like to remove some projects temporarily, use .github/ci-control/ci-config.json instead. |
| 118 | # Keep these in alphabetical order. |
Aurimas Liutikas | 1d8d1ef | 2022-04-25 13:53:11 -0700 | [diff] [blame] | 119 | project: ["activity", "appcompat", "biometric", "collection", "compose-runtime", "core", "datastore", "fragment", "lifecycle", "navigation", "paging", "room", "work"] |
Yigit Boyar | 5a559f1 | 2021-06-01 00:27:32 +0200 | [diff] [blame] | 120 | include: |
jimgoog | 51f8af3 | 2021-08-11 17:45:19 +0000 | [diff] [blame] | 121 | - project: "compose-runtime" |
| 122 | project-root: "compose/runtime" |
Yigit Boyar | 2abb89a | 2022-02-14 17:15:40 -0800 | [diff] [blame] | 123 | - project: "collection" |
| 124 | custom-os: "macos-latest" |
Yigit Boyar | 5a559f1 | 2021-06-01 00:27:32 +0200 | [diff] [blame] | 125 | runs-on: ${{ matrix.custom-os || matrix.os }} |
Dustin Lam | c93a99d | 2020-12-31 00:08:18 +0000 | [diff] [blame] | 126 | needs: [setup, lint] |
Dustin Lam | c93a99d | 2020-12-31 00:08:18 +0000 | [diff] [blame] | 127 | env: |
Yigit Boyar | 5a559f1 | 2021-06-01 00:27:32 +0200 | [diff] [blame] | 128 | artifact-id: ${{matrix.project}} |
| 129 | project-root: ${{matrix.project-root || matrix.project}} |
Dustin Lam | ad6ff38 | 2021-11-05 00:21:32 +0000 | [diff] [blame] | 130 | GRADLE_BUILD_CACHE_PASSWORD: ${{ secrets.GRADLE_BUILD_CACHE_PASSWORD }} |
| 131 | GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} |
Dustin Lam | c93a99d | 2020-12-31 00:08:18 +0000 | [diff] [blame] | 132 | steps: |
| 133 | - name: "Checkout androidx repo" |
| 134 | uses: actions/checkout@v2 |
Yigit Boyar | 7dcad2b | 2022-02-04 16:49:03 +0000 | [diff] [blame] | 135 | - name: "Check if the project should be built" |
| 136 | id: check-ci-config |
Yigit Boyar | 990e09d | 2022-05-03 17:04:17 +0000 | [diff] [blame] | 137 | env: |
| 138 | BRANCH_REF: ${{ github.head_ref || github.ref }} |
Yigit Boyar | 03528e6 | 2021-06-12 03:02:30 +0000 | [diff] [blame] | 139 | run: | |
| 140 | set -x |
Yigit Boyar | 990e09d | 2022-05-03 17:04:17 +0000 | [diff] [blame] | 141 | RESULT=`.github/ci-control/should_run_project.py --project ${{ matrix.project }} --branch "$BRANCH_REF"` |
Yigit Boyar | 7dcad2b | 2022-02-04 16:49:03 +0000 | [diff] [blame] | 142 | echo "::set-output name=enabled::$RESULT" |
| 143 | - name: "Run build" |
| 144 | uses: ./.github/actions/build-single-project |
| 145 | if: ${{ steps.check-ci-config.outputs.enabled == 'true' }} |
Dustin Lam | c93a99d | 2020-12-31 00:08:18 +0000 | [diff] [blame] | 146 | with: |
Yigit Boyar | 7dcad2b | 2022-02-04 16:49:03 +0000 | [diff] [blame] | 147 | project: ${{ matrix.project }} |
| 148 | project-root: ${{matrix.project-root || matrix.project }} |
| 149 | gradle-cache-password: ${{ secrets.GRADLE_BUILD_CACHE_PASSWORD }} |
| 150 | gradle-enterprise-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} |
| 151 | gradle-flags: ${{ needs.setup.outputs.gradlew_flags }} |
| 152 | # Upload artifacts task should be in the build-single-project |
| 153 | # action but they have a tendency to fail and continue-on-error |
| 154 | # is not supported there yet. |
| 155 | # https://github.com/actions/runner/issues/1457 |
Dustin Lam | c93a99d | 2020-12-31 00:08:18 +0000 | [diff] [blame] | 156 | - name: "Upload build artifacts" |
| 157 | continue-on-error: true |
Yigit Boyar | 7dcad2b | 2022-02-04 16:49:03 +0000 | [diff] [blame] | 158 | if: ${{ steps.check-ci-config.outputs.enabled == 'true' }} |
Dustin Lam | c93a99d | 2020-12-31 00:08:18 +0000 | [diff] [blame] | 159 | uses: actions/upload-artifact@v2 |
| 160 | with: |
Yigit Boyar | c8c8578 | 2022-03-22 12:54:46 -0700 | [diff] [blame] | 161 | name: artifacts_${{ matrix.project }} |
Dustin Lam | 7c04f76 | 2020-12-11 17:36:12 -0800 | [diff] [blame] | 162 | path: ~/dist |
Yigit Boyar | 5ec743d | 2021-12-07 16:29:53 +0000 | [diff] [blame] | 163 | - name: "Upload daemon logs" |
| 164 | continue-on-error: true |
| 165 | if: failure() |
| 166 | uses: actions/upload-artifact@v2 |
| 167 | with: |
Yigit Boyar | c8c8578 | 2022-03-22 12:54:46 -0700 | [diff] [blame] | 168 | name: gradle-daemon-logs_${{ matrix.project }} |
Yigit Boyar | 5ec743d | 2021-12-07 16:29:53 +0000 | [diff] [blame] | 169 | path: ~/.gradle/daemon |