-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathaction.yml
More file actions
112 lines (102 loc) · 4.23 KB
/
action.yml
File metadata and controls
112 lines (102 loc) · 4.23 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
name: 'CI VM'
description: 'Run main CI steps in VMs for VM-only platforms.'
inputs:
target:
description: 'Rust target to build for.'
required: true
working-directory:
description: 'Working directory.'
default: '.'
ndk-version:
description: 'NDK version to install.'
# https://searchfox.org/mozilla-central/search?q=NDK_VERSION =&path=python/mozboot/mozboot/android.py
default: '27.2.12479018'
api-level:
description: 'Android API level to use.'
# https://searchfox.org/mozilla-central/search?q=\bapi_level=&path=taskcluster/scripts/misc/build-llvm-common.sh®exp=true
# However, NSS requires an API >= 23 for a few symbols.
default: '23'
minimum-nss-version:
description: 'If NSS is required, the minimum version required.'
default: ''
codecov-token:
description: 'Codecov token, if Codecov upload is desired.'
default: ''
github-token:
description: 'A Github PAT'
required: true
runs:
using: composite
steps:
- uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
with:
distribution: zulu
java-version: 23
- uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2
with:
accept-android-sdk-licenses: true
log-accepted-android-sdk-licenses: false
- shell: bash
env:
NDK_VERSION: ${{ inputs.ndk-version }}
WD: ${{ inputs.working-directory }}
run: cd "$WD" && sdkmanager --install "ndk;$NDK_VERSION"
- uses: ./.github/actions/rust
with:
version: stable
targets: ${{ inputs.target }}
tools: cargo-ndk@^4
token: ${{ inputs.github-token }}
- uses: ./.github/actions/nss
if: ${{ inputs.minimum-nss-version != '' }}
with:
minimum-version: ${{ inputs.minimum-nss-version }}
target: ${{ inputs.target }}
- shell: bash
env:
TARGET: ${{ startsWith(inputs.target, 'arm') && 'arm64-v8a' || inputs.target }}
API_LEVEL: ${{ inputs.api-level }}
WD: ${{ inputs.working-directory }}
run: cd "$WD" && cargo ndk --platform "$API_LEVEL" --target "$TARGET" test --no-run
- shell: bash
env:
TARGET: ${{ inputs.target }}
API_LEVEL: ${{ inputs.api-level }}
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
cat <<'EOF' > /tmp/rust-android-run-tests-on-emulator.sh
#!/bin/bash
set -ex
adb wait-for-device
while [ -z "$(adb shell getprop sys.boot_completed | tr -d '\r')" ]; do sleep 1; done
any_failures=0
TMP=/data/local/tmp
[ -e "$WD/test-fixture/db" ] && adb push "test-fixture/db" "$TMP/"
[ "$LD_LIBRARY_PATH" ] && adb push "$LD_LIBRARY_PATH" "$TMP/"
for test in $(find $WD/target/$TARGET/debug/deps/ -type f -executable ! -name "*.so" -name "*-*"); do
adb push "$test" "$TMP/"
adb shell chmod +x "$TMP/$(basename "$test")"
# See https://unix.stackexchange.com/a/451140/409256
adb shell "CARGO_TERM_COLOR=always RUST_BACKTRACE=1 LD_LIBRARY_PATH=$TMP/lib NSS_DB_PATH=$TMP/db API_LEVEL=$API_LEVEL $TMP/$(basename "$test") || echo _FAIL_" 2>&1 | tee output
grep _FAIL_ output > /dev/null && any_failures=1
done
exit $any_failures
EOF
chmod a+x /tmp/rust-android-run-tests-on-emulator.sh
- uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # v2.34.0
with:
api-level: ${{ inputs.api-level }}
arch: ${{ startsWith(inputs.target, 'x86_64') && 'x86_64' || (startsWith(inputs.target, 'i686') && 'x86' || (startsWith(inputs.target, 'aarch64') && 'arm64-v8a')) }}
ndk: ${{ inputs.ndk-version }}
emulator-boot-timeout: 120
disk-size: 2G
script: /tmp/rust-android-run-tests-on-emulator.sh
- if: ${{ inputs.codecov-token != '' }}
uses: codecov/codecov-action@fdcc8476540edceab3de004e990f80d881c6cc00 # v5.5.0
with:
files: lcov.info
fail_ci_if_error: false
token: ${{ inputs.codecov-token }}
verbose: true