ci, emulator: use actions/checkout
to install V and examples in one…
#493
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Emulator Run CI | |
on: | |
push: | |
paths-ignore: | |
- "**.md" | |
pull_request: | |
paths-ignore: | |
- "**.md" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.sha || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
macos-legacy-run-v-examples: | |
runs-on: macos-12 | |
timeout-minutes: 45 | |
env: | |
VAB_FLAGS: -cg -f '-d no_load_styles' -v 3 --api 30 --build-tools 33.0.2 --device auto --log-clear --archs x86_64 | |
VFLAGS: -no-parallel | |
steps: | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: 'adopt' | |
java-version: 8 | |
- name: Checkout V | |
uses: actions/checkout@v4 | |
with: | |
repository: vlang/v | |
path: v | |
- name: Build and install v | |
run: cd ./v && make -j4 && sudo ./v symlink | |
- name: Checkout vab | |
uses: actions/checkout@v4 | |
with: | |
path: vab | |
- name: Simulate "v install vab" | |
run: mv vab ~/.vmodules | |
- name: Build vab with -prod | |
run: v -prod ~/.vmodules/vab | |
- name: Build vab | |
run: v -g ~/.vmodules/vab | |
- name: Symlink vab | |
run: sudo ln -s ~/.vmodules/vab/vab /usr/local/bin/vab | |
- name: Run vab --help | |
run: vab --help | |
- name: Install build-tools 33.0.2 | |
run: | | |
vab install "build-tools;33.0.2" | |
- name: Install platform android-30 | |
run: | | |
vab install "platforms;android-30" | |
- name: Install AAB dependencies | |
run: | | |
vab install bundletool | |
vab install aapt2 | |
- name: Run vab doctor | |
run: vab doctor | |
- name: Cache emulator | |
id: cache-emulator | |
uses: actions/cache@v4 | |
with: | |
path: | | |
/Users/runner/.android/avd | |
/Users/runner/Library/Android/sdk/system-images/android-30 | |
key: ${{ runner.os }}-android-emulator-${{ hashFiles('/Users/runner/.android/avd') }} | |
- name: Prepare emulator | |
if: steps.cache-emulator.outputs.cache-hit != 'true' | |
run: | | |
export ANDROID_SDK_ROOT="$HOME/Library/Android/sdk" | |
echo yes | $ANDROID_SDK_ROOT/tools/bin/sdkmanager 'system-images;android-30;google_apis;x86_64' | |
echo no | $ANDROID_SDK_ROOT/tools/bin/avdmanager create avd --force --name test --abi google_apis/x86_64 --package 'system-images;android-30;google_apis;x86_64' | |
- name: Install and run V + V UI examples as APK and AAB | |
run: | | |
export ANDROID_SDK_ROOT="$HOME/Library/Android/sdk" | |
export ANDROID_NDK_ROOT="$ANDROID_SDK_ROOT/ndk-bundle" | |
# Don't set Java > 8 here (emulator can't be started otherwise, lol) #export JAVA_HOME=$JAVA_HOME_11_X64 | |
#pgrep emulator >/dev/null 2>&1 || | |
$ANDROID_SDK_ROOT/emulator/emulator -avd test -wipe-data -no-metrics -no-snapshot -no-window -no-boot-anim -camera-back emulated -camera-front emulated -gpu swiftshader_indirect & | |
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;' | |
# Debugging | |
#export ADB_TAGS="SOKOL_APP:D" | |
#export ADB_TAGS="$ADB_TAGS V_ANDROID:D v_test_app:D" | |
# Test deployment of single file *after* build | |
echo "Testing vab deployment *after* build" | |
vab --package-id "io.v.ci.vab.apk.deploytest" --name "V DEPLOY TEST APK" v/examples/gg/bezier.v && vab v_deploy_test_apk.apk | |
vab --package-id "io.v.ci.vab.aab.deploytest" --name "V DEPLOY TEST AAB" --package aab v/examples/gg/bezier.v && vab v_deploy_test_aab.aab | |
# 'flappylearning' can build but running is currently broken on Android | |
# Skip fireworks for now | |
declare -a v_examples=('2048' 'tetris' 'sokol/particles' 'sokol/drawing.v' 'sokol/freetype_raven.v' 'gg/bezier.v' 'gg/bezier_anim.v' 'gg/polygons.v' 'gg/raven_text_rendering.v' 'gg/rectangles.v' 'gg/stars.v' 'gg/worker_thread.v') | |
echo "Compiling V examples ${v_examples[@]}" | |
for example in "${v_examples[@]}"; do | |
#path_safe_name=$( echo "$example" | sed 's%/%-%' | sed 's%\.%-%' ) | |
package_id=$( echo "$example" | sed 's%/%%' | sed 's%\.%%' ) | |
package_id=$( echo "v$package_id" ) | |
# APK | |
echo "Compiling apk from examples/$example ($package_id)" | |
vab --package-id "io.v.apk.$package_id" run v/examples/$example | |
# AAB | |
echo "Compiling aab from examples/$example ($package_id)" | |
vab --package aab --package-id "io.v.aab.$package_id" run v/examples/$example | |
done | |
# Output test | |
echo "Testing if v/examples/tetris can run..." | |
vab -g --package-id "io.v.ci.vab.apk.examples.tetris" run v/examples/tetris | |
sleep 5 | |
adb -e logcat -d > /tmp/logcat.dump.txt | |
echo "Looking for traces of BDWGC" | |
cat /tmp/logcat.dump.txt | grep -q 'BDWGC : Grow'; if [ ! $? -eq 0 ]; then cat /tmp/logcat.dump.txt; fi | |
# V UI | |
echo "Installing V UI" | |
git clone --depth 1 https://github.com/vlang/ui | |
cd ui ; mkdir -p ~/.vmodules ; ln -s $(pwd) ~/.vmodules/ui ; cd .. | |
declare -a v_ui_examples=('rectangles.v') | |
echo "Compiling examples ${v_ui_examples[@]}" | |
for example in "${v_ui_examples[@]}"; do | |
package_id=$( echo "$example" | sed 's%/%%' | sed 's%\.%%' ) | |
package_id=$( echo "v$package_id" ) | |
# APK | |
echo "Compiling apk from ui/examples/$example ($package_id)" | |
vab --package-id "io.v.apk.ui.$package_id" run ui/examples/$example | |
# AAB | |
echo "Compiling aab from ui/examples/$example ($package_id)" | |
vab --package aab --package-id "io.v.aab.ui.$package_id" run ui/examples/$example | |
done | |
# Output test | |
echo "Testing if ui/examples/calculator can run..." | |
vab -g --package-id "io.v.ui.ci.examples.calculator" run ui/examples/calculator.v | |
sleep 5 | |
adb -e logcat -d > /tmp/logcat.dump.txt | |
echo "Looking for traces of BDWGC" | |
cat /tmp/logcat.dump.txt | grep -q 'BDWGC : Grow'; if [ ! $? -eq 0 ]; then cat /tmp/logcat.dump.txt; fi | |
echo "Killing emulator" | |
adb -s emulator-5554 emu kill |