Skip to content

Commit 5759c91

Browse files
authored
Use setup-skip action (#1)
* Use setup-skip action * Update CI to run on pull_request * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Try setup-skip action * Update versions of actions * Cleanup
1 parent 2d4193c commit 5759c91

File tree

1 file changed

+69
-58
lines changed

1 file changed

+69
-58
lines changed

.github/workflows/ci.yml

Lines changed: 69 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
push:
44
branches: [ main ]
55
workflow_dispatch:
6-
6+
pull_request:
77
jobs:
88
install-sdk:
99
strategy:
@@ -12,90 +12,101 @@ jobs:
1212
- name: 'macOS 26'
1313
os: 'macos-26'
1414
ANDROID_API: 28
15-
ANDROID_ARCH: 'arm64-v8a'
16-
ANDROID_GPU: 'swiftshader_indirect'
17-
- name: 'macOS 15'
18-
os: 'macos-15'
19-
ANDROID_API: 28
20-
ANDROID_ARCH: 'arm64-v8a'
21-
ANDROID_GPU: 'swiftshader_indirect'
22-
- name: 'macOS 14'
23-
os: 'macos-14'
24-
ANDROID_API: 28
25-
ANDROID_ARCH: 'arm64-v8a'
26-
ANDROID_GPU: 'swiftshader_indirect'
15+
EMULATOR_ARCH: 'arm64-v8a'
16+
EMULATOR_GPU: 'swiftshader_indirect'
17+
#- name: 'macOS 15'
18+
# os: 'macos-15'
19+
# ANDROID_API: 28
20+
# EMULATOR_ARCH: 'arm64-v8a'
21+
# EMULATOR_GPU: 'swiftshader_indirect'
22+
#- name: 'macOS 14'
23+
# os: 'macos-14'
24+
# ANDROID_API: 28
25+
# EMULATOR_ARCH: 'arm64-v8a'
26+
# EMULATOR_GPU: 'swiftshader_indirect'
2727
- name: 'macOS 13'
2828
os: 'macos-13'
2929
ANDROID_API: 28
30-
ANDROID_ARCH: 'x86_64'
31-
ANDROID_GPU: 'swiftshader_indirect'
30+
EMULATOR_ARCH: 'x86_64'
31+
EMULATOR_GPU: 'swiftshader_indirect'
3232
- name: 'Ubuntu Latest'
3333
os: 'ubuntu-latest'
3434
ANDROID_API: 28
35-
ANDROID_ARCH: 'x86_64'
36-
ANDROID_GPU: 'none'
35+
EMULATOR_ARCH: 'x86_64'
36+
EMULATOR_GPU: 'swiftshader_indirect'
3737
fail-fast: false
3838
runs-on: ${{ matrix.os }}
3939
env:
4040
ANDROID_API: ${{ matrix.ANDROID_API }}
41-
ANDROID_ARCH: ${{ matrix.ANDROID_ARCH }}
42-
ANDROID_GPU: ${{ matrix.ANDROID_GPU }}
41+
EMULATOR_ARCH: ${{ matrix.EMULATOR_ARCH }}
42+
EMULATOR_GPU: ${{ matrix.EMULATOR_GPU }}
43+
EMULATOR_ENGINE: ${{ matrix.EMULATOR_ENGINE }}
4344
ANDROID_TARGET: 'default'
4445
#ANDROID_BUILD_TOOLS_VERSION: 36.0.0
4546
ANDROID_BUILD_TOOLS_VERSION: 'latest'
46-
ANDROID_EMULATOR_NAME: 'test'
47+
ANDROID_EMULATOR_NAME: 'demo'
48+
ANDROID_PROFILE: "Nexus 10"
49+
ANDROID_CHANNEL: "3"
50+
BUILD_TOOLS_VERSION: "35.0.0"
4751
steps:
52+
- uses: skiptools/actions/setup-skip@v1
53+
54+
- uses: nttld/setup-ndk@v1
55+
id: setup-ndk
56+
with:
57+
ndk-version: r27d
58+
4859
- name: "Setup Environment"
4960
run: |
5061
echo "$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/${{ env.ANDROID_BUILD_TOOLS_VERSION }}" >> $GITHUB_PATH
62+
echo "ANDROID_NDK_HOME=${{ steps.setup-ndk.outputs.ndk-path }}" >> $GITHUB_ENV
63+
# needed for Linux or else the emulator will be created in
64+
# ~/.android/avd but it will be sought in ~/.config/.android/avd
65+
if [[ "${RUNNER_OS}" == "Linux" ]]; then
66+
echo "ANDROID_AVD_HOME=${XDG_CONFIG_HOME}/.android/avd" >> $GITHUB_ENV
67+
fi
5168
52-
- name: "Launch emulator"
53-
timeout-minutes: 10
54-
run: |
55-
which adb
69+
- uses: skiptools/swift-android-action@v2
70+
with:
71+
build-package: false
5672

57-
yes Y | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses
73+
- name: SDKs - accept licenses
74+
run: yes y | sdkmanager --licenses
5875

59-
# Install AVD files
60-
yes Y | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "system-images;android-${ANDROID_API};${ANDROID_TARGET};${ANDROID_ARCH}"
61-
yes Y | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --channel=3 emulator
62-
# Create emulator
63-
echo "no" | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -f -n test -d "Nexus 10" --abi "${ANDROID_TARGET}/${ANDROID_ARCH}" -k "system-images;android-${ANDROID_API};${ANDROID_TARGET};${ANDROID_ARCH}" --force
64-
$ANDROID_HOME/emulator/emulator -list-avds
65-
echo "Starting emulator"
66-
67-
# Start emulator in background
68-
nohup $ANDROID_HOME/emulator/emulator -avd ${ANDROID_EMULATOR_NAME} -no-snapshot -no-window -no-audio -no-boot-anim -no-accel -no-metrics -camera-back none -accel off -gpu ${ANDROID_GPU} &
69-
# Fixed quoting around "\r"
70-
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d "\r") ]]; do sleep 1; done; input keyevent 82'
71-
$ANDROID_HOME/platform-tools/adb devices
72-
echo "Emulator started"
73-
74-
- name: "Check Emulator"
75-
run: |
76-
$ANDROID_HOME/platform-tools/adb shell 'echo Hello Android!'
77-
78-
- name: "Install Skip (macOS)"
79-
if: ${{ startsWith(matrix.os, 'macos-') }}
80-
run: |
81-
brew install skiptools/skip/skip
82-
skip android sdk install
76+
- name: SKDs - setup build tools
77+
run: sdkmanager --install "build-tools;${BUILD_TOOLS_VERSION}" platform-tools "platforms;android-${ANDROID_API}" --channel="${ANDROID_CHANNEL}"
8378

84-
- name: Install Skip (Ubuntu)
85-
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
79+
- name: SKDs - setup emulator
80+
run: sdkmanager --install emulator --channel="${ANDROID_CHANNEL}"
81+
82+
- name: SKDs - download required images
83+
run: sdkmanager --install "system-images;android-${ANDROID_API};${ANDROID_TARGET};${EMULATOR_ARCH}" --channel="${ANDROID_CHANNEL}"
84+
85+
- name: Emulator - Create
86+
run: avdmanager --verbose create avd --force -n "${ANDROID_EMULATOR_NAME}" --device "${ANDROID_PROFILE}" --abi "${ANDROID_TARGET}/${EMULATOR_ARCH}" --package "system-images;android-${ANDROID_API};${ANDROID_TARGET};${EMULATOR_ARCH}" --sdcard 512M
87+
88+
- name: Emulator - Find AVDs
89+
run: find ~/ -type d -name '*.avd'
90+
91+
- name: Emulator - List AVDs
92+
run: emulator -list-avds
93+
94+
- name: Emulator - Boot
95+
run: emulator -memory 4096 -avd "${ANDROID_EMULATOR_NAME}" -wipe-data -no-window -accel off -no-accel -gpu "${EMULATOR_GPU}" -no-snapshot -noaudio -no-boot-anim &
96+
97+
- name: ADB Wait For Device
98+
run: adb wait-for-any-device
99+
timeout-minutes: 3
100+
101+
- name: "Check Emulator"
86102
run: |
87-
mkdir -p ~/bin/skiptools
88-
cd ~/bin/skiptools
89-
curl -fsSLO https://github.com/skiptools/skip/releases/latest/download/skip-linux.zip
90-
unzip skip-linux.zip
91-
echo "PATH=${PWD}/skip.artifactbundle/$(uname -m)-swift-linux-musl:${PATH}" >> $GITHUB_ENV
92-
cd -
103+
adb shell 'echo Hello Android!'
93104
94105
- name: "Test Swift Package"
95106
run: |
96107
mkdir PackageDemo
97108
cd PackageDemo
98109
swift package init
99110
swift test
100-
skip android test
111+
skip android test --arch ${EMULATOR_ARCH}
101112

0 commit comments

Comments
 (0)