From b5e73a415ed4323ecb93a72d0ec0792cd1eaa9c5 Mon Sep 17 00:00:00 2001 From: Johan Kool Date: Sat, 7 Dec 2024 15:26:06 +0100 Subject: [PATCH 1/3] Compile for Android on CI --- .github/workflows/ci.yml | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 607f37a..68cd077 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ on: pull_request: branches: - '*' + workflow_dispatch: concurrency: group: ci-${{ github.ref }} @@ -139,3 +140,47 @@ jobs: run: swift build -c ${{ matrix.config }} - name: Run tests (debug only) run: swift test + + android: + name: Android (Swift 6.0.2) + runs-on: ubuntu-22.04 + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Install Swift + uses: tayloraswift/swift-install-action@master + with: + swift-prefix: swift-6.0.2-release/ubuntu2204/swift-6.0.2-RELEASE + swift-id: swift-6.0.2-RELEASE-ubuntu22.04 + - name: Check Swift + run: swift --version + - name: Install Android SDK + run: + swift sdk install https://github.com/finagolfin/swift-android-sdk/releases/download/6.0.2/swift-6.0.2-RELEASE-android-24-0.1.artifactbundle.tar.gz --checksum d75615eac3e614131133c7cc2076b0b8fb4327d89dce802c25cd53e75e1881f4 + - name: Check Android SDK + run: + swift sdk configure --show-configuration swift-6.0.2-RELEASE-android-24-0.1 x86_64-unknown-linux-android24 + - name: Build Tests + run: + swift build --build-tests --swift-sdk x86_64-unknown-linux-android24 -Xswiftc -Xclang-linker -Xswiftc -fuse-ld=lld + - name: Prepare Android Emulator Test Script + run: | + mkdir pack + cp .build/x86_64-unknown-linux-android24/debug/xctest-dynamic-overlayPackageTests.xctest pack + + cp /home/runner/.config/swiftpm/swift-sdks/swift-6.0.2-RELEASE-android-24-0.1.artifactbundle/swift-6.0.2-release-android-24-sdk/android-27c-sysroot/usr/lib/x86_64-linux-android/24/lib*.so pack + rm pack/lib{c,dl,log,m,z}.so + + set -x + cat > ~/test-toolchain.sh << EOF + adb push pack /data/local/tmp + adb shell /data/local/tmp/pack/xctest-dynamic-overlayPackageTests.xctest + EOF + + chmod +x ~/test-toolchain.sh + - name: Run Tests on Android Emulator + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 29 + arch: x86_64 + script: ~/test-toolchain.sh \ No newline at end of file From 826468038947afe7df949c157316259b5d2f1f25 Mon Sep 17 00:00:00 2001 From: Johan Kool Date: Sat, 21 Dec 2024 16:00:27 +0100 Subject: [PATCH 2/3] Use custom GitHub Action --- .github/workflows/ci.yml | 41 ++-------------------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 68cd077..fe9a637 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,42 +145,5 @@ jobs: name: Android (Swift 6.0.2) runs-on: ubuntu-22.04 steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - name: Install Swift - uses: tayloraswift/swift-install-action@master - with: - swift-prefix: swift-6.0.2-release/ubuntu2204/swift-6.0.2-RELEASE - swift-id: swift-6.0.2-RELEASE-ubuntu22.04 - - name: Check Swift - run: swift --version - - name: Install Android SDK - run: - swift sdk install https://github.com/finagolfin/swift-android-sdk/releases/download/6.0.2/swift-6.0.2-RELEASE-android-24-0.1.artifactbundle.tar.gz --checksum d75615eac3e614131133c7cc2076b0b8fb4327d89dce802c25cd53e75e1881f4 - - name: Check Android SDK - run: - swift sdk configure --show-configuration swift-6.0.2-RELEASE-android-24-0.1 x86_64-unknown-linux-android24 - - name: Build Tests - run: - swift build --build-tests --swift-sdk x86_64-unknown-linux-android24 -Xswiftc -Xclang-linker -Xswiftc -fuse-ld=lld - - name: Prepare Android Emulator Test Script - run: | - mkdir pack - cp .build/x86_64-unknown-linux-android24/debug/xctest-dynamic-overlayPackageTests.xctest pack - - cp /home/runner/.config/swiftpm/swift-sdks/swift-6.0.2-RELEASE-android-24-0.1.artifactbundle/swift-6.0.2-release-android-24-sdk/android-27c-sysroot/usr/lib/x86_64-linux-android/24/lib*.so pack - rm pack/lib{c,dl,log,m,z}.so - - set -x - cat > ~/test-toolchain.sh << EOF - adb push pack /data/local/tmp - adb shell /data/local/tmp/pack/xctest-dynamic-overlayPackageTests.xctest - EOF - - chmod +x ~/test-toolchain.sh - - name: Run Tests on Android Emulator - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 29 - arch: x86_64 - script: ~/test-toolchain.sh \ No newline at end of file + - name: Test on Android + uses: johankool/swift-android-test-action@v1 From a51e83a9c027761c02289050a53a29d8cbad3c8d Mon Sep 17 00:00:00 2001 From: Johan Kool Date: Sat, 21 Dec 2024 16:25:55 +0100 Subject: [PATCH 3/3] Simplify --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe9a637..9310e6b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -142,8 +142,7 @@ jobs: run: swift test android: - name: Android (Swift 6.0.2) + name: Android runs-on: ubuntu-22.04 steps: - - name: Test on Android - uses: johankool/swift-android-test-action@v1 + - uses: johankool/swift-android-test-action@v1