Repository navigation
156 lines (137 loc) · 5.22 KB
/
Copy pathchatapp.yaml
File metadata and controls
156 lines (137 loc) · 5.22 KB
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
name: ChatApp
on:
push:
branches:
- main
paths:
- 'ChatApp/**'
- '.github/workflows/chatapp.yaml'
- '.github/ci-gradle.properties'
pull_request:
workflow_dispatch:
concurrency:
group: chatapp-${{ github.ref }}
cancel-in-progress: true
jobs:
changes:
name: "Check changes"
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
run_ci: ${{ steps.filter.outputs.run_ci }}
steps:
- name: Checkout
if: github.event_name == 'pull_request'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
- name: Check changed paths
id: filter
env:
EVENT_NAME: ${{ github.event_name }}
BASE_REF: ${{ github.base_ref }}
run: |
if [ "$EVENT_NAME" != "pull_request" ]; then
echo "run_ci=true" >> "$GITHUB_OUTPUT"
exit 0
fi
changed_files="$(git diff --no-renames --name-only "origin/$BASE_REF...HEAD")"
# git wraps paths with non-ASCII or special characters in double quotes.
if grep -qE '^"?(ChatApp/|\.github/workflows/chatapp\.yaml|\.github/ci-gradle\.properties)' <<< "$changed_files"; then
echo "run_ci=true" >> "$GITHUB_OUTPUT"
else
echo "run_ci=false" >> "$GITHUB_OUTPUT"
fi
chatapp-build:
name: "ChatApp spotless, tests & APKs"
needs: changes
if: needs.changes.outputs.run_ci == 'true'
runs-on: ubuntu-latest
timeout-minutes: 45
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
- name: Set up JDK 21
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6
with:
distribution: 'zulu'
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6
- name: Setup Android SDK
uses: android-actions/setup-android@be39fa834029ff78f1a44aa3bb0819b8fc2bd8fd # v4
- name: Run spotless
run: ./gradlew spotlessCheck
working-directory: ChatApp
- name: Run unit tests
run: ./gradlew test
working-directory: ChatApp
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Setup GMD
run: |
./gradlew :app:pixel7Api37Setup \
--info \
-Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true \
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect"
working-directory: ChatApp
- name: Run instrumentation tests
run: |
./gradlew :app:pixel7Api37Check \
-Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true \
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect"
working-directory: ChatApp
- name: Upload instrumentation test report
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
name: chatapp-androidtest-report
path: ChatApp/app/build/reports/androidTests/
- name: Build Debug and Release APKs
run: ./gradlew assembleDebug assembleRelease
working-directory: ChatApp
- name: Upload ChatApp APKs
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
name: chatapp-apks
path: |
ChatApp/app/build/outputs/apk/**/*.apk
ChatApp/wear/build/outputs/apk/**/*.apk
# Required status check in the rules-main ruleset, so keep its name in sync. GitHub counts a
# skipped required check as passing, so this job always runs and fails unless the build passed or
# was skipped because the change touches no ChatApp files.
chatapp-gate:
name: "ChatApp build & test"
needs: [changes, chatapp-build]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 5
permissions: {}
steps:
- name: Check build result
env:
CHANGES_RESULT: ${{ needs.changes.result }}
RUN_CI: ${{ needs.changes.outputs.run_ci }}
BUILD_RESULT: ${{ needs.chatapp-build.result }}
run: |
if [ "$CHANGES_RESULT" != "success" ]; then
echo "::error::Check changes finished with '$CHANGES_RESULT', so the ChatApp build was not verified."
exit 1
fi
if [ "$RUN_CI" = "false" ] && [ "$BUILD_RESULT" = "skipped" ]; then
echo "No ChatApp files changed, so the ChatApp build is not needed."
exit 0
fi
if [ "$BUILD_RESULT" != "success" ]; then
echo "::error::ChatApp spotless, tests & APKs finished with '$BUILD_RESULT'."
exit 1
fi
echo "ChatApp spotless, tests & APKs passed."