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
name: Android Test
on:
workflow_dispatch:
pull_request:
push:
tags:
- "v*.*.*"
branches:
- master
- develop
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
android-build:
name: Android NDK Build
runs-on: ubuntu-latest
# TODO: Add more architectures
strategy:
fail-fast: false
matrix:
abi:
api-level:
build:
# TODO: This may be removed
target:
env:
ANDROID_NDK_VERSION: "26.1.10909125"
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Install Android NDK
run: |
sdkmanager --install "ndk;${{ env.ANDROID_NDK_VERSION }}"
echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/${{ env.ANDROID_NDK_VERSION }}" >> $GITHUB_ENV
echo "ANDROID_NDK=$ANDROID_HOME/ndk/${{ env.ANDROID_NDK_VERSION }}" >> $GITHUB_ENV
- name: Install dependencies
run: ./tools/metacall-environment.sh ${{ matrix.build }} base android
- name: Create build directory
run: mkdir -p build
- name: Configure CMake for Android
working-directory: ./build
env:
ANDROID_API_LEVEL: ${{ matrix.api-level }}
ANDROID_ABI: ${{ matrix.abi }}
run: ../tools/metacall-configure.sh ${{ matrix.build }} base android scripts tests
- name: Build
working-directory: ./build
run: ../tools/metacall-build.sh ${{ matrix.build }} tests
# - name: Upload build artifacts
# uses: actions/upload-artifact@v4
# with:
# name: android-build-${{ matrix.abi }}-api${{ matrix.api-level }}-${{ matrix.build }}
# path: ./build
# android-emulator-test:
# name: Android Emulator Test
# needs: android-build
# runs-on: ubuntu-latest
# # TODO: Add more architectures
# strategy:
# fail-fast: false
# matrix:
# api-level: [30]
# target: [google_apis]
# arch: [x86_64]
# build: [release]
# steps:
# - name: Check out the repository
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
- 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: Download build artifacts
# uses: actions/download-artifact@v4
# with:
# name: android-build-${{ matrix.abi }}-api${{ matrix.api-level }}-${{ matrix.build }}
# path: build
# - name: Set up JDK 17
# uses: actions/setup-java@v4
# with:
# java-version: '17'
# distribution: 'temurin'
# - name: Setup Android SDK
# uses: android-actions/setup-android@v3
# - name: Install Android NDK for libc++_shared.so
# run: |
# sdkmanager --install "ndk;26.1.10909125"
# echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/26.1.10909125" >> $GITHUB_ENV
- name: Run tests on Android Emulator
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: ${{ matrix.arch }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: |
echo "=== Pushing test files to emulator ==="
adb push build/ /data/local/tmp/metacall/
echo ""
echo "=== Files on emulator ==="
adb shell "ls -la /data/local/tmp/metacall/"
echo "TODO: Run CTest with emulator"