forked from androidx/androidx
-
Notifications
You must be signed in to change notification settings - Fork 0
174 lines (159 loc) · 7.09 KB
/
presubmit.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
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 "::set-output name=gradlew_flags::$GRADLEW_FLAGS"
- 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"
id: setup-java
uses: actions/setup-java@v1
with:
java-version: "17"
- name: "Set environment variables"
shell: bash
run: |
set -x
echo "DIST_DIR=$HOME/dist" >> $GITHUB_ENV
- name: "Checkout androidx repo"
uses: actions/checkout@v2
- 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 ktlint args"
id: ktlint-file-args
run: |
set -x
KTLINT_FILES=`echo "${{ steps.changed-files.outputs.files }}" | sed 's|[^ ]* *|--file=../&|g' | grep -v "*.txt"`
echo "::set-output name=ktlint-file-args::$KTLINT_FILES"
- 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 "::set-output name=files::$AFFECTED_FILES"
- 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: "ktlint"
env:
JAVA_HOME: ${{ steps.setup-java.outputs.path }}
working-directory: playground-projects/ktlint-playground
run: ./gradlew -q :ktlintCheckFile ${{ steps.ktlint-file-args.outputs.ktlint-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", "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@v2
- 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 "::set-output name=enabled::$RESULT"
- 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@v2
with:
name: artifacts_${{ matrix.project }}
path: ~/dist
- name: "Upload daemon logs"
continue-on-error: true
if: failure()
uses: actions/upload-artifact@v2
with:
name: gradle-daemon-logs_${{ matrix.project }}
path: ~/.gradle/daemon