[go: nahoru, domu]

blob: 40ba42ad0778ee10819090579d338b9f55b7f3a9 [file] [log] [blame]
Rahul Ravikumar383c25a2020-05-27 12:11:02 -07001name: AndroidX Presubmits
Rahul Ravikumarc170c562020-06-26 12:20:03 -07002on:
Rahul Ravikumar5cbb2b52020-08-04 09:37:35 -07003 push:
Yigit Boyar092314ea2021-06-17 17:21:40 -07004 pull_request:
Rahul Ravikumar383c25a2020-05-27 12:11:02 -07005
Daz DeBoerf59373c2022-01-28 15:46:31 +00006env:
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 Boyarf1044522022-06-23 08:27:01 -070010 GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: "2022.07.23"
Rahul Ravikumar383c25a2020-05-27 12:11:02 -070011jobs:
Dustin Lamc0f8f1a2020-10-30 09:59:40 -070012 setup:
13 runs-on: ubuntu-latest
Dustin Lam860f8dd2021-04-12 16:45:58 -070014 outputs:
15 gradlew_flags: ${{ steps.global-constants.outputs.gradlew_flags }}
Dustin Lamc0f8f1a2020-10-30 09:59:40 -070016 steps:
Dustin Lam860f8dd2021-04-12 16:45:58 -070017 - name: "Setup global constants"
18 id: global-constants
Daz DeBoerf59373c2022-01-28 15:46:31 +000019 # The configuration-cache cannot be used due to state excluded when caching Gradle User Home
Dustin Lam860f8dd2021-04-12 16:45:58 -070020 run: |
21 set -x
Yigit Boyar4adea492021-09-04 03:40:26 +000022 GRADLEW_FLAGS="-Dorg.gradle.internal.http.connectionTimeout=60000 \
Yigit Boyar9faf7fc2021-09-10 22:49:41 +030023 -Dorg.gradle.internal.http.socketTimeout=60000 \
24 -Dorg.gradle.internal.repository.max.retries=20 \
25 -Dorg.gradle.internal.repository.initial.backoff=500 \
Daz DeBoerf59373c2022-01-28 15:46:31 +000026 --no-configuration-cache \
Dustin Lam860f8dd2021-04-12 16:45:58 -070027 --stacktrace"
28 echo "::set-output name=gradlew_flags::$GRADLEW_FLAGS"
Daz DeBoerf59373c2022-01-28 15:46:31 +000029 - 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 Lamc0f8f1a2020-10-30 09:59:40 -070033
34 lint:
35 runs-on: ubuntu-latest
Dustin Lam1c5a4292021-01-06 18:35:17 +000036 needs: [setup]
Dustin Lamc0f8f1a2020-10-30 09:59:40 -070037 outputs:
38 status: ${{ steps.output-status.outputs.status }}
Yigit Boyar2ca51702021-06-17 05:14:19 +000039 affectedFileArgs: ${{ steps.affected-file-args.outputs.files }}
Daz DeBoerf59373c2022-01-28 15:46:31 +000040 env:
41 GRADLE_BUILD_CACHE_PASSWORD: ${{ secrets.GRADLE_BUILD_CACHE_PASSWORD }}
42 GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
Dustin Lamc0f8f1a2020-10-30 09:59:40 -070043 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 Lam1c5a4292021-01-06 18:35:17 +000050 - 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 Lam1c5a4292021-01-06 18:35:17 +000060 echo "DIST_DIR=$HOME/dist" >> $GITHUB_ENV
61
62 - name: "Checkout androidx repo"
63 uses: actions/checkout@v2
Dustin Lam1c5a4292021-01-06 18:35:17 +000064
65 - name: "Get changed files in push or pull_request"
66 id: changed-files
Dustin Lam522e2c12021-03-22 12:53:44 -070067 uses: androidx/changed-files-action@main
Yigit Boyara986e042021-06-28 12:40:49 -070068 with:
69 github-token: ${{ secrets.GITHUB_TOKEN }}
Dustin Lam1c5a4292021-01-06 18:35:17 +000070
Dustin Lam1c5a4292021-01-06 18:35:17 +000071 - name: "Warn on missing updateApi"
72 run: |
73 set -x
Dustin Lam522e2c12021-03-22 12:53:44 -070074 ./development/apilint.py -f ${{ steps.changed-files.outputs.files }}
Dustin Lam1c5a4292021-01-06 18:35:17 +000075
76 - name: "Parse changed-files as ktlint args"
77 id: ktlint-file-args
78 run: |
79 set -x
Yigit Boyard5c8b4a2021-09-27 23:37:10 +000080 KTLINT_FILES=`echo "${{ steps.changed-files.outputs.files }}" | sed 's|[^ ]* *|--file=../&|g' | grep -v "*.txt"`
Dustin Lam1c5a4292021-01-06 18:35:17 +000081 echo "::set-output name=ktlint-file-args::$KTLINT_FILES"
82
Yigit Boyar2ca51702021-06-17 05:14:19 +000083 - name: "Parse changed-files as affected files args"
84 id: affected-file-args
85 run: |
86 set -x
Dustin Lamda5cefe2021-08-18 23:51:12 +000087 AFFECTED_FILES=`echo "${{ steps.changed-files.outputs.files_including_removals }}" | sed 's|\([^ ]\+\)|--changedFilePath=\1|g'`
Yigit Boyar2ca51702021-06-17 05:14:19 +000088 echo "::set-output name=files::$AFFECTED_FILES"
Daz DeBoerf59373c2022-01-28 15:46:31 +000089
90 - name: "Setup Gradle"
91 uses: gradle/gradle-build-action@v2
Yigit Boyar4adea492021-09-04 03:40:26 +000092 with:
Daz DeBoerf59373c2022-01-28 15:46:31 +000093 # 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 Lam1c5a4292021-01-06 18:35:17 +0000106 - name: "ktlint"
Dustin Lam1c5a4292021-01-06 18:35:17 +0000107 env:
108 JAVA_HOME: ${{ steps.setup-java.outputs.path }}
Daz DeBoerf59373c2022-01-28 15:46:31 +0000109 working-directory: activity
110 run: ./gradlew -q :ktlintCheckFile ${{ steps.ktlint-file-args.outputs.ktlint-file-args }} ${{ needs.setup.outputs.gradlew_flags }}
111
Yigit Boyar5a559f12021-06-01 00:27:32 +0200112 build-modules:
Dustin Lamc93a99d2020-12-31 00:08:18 +0000113 strategy:
114 fail-fast: false
115 matrix:
116 os: [ubuntu-latest]
Alan Viverette63ba82e2022-04-25 11:24:03 -0400117 # If you would like to remove some projects temporarily, use .github/ci-control/ci-config.json instead.
118 # Keep these in alphabetical order.
Aurimas Liutikas1d8d1ef2022-04-25 13:53:11 -0700119 project: ["activity", "appcompat", "biometric", "collection", "compose-runtime", "core", "datastore", "fragment", "lifecycle", "navigation", "paging", "room", "work"]
Yigit Boyar5a559f12021-06-01 00:27:32 +0200120 include:
jimgoog51f8af32021-08-11 17:45:19 +0000121 - project: "compose-runtime"
122 project-root: "compose/runtime"
Yigit Boyar2abb89a2022-02-14 17:15:40 -0800123 - project: "collection"
124 custom-os: "macos-latest"
Yigit Boyar5a559f12021-06-01 00:27:32 +0200125 runs-on: ${{ matrix.custom-os || matrix.os }}
Dustin Lamc93a99d2020-12-31 00:08:18 +0000126 needs: [setup, lint]
Dustin Lamc93a99d2020-12-31 00:08:18 +0000127 env:
Yigit Boyar5a559f12021-06-01 00:27:32 +0200128 artifact-id: ${{matrix.project}}
129 project-root: ${{matrix.project-root || matrix.project}}
Dustin Lamad6ff382021-11-05 00:21:32 +0000130 GRADLE_BUILD_CACHE_PASSWORD: ${{ secrets.GRADLE_BUILD_CACHE_PASSWORD }}
131 GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
Dustin Lamc93a99d2020-12-31 00:08:18 +0000132 steps:
133 - name: "Checkout androidx repo"
134 uses: actions/checkout@v2
Yigit Boyar7dcad2b2022-02-04 16:49:03 +0000135 - name: "Check if the project should be built"
136 id: check-ci-config
Yigit Boyar990e09d2022-05-03 17:04:17 +0000137 env:
138 BRANCH_REF: ${{ github.head_ref || github.ref }}
Yigit Boyar03528e62021-06-12 03:02:30 +0000139 run: |
140 set -x
Yigit Boyar990e09d2022-05-03 17:04:17 +0000141 RESULT=`.github/ci-control/should_run_project.py --project ${{ matrix.project }} --branch "$BRANCH_REF"`
Yigit Boyar7dcad2b2022-02-04 16:49:03 +0000142 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 Lamc93a99d2020-12-31 00:08:18 +0000146 with:
Yigit Boyar7dcad2b2022-02-04 16:49:03 +0000147 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 Lamc93a99d2020-12-31 00:08:18 +0000156 - name: "Upload build artifacts"
157 continue-on-error: true
Yigit Boyar7dcad2b2022-02-04 16:49:03 +0000158 if: ${{ steps.check-ci-config.outputs.enabled == 'true' }}
Dustin Lamc93a99d2020-12-31 00:08:18 +0000159 uses: actions/upload-artifact@v2
160 with:
Yigit Boyarc8c85782022-03-22 12:54:46 -0700161 name: artifacts_${{ matrix.project }}
Dustin Lam7c04f762020-12-11 17:36:12 -0800162 path: ~/dist
Yigit Boyar5ec743d2021-12-07 16:29:53 +0000163 - name: "Upload daemon logs"
164 continue-on-error: true
165 if: failure()
166 uses: actions/upload-artifact@v2
167 with:
Yigit Boyarc8c85782022-03-22 12:54:46 -0700168 name: gradle-daemon-logs_${{ matrix.project }}
Yigit Boyar5ec743d2021-12-07 16:29:53 +0000169 path: ~/.gradle/daemon