-
Notifications
You must be signed in to change notification settings - Fork 2
168 lines (144 loc) · 5.98 KB
/
ci.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
name: CI - Test Runner
# Run the workflow when commits are pushed on main or when a PR is modified
on:
push:
branches:
- main
- 'setup/**'
- 'feat/**'
- 'release/**'
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
ci:
name: CI
# Execute the CI on the course's runners
runs-on: ubuntu-latest
steps:
- uses: denoland/setup-deno@v2
# First step : Checkout the repository on the runner
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of Sonar analysis (if we use Sonar Later)
# Kernel-based Virtual Machine (KVM) is an open source virtualization technology built into Linux. Enabling it allows the Android emulator to run faster.
- 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 JDK
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
# Hello Hello, Alonso here ^_~
# For whatever reason Android SDK is weird and I can't get the emulator to work
# vvv this new plugin should install v12.0 that was published Sep 2024 to be updated
- name: Setup Android SDK
uses: Swisyn/setup-android-sdk@v1
with:
cmdline-tools-version: 11076708
##TODO: Check if I need to install adb and avdmanager manually with cli cmds
# Caching is a very useful part of a CI, as a workflow is executed in a clean environment every time,
# this means that one would need to re-download and re-process gradle files for every run. Which is very time consuming.
#
# To avoid that, we cache the the gradle folder to reuse it later.
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
# Cache the Emulator, if the cache does not hit, create the emulator
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-34
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
target: google_apis
arch: x86_64
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: echo "Generated AVD snapshot for caching."
- name: Grant execute permission for gradlew
run: |
chmod +x ./gradlew
- name: Setup secrets.properties
env:
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
SERVICE_KEY: ${{ secrets.SERVICE_KEY }}
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
POWERSYNC_URL: ${{ secrets.POWERSYNC_URL }}
STADIA_MAPS_KEY: ${{ secrets.STADIA_MAPS_KEY }}
STREAM_SDK_KEY: ${{ secrets.STREAM_SDK_KEY }}
STREAM_SDK_SECRET: ${{ secrets.STREAM_SDK_SECRET }}
run: |
sed -e "s|SAFE_DEFAULT_VALUE_SERVICE_KEY|$SERVICE_KEY|g;" \
-e "s|SAFE_DEFAULT_VALUE_SUPABASE_KEY|$SUPABASE_KEY|g;" \
-e "s|SAFE_DEFAULT_VALUE_SUPABASE_URL|$SUPABASE_URL|g;" \
-e "s|SAFE_DEFAULT_VALUE_POWERSYNC_URL|$POWERSYNC_URL|g;" \
-e "s|SAFE_DEFAULT_STADIA_MAPS_KEY|$STADIA_MAPS_KEY|g;" \
-e "s|SAFE_DEFAULT_VALUE_STREAM_SDK_KEY|$STREAM_SDK_KEY|g;" \
-e "s|SAFE_DEFAULT_VALUE_STREAM_SDK_SECRET|$STREAM_SDK_SECRET|g;" secrets.defaults.properties > secrets.properties
# Load google-services.json from the secrets
- name: Setup google-services.json
env:
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }}
run: |
echo "$GOOGLE_SERVICES" | base64 --decode > ./app/google-services.json
# Load service-account.json from the secrets
- name: Setup service-account.json
env:
SERVICE_ACCOUNT: ${{ secrets.SERVICE_ACCOUNT }}
run: |
echo "$SERVICE_ACCOUNT" | base64 --decode > ./supabase/functions/service-account.json
# Check formatting
- name: KTFmt Check
run: |
./gradlew ktfmtCheck
# This step runs gradle commands to build the application
- name: Assemble
run: |
# To run the CI with debug information, add --info
./gradlew assemble lint --parallel --build-cache
# Run Unit tests
- name: Run unit tests
run: |
# To run the CI with debug information, add --info
./gradlew check --parallel --build-cache
# Run connected tests on the emulator
- name: Run connected tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
target: google_apis
arch: x86_64
avd-name: github
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -skin 1080x1920
disable-animations: true
script: ./gradlew connectedCheck --parallel --build-cache
# Run Deno tests
- name: Run Deno tests
run: |
deno test --allow-net --allow-read supabase/tests/*.test.ts
# This step generates the coverage report which will be uploaded to sonar
- name: Generate Coverage Report
run: |
./gradlew jacocoTestReport
# Upload the various reports to sonar
- name: SonarCloud
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew build sonar --parallel --build-cache --info