forked from androidx/androidx
-
Notifications
You must be signed in to change notification settings - Fork 0
190 lines (172 loc) · 6.57 KB
/
jbpresubmit.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# This workflow is intended to be used by JB-compose team in https://github.com/JetBrains/androidx
# which is a fork of androidx repo.
# By having this file in the AndroidX upstream we (JB-compose team) avoid the need to
# rebase/cherry-pick the workflow file for every CL we want to submit upstream.
# The aim of this workflow is to run checks and some tests before submitting the CL upstream.
name: JB-COMPOSE-variant of AndroidX Presubmits
on:
push:
branches:
- jb_cl*
- jb_presubmit*
pull_request:
branches:
- jb-main
- jb_presubmit*
- jb_cl*
types:
- opened
- reopened
- synchronize
# Allows to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
setup:
runs-on: ubuntu-latest
outputs:
gradlew_flags: ${{ steps.global-constants.outputs.gradlew_flags }}
checkout_ref: ${{ steps.checkout-args.outputs.ref }}
checkout_repo: ${{ steps.checkout-args.outputs.repository }}
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 \
-Dorg.gradle.jvmargs=-XX:MaxMetaspaceSize=512m \
--stacktrace"
echo "gradlew_flags=GRADLEW_FLAGS" >> $GITHUB_OUTPUT
- name: "Compute actions/checkout arguments"
id: checkout-args
env:
REF: ${{ github.event.pull_request.head.ref || github.event.ref}}
run: |
set -x
echo "ref=$REF" >> $GITHUB_OUTPUT
REPOSITORY=${{ github.event.pull_request.head.repo.full_name }}
if [ -z "$REPOSITORY" ]; then
REPOSITORY=${{ github.repository }}
fi
echo "repository=$REPOSITORY" >> $GITHUB_OUTPUT
lint:
runs-on: ubuntu-latest
needs: [setup]
outputs:
status: ${{ steps.output-status.outputs.status }}
affectedFileArgs: ${{ steps.affected-file-args.outputs.files }}
java: ${{ steps.setup-java.outputs.path }}
steps:
- name: Pull request format
if: ${{ false }} #
uses: 'androidx/check-pr-format-action@main'
with:
# Enforces a `Test: <stanza>` in the pull request
checks: '["(.*)?Test:(.*)?"]'
- name: "Setup JDK 11"
id: setup-java
uses: actions/setup-java@v1
with:
java-version: "11"
- name: "Set environment variables"
shell: bash
run: |
set -x
echo "ANDROID_SDK_ROOT=$HOME/Library/Android/sdk" >> $GITHUB_ENV
echo "DIST_DIR=$HOME/dist" >> $GITHUB_ENV
- name: "Checkout androidx repo"
uses: actions/checkout@v4
with:
ref: ${{ needs.setup.outputs.checkout_ref }}
repository: ${{ needs.setup.outputs.checkout_repo }}
fetch-depth: 1
- 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"
env:
ENABLE_UPDATEAPI_WARNING: ${{ true }}
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: "warm up gradle"
id: warm-up-gradle-cache
uses: gradle/gradle-command-action@v1
env:
JAVA_HOME: ${{ steps.setup-java.outputs.path }}
with:
arguments: tasks -PandroidXUnusedParameter=compose-jb # add project name to cache key
build-root-directory: activity
configuration-cache-enabled: true
dependencies-cache-enabled: true
dependencies-cache-key: |
**/libs.versions.toml
dependencies-cache-exact: false
gradle-executable: activity/gradlew
wrapper-directory: activity/gradle/wrapper
distributions-cache-enabled: true
- name: "ktfmt"
uses: gradle/gradle-command-action@v1
env:
JAVA_HOME: ${{ steps.setup-java.outputs.path }}
with:
arguments: -q :ktCheckFile ${{ steps.ktfmt-file-args.outputs.ktfmt-file-args }} ${{ needs.setup.outputs.gradlew_flags }}
build-root-directory: activity
configuration-cache-enabled: false
dependencies-cache-enabled: false
gradle-executable: activity/gradlew
wrapper-directory: activity/gradle/wrapper
distributions-cache-enabled: false
tests:
runs-on: ubuntu-latest
needs: [ setup, lint ]
steps:
- name: "Setup JDK 11"
id: setup-java
uses: actions/setup-java@v1
with:
java-version: "11"
- name: "checkout dependencies"
shell: bash
# checkout compose-jb repo containing scripts for running tests.
# note: this step also downloads Android sdk because we don't do full `repo sync` but
# install/checkout only what's needed for testing scripts.
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
GITHUB_SHA=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.head.sha)
fi
git clone -n https://github.com/JetBrains/compose-jb
cd compose-jb
git checkout origin/master
git submodule update --init --recursive
pushd compose/frameworks/support
git fetch
git checkout $GITHUB_SHA
git log -1 --oneline
popd
./compose/scripts/downloadAndroidSdk
- name: "run tests"
shell: bash
env:
JAVA_HOME: ${{ steps.setup-java.outputs.path }}
run: |
cd compose-jb
unset ANDROID_SDK_HOME
export ANDROID_HOME=$PWD/compose/prebuilts/fullsdk-linux
./compose/scripts/testComposeModules