Skip to content

Commit

Permalink
env, ci: add support for linux emulator runs, add new emulator modu…
Browse files Browse the repository at this point in the history
…le (vlang#315)

* android: add `emulator` module

* ci: add `ubuntu-latest` based emulator runs

* ci: add `v retry -r 2 --` to AAB deployments as these are sometimes flaky

* env: support installing `system-images`

* ci: simplify caching, do not cache test avd (not really time consuming)
  • Loading branch information
larpon authored Sep 29, 2024
1 parent bc87aa0 commit 1fa5d6b
Show file tree
Hide file tree
Showing 11 changed files with 726 additions and 47 deletions.
104 changes: 87 additions & 17 deletions .github/workflows/ci_emulator_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,79 @@ concurrency:
cancel-in-progress: true

jobs:
ubuntu-latest-test-all:
runs-on: ubuntu-latest
timeout-minutes: 35
env:
VAB_FLAGS: -cg -f '-d no_load_styles' -v 3 --api 30 --build-tools 33.0.2
VFLAGS: -no-parallel
steps:
- uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: 17

- 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
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 dependencies
run: |
v retry -- sudo apt update
v retry -- sudo apt install --quiet -y qemu-kvm
sudo chown $USER /dev/kvm
- name: Install SDK dependencies
run: |
vab install "platform-tools"
vab install "build-tools;33.0.2"
vab install "platforms;android-30"
vab install emulator
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: |
/usr/local/lib/android/sdk/system-images/android-30
key: ${{ runner.os }}-android-emulator-${{ hashFiles('/usr/local/lib/android/sdk/system-images') }}

- name: Prepare emulator
if: steps.cache-emulator.outputs.cache-hit != 'true'
run: |
vab install 'system-images;android-30;aosp_atd;x86_64'
- name: Run `vab test-all`
run: |
vab test-all
macos-legacy-run-v-examples:
runs-on: macos-12
timeout-minutes: 45
Expand Down Expand Up @@ -54,16 +127,10 @@ jobs:
- name: Run vab --help
run: vab --help

- name: Install build-tools 33.0.2
- name: Install SDK dependencies
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 "platforms;android-30"
vab install bundletool
vab install aapt2
Expand All @@ -75,15 +142,17 @@ jobs:
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') }}
key: ${{ runner.os }}-android-emulator-${{ hashFiles('/Users/runner/Library/Android/sdk/system-images/android-30') }}

- name: Prepare emulator
if: steps.cache-emulator.outputs.cache-hit != 'true'
run: |
vab install 'system-images;android-30;aosp_atd;x86_64'
- name: Create test AVD
run: |
export ANDROID_SDK_ROOT="$HOME/Library/Android/sdk"
echo yes | $ANDROID_SDK_ROOT/tools/bin/sdkmanager 'system-images;android-30;aosp_atd;x86_64'
echo no | $ANDROID_SDK_ROOT/tools/bin/avdmanager create avd --force --name test --abi aosp_atd/x86_64 --package 'system-images;android-30;aosp_atd;x86_64'
- name: Install and run V + V UI examples as APK and AAB
Expand All @@ -102,13 +171,14 @@ jobs:
# 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.apk.deploytest" --name "V DEPLOY TEST APK" v/examples/gg/bezier.v
vab v_deploy_test_apk.apk
sleep 1 # Experience tells us that the emulator likes to catch it's breath...
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
vab --package-id "io.v.ci.vab.aab.deploytest" --name "V DEPLOY TEST AAB" --package aab v/examples/gg/bezier.v
v retry -r 2 -- 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')
declare -a v_examples=('2048' 'flappylearning' '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
Expand All @@ -124,7 +194,7 @@ jobs:
# AAB
echo "Compiling aab from examples/$example ($package_id)"
vab --package aab --package-id "io.v.aab.$package_id" run v/examples/$example
v retry -r 2 -- vab --package aab --package-id "io.v.aab.$package_id" run v/examples/$example
done
# Output test
Expand Down Expand Up @@ -155,7 +225,7 @@ jobs:
# 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
v retry -r 2 -- vab --package aab --package-id "io.v.aab.ui.$package_id" run ui/examples/$example
done
# Output test
Expand Down
Loading

0 comments on commit 1fa5d6b

Please sign in to comment.