-
Notifications
You must be signed in to change notification settings - Fork 127
134 lines (111 loc) · 4.25 KB
/
Copy pathtest.yml
File metadata and controls
134 lines (111 loc) · 4.25 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
name: Test
on:
push:
branches: [ master, main ]
tags: [ '[0-9]*' ]
pull_request:
branches: [ master, main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
submodules: recursive
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
# Robolectric SDK 36 (see app/src/test/resources/robolectric.properties)
# ships jars compiled with Java 21 and refuses to run on Java 17.
java-version: '21'
distribution: 'temurin'
- name: Install Android native build tools
run: |
"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" \
"cmake;3.22.1" \
"ndk;27.2.12479018"
- name: Cache cargo registry and build
uses: actions/cache@v6
with:
path: |
~/.cargo/registry
~/.cargo/git
wgbridge-rs/target
key: cargo-${{ runner.os }}-${{ hashFiles('wgbridge-rs/Cargo.lock') }}
- name: Set up Rust
run: ./scripts/setup_rust_android.sh
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
- name: Prefetch Gradle dependencies
run: |
./gradlew :app:dependencies
./gradlew :app:prefetchAndroidLintDependencies
# :app:dependencies only resolves dependency metadata, not the
# actual test-variant classpath artifacts (e.g. mockwebserver3).
# Compile the unit tests online once so their classpath is cached
# before the offline run below.
./gradlew :app:assembleFdroidDebugUnitTest
- name: Run Rust unit tests
run: cargo test --manifest-path wgbridge-rs/Cargo.toml --locked --offline
- name: Run unit tests
run: ./gradlew testFdroidDebugUnitTest --offline
- name: Build F-Droid release APK offline
run: ./gradlew :app:assembleFdroidRelease --offline
- name: Verify WireGuard libraries in F-Droid APK
run: |
APK=$(find app/build/outputs/apk/fdroid -type f -name '*.apk' -print -quit)
test -n "$APK"
for ABI in armeabi-v7a arm64-v8a x86 x86_64; do
test "$(unzip -Z1 "$APK" "lib/$ABI/libwgbridge.so")" = "lib/$ABI/libwgbridge.so"
done
instrumentation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
submodules: recursive
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
- name: Install Android native build tools
run: |
"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" \
"cmake;3.22.1" \
"ndk;27.2.12479018"
- name: Cache cargo registry and build
uses: actions/cache@v6
with:
path: |
~/.cargo/registry
~/.cargo/git
wgbridge-rs/target
key: cargo-android-${{ runner.os }}-${{ hashFiles('wgbridge-rs/Cargo.lock') }}
- name: Set up Rust
run: ./scripts/setup_rust_android.sh
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
- name: Prefetch Gradle dependencies
run: |
./gradlew :app:dependencies
# Warm the cache for the androidTest classpath (androidx.test.*).
# Running the tests themselves still needs network access: the
# Unified Test Platform runner classpath (UTP, dagger, protobuf,
# etc.) is only resolved once a device is actually connected.
./gradlew :app:assembleFdroidDebugAndroidTest
- name: Enable KVM
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: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@v2.38.0
with:
# API 37 has no published emulator system image yet; 36 is the
# newest one available while compileSdk/targetSdk track the preview.
api-level: 36
arch: x86_64
ndk: 27.2.12479018
profile: pixel_7
script: ./gradlew connectedFdroidDebugAndroidTest