all: run vfmt over project (#286) #414
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: emulator-${{ github.event.pull_request.number || github.sha }} | |
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 29.0.0 --device auto --log-clear --archs x86_64 | |
VFLAGS: -no-parallel | |
steps: | |
- uses: actions/setup-java@v2 | |
with: | |
distribution: 'adopt' | |
java-version: 8 | |
- name: Install V | |
uses: vlang/setup-v@v1 | |
with: | |
check-latest: true | |
- name: Checkout vab | |
uses: actions/checkout@v2 | |
with: | |
path: vab | |
- name: Simulate "v install vab" | |
run: mv vab ~/.vmodules | |
- name: Run tests | |
run: v test ~/.vmodules/vab | |
- 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 29 | |
run: | | |
vab install "build-tools;29.0.0" | |
- 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@v2 | |
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 -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;' | |
# Remove packages here if cache is run, and emulator failed | |
# Debugging | |
#export ADB_TAGS="SOKOL_APP:D" | |
#export ADB_TAGS="$ADB_TAGS V_ANDROID:D v_test_app:D" | |
echo "Installing V examples" | |
git clone --depth 1 https://github.com/vlang/v | |
# Test deployment of single file *after* build | |
vab --name "V DEPLOY TEST APK" v/examples/gg/bezier.v && vab v_deploy_test_apk.apk | |
vab --package aab --name "V DEPLOY TEST 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 | |
# Remove app in case cache is run | |
adb uninstall "io.v.apk.$package_id" | |
adb uninstall "io.v.aab.$package_id" | |
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 | |
# Remove app in case cache is run | |
echo "Uninstalling v/examples/tetris" | |
adb uninstall io.v.ci.vab.apk.examples.tetris | |
# 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 | |
# Remove app in case cache is run | |
adb uninstall "io.v.apk.ui.$package_id" | |
adb uninstall "io.v.aab.ui.$package_id" | |
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 | |
# Remove app in case cache is run | |
echo "Uninstalling ui/examples/calculator" | |
adb uninstall io.v.ui.ci.examples.calculator | |
echo "Killing emulator" | |
adb -s emulator-5554 emu kill |