@@ -33,13 +33,129 @@ jobs:
3333 run : ./build
3434
3535 android-build :
36- name : Build Android image
37- runs-on : ubuntu-latest
38- if : false
36+ name : Build Android ${{ matrix.arch }} SDK
37+ strategy :
38+ fail-fast : false
39+ matrix :
40+ # blank arch builds all (aarch64,x86_64,armv7)
41+ # arch: ['']
42+ # builds only x86_64 to speed up the validation
43+ # arch: ['x86_64']
44+ # build both the quick (x86_64) and complete (aarch64,x86_64,armv7) SDKs
45+ arch : ['x86_64', '']
46+ runs-on : ubuntu-24.04
3947 steps :
4048 - name : Checkout repository
4149 uses : actions/checkout@v4
42- - name : Build Docker images
50+ - name : Install Dependencies
51+ run : |
52+ sudo apt install -q ninja-build patchelf
53+ - name : Build Android SDK
4354 working-directory : swift-ci/sdks/android
44- run : ./build
55+ run : |
56+ TARGET_ARCHS=${{ matrix.arch }} ./build
57+ - name : Get artifact info
58+ id : info
59+ shell : bash
60+ run : |
61+ set -ex
62+ SWIFT_ROOT=$(dirname ${{ runner.temp }}/swift-android-sdk/host-toolchain/*/usr)
63+ echo "swift-root=${SWIFT_ROOT}" >> $GITHUB_OUTPUT
64+ echo "swift-path=${SWIFT_ROOT}/usr/bin/swift" >> $GITHUB_OUTPUT
65+
66+ ARTIFACT_BUILD=$(realpath ${{ runner.temp }}/swift-android-sdk/build/*.artifactbundle)
67+ ARTIFACT_PATH=$(realpath ${{ runner.temp }}/swift-android-sdk/products/*.artifactbundle.tar.gz)
68+ echo "artifact-path=${ARTIFACT_PATH}" >> $GITHUB_OUTPUT
69+ echo "sdk-id=x86_64-unknown-linux-android28" >> $GITHUB_OUTPUT
70+
71+ ARTIFACT_EXT=".artifactbundle.tar.gz"
72+ ARTIFACT_NAME="$(basename ${ARTIFACT_PATH} ${ARTIFACT_EXT})"
73+ # artifacts need a unique name so we suffix with the matrix arch(s)
74+ if [[ ! -z "${{ matrix.arch }}" ]]; then
75+ ARTIFACT_NAME="${ARTIFACT_NAME}-$(echo ${{ matrix.arch }} | tr ',' '-')"
76+ fi
77+ ARTIFACT_NAME="${ARTIFACT_NAME}${ARTIFACT_EXT}"
78+
79+ # There is no way to prevent even a single-file artifact from being zipped:
80+ # https://github.com/actions/upload-artifact?tab=readme-ov-file#zip-archives
81+ # so the actual artifact download will look like:
82+ # swift-6.1-RELEASE_android-0.1-x86_64.artifactbundle.tar.gz.zip
83+ echo "artifact-name=${ARTIFACT_NAME}" >> $GITHUB_OUTPUT
84+
85+ # validate some required paths in the artifactbundle
86+ pushd ${ARTIFACT_BUILD}/*/*/usr
87+ ls lib/swift/android
88+ ls lib/swift/android/*
89+ ls lib/swift/android/*/swiftrt.o
90+ ls lib/*-linux-android/*/crtbegin_dynamic.o
91+
92+ ls lib/swift_static-*
93+ ls lib/swift_static-*/android
94+ ls lib/swift_static-*/android/libFoundationEssentials.a
95+
96+ ls lib/*-linux-android/libFoundationEssentials.so
97+ ls lib/*-linux-android/libFoundationNetworking.so
98+ ls lib/*-linux-android/libFoundationInternationalization.so
99+ ls lib/*-linux-android/lib_FoundationICU.so
100+ ls lib/*-linux-android/libFoundationXML.so
101+ ls lib/*-linux-android/libTesting.so
102+
103+ ls lib/swift/clang/lib
104+ ls lib/swift/clang/lib/linux
105+ ls lib/swift/clang/lib/linux/*/libunwind.a
106+ popd
107+ - name : Upload SDK artifactbundle
108+ uses : actions/upload-artifact@v4
109+ with :
110+ compression-level : 0
111+ name : ${{ steps.info.outputs.artifact-name }}
112+ path : ${{ steps.info.outputs.artifact-path }}
113+ - name : Cleanup
114+ run : |
115+ # need to free up some space or else when installing we get: No space left on device
116+ rm -rf ${{ runner.temp }}/swift-android-sdk/{build,src}
117+ - name : Install artifactbundle
118+ shell : bash
119+ run : |
120+ set -ex
121+ ${{ steps.info.outputs.swift-path }} sdk install ${{ steps.info.outputs.artifact-path }}
122+ ${{ steps.info.outputs.swift-path }} sdk configure --show-configuration $(${{ steps.info.outputs.swift-path }} sdk list | head -n 1) ${{ steps.info.outputs.sdk-id }}
123+ # recent releases require that ANDROID_NDK_ROOT *not* be set
124+ # see https://github.com/finagolfin/swift-android-sdk/issues/207
125+ echo "ANDROID_NDK_ROOT=" >> $GITHUB_ENV
126+
127+ - name : Create Demo Project
128+ run : |
129+ cd ${{ runner.temp }}
130+ mkdir DemoProject
131+ cd DemoProject
132+ ${{ steps.info.outputs.swift-path }} --version
133+ ${{ steps.info.outputs.swift-path }} package init
134+ echo 'import Foundation' >> Sources/DemoProject/DemoProject.swift
135+ echo 'import FoundationEssentials' >> Sources/DemoProject/DemoProject.swift
136+ echo 'import FoundationXML' >> Sources/DemoProject/DemoProject.swift
137+ echo 'import FoundationNetworking' >> Sources/DemoProject/DemoProject.swift
138+ echo 'import Dispatch' >> Sources/DemoProject/DemoProject.swift
139+ echo 'import Android' >> Sources/DemoProject/DemoProject.swift
140+ - name : Test Demo Project on Android
141+ uses : skiptools/swift-android-action@v2
142+ with :
143+ # only test for the complete arch SDK build to speed up CI
144+ run-tests : ${{ matrix.arch == '' }}
145+ package-path : ${{ runner.temp }}/DemoProject
146+ installed-sdk : ${{ steps.info.outputs.sdk-id }}
147+ installed-swift : ${{ steps.info.outputs.swift-root }}
148+
149+ - name : Checkout swift-algorithms
150+ uses : actions/checkout@v4
151+ with :
152+ repository : apple/swift-algorithms
153+ path : swift-algorithms
154+ - name : Test swift-algorithms
155+ uses : skiptools/swift-android-action@v2
156+ with :
157+ run-tests : ${{ matrix.arch == '' }}
158+ package-path : swift-algorithms
159+ installed-sdk : ${{ steps.info.outputs.sdk-id }}
160+ installed-swift : ${{ steps.info.outputs.swift-root }}
45161
0 commit comments