@@ -21,3 +21,160 @@ jobs:
2121          name : docker-logs 
2222          path : | 
2323            *.log 
24+ 
25+     android-build :
26+      name : Android ${{ matrix.build-type }} ${{ matrix.swift-version }} ${{ matrix.arch }} ${{ matrix.runner }} (compiler=${{ matrix.build-compiler }}) 
27+      strategy :
28+        fail-fast : false 
29+        matrix :
30+          include :
31+            # - swift-version: 'tag:swift-DEVELOPMENT-SNAPSHOT-2025-10-02-a'
32+            - swift-version : ' tag:swift-6.2-DEVELOPMENT-SNAPSHOT-2025-10-09-a' 
33+              build-type : ' docker' 
34+              build-compiler : ' 1' 
35+              runner : ' self-hosted' 
36+      runs-on : ${{ matrix.runner }} 
37+      #  16 hour timeout
38+      timeout-minutes : 1080 
39+      steps :
40+       - name : Free Disk Space 
41+         if : ${{ matrix.runner != 'self-hosted' }} 
42+         run : | 
43+           df -h 
44+           # brings available space from 25G to 32G 
45+           # otherwise we sometimes run out of space during the build 
46+           sudo rm -rf /usr/share/miniconda /usr/share/az* /usr/share/glade* /usr/local/share/chromium /usr/local/share/powershell /usr/share/dotnet /opt/ghc /opt/hostedtoolcache /usr/local/graalvm/ /usr/local/.ghcup/ /usr/local/lib/node_modules /usr/local/share/boost 
47+           sudo docker image prune --all --force 
48+           sudo docker builder prune -a 
49+           df -h 
50+        - name : Setup 
51+         id : config 
52+         run : | 
53+           # these variabes are used by build-docker and build-local 
54+           # to determine which Swift version to build for 
55+           echo "SWIFT_VERSION=${{ matrix.swift-version }}" >> $GITHUB_ENV 
56+           # pass the build-compiler matrix through to the build script 
57+           echo "BUILD_COMPILER=${{ matrix.build-compiler }}" >> $GITHUB_ENV 
58+           echo "TARGET_ARCHS=${{ matrix.arch }}" >> $GITHUB_ENV 
59+           echo "WORKDIR=${{ runner.temp }}/swift-android-sdk" >> $GITHUB_ENV 
60+        - name : Checkout repository 
61+         uses : actions/checkout@v4 
62+       - name : Build Android SDK (Local) 
63+         if : ${{ matrix.build-type == 'local' }} 
64+         working-directory : swift-ci/sdks/android 
65+         run : | 
66+           sudo apt install -q patchelf build-essential cmake ninja-build python3 golang git gnupg2 libcurl4-openssl-dev libedit-dev libicu-dev libncurses5-dev libpython3-dev libsqlite3-dev libxml2-dev rsync uuid-dev uuid-runtime tzdata curl unzip 
67+           ./build-local ${SWIFT_VERSION} ${WORKDIR} 
68+        - name : Build Android SDK (Docker) 
69+         if : ${{ matrix.build-type == 'docker' }} 
70+         working-directory : swift-ci/sdks/android 
71+         run : | 
72+           ./build-docker ${SWIFT_VERSION} ${WORKDIR} 
73+        - name : Install Host Toolchain 
74+         if : ${{ matrix.build-type == 'docker' }} 
75+         working-directory : swift-ci/sdks/android 
76+         run : | 
77+           # when building in a Docker container, we don't have a local host toolchain, 
78+           # but we need one in order to run the SDK validation tests, so we install it now 
79+           HOST_OS=ubuntu$(lsb_release -sr) 
80+           source ./scripts/toolchain-vars.sh 
81+           mkdir -p ${WORKDIR}/host-toolchain 
82+           ./scripts/install-swift.sh ${WORKDIR}/host-toolchain/$SWIFT_BASE/usr 
83+           ls ${WORKDIR}/host-toolchain 
84+           ${WORKDIR}/host-toolchain/*/usr/bin/swift --version 
85+        - name : Get artifact info 
86+         id : info 
87+         shell : bash 
88+         run : | 
89+           set -ex 
90+           SWIFT_ROOT=$(dirname ${WORKDIR}/host-toolchain/*/usr) 
91+           echo "swift-root=${SWIFT_ROOT}" >> $GITHUB_OUTPUT 
92+           echo "swift-path=${SWIFT_ROOT}/usr/bin/swift" >> $GITHUB_OUTPUT 
93+ 
94+           ARTIFACT_PATH=$(realpath ${WORKDIR}/products/*.artifactbundle.tar.gz) 
95+           echo "artifact-path=${ARTIFACT_PATH}" >> $GITHUB_OUTPUT 
96+           echo "sdk-id=x86_64-unknown-linux-android28" >> $GITHUB_OUTPUT 
97+ 
98+           ARTIFACT_EXT=".artifactbundle.tar.gz" 
99+           ARTIFACT_NAME="$(basename ${ARTIFACT_PATH} ${ARTIFACT_EXT})" 
100+           # depending on whether we are building locally or in a container, add a maker to the name 
101+           if [[ "${{ matrix.build-type }}" == 'local' ]]; then 
102+             ARTIFACT_NAME="${ARTIFACT_NAME}-local" 
103+           fi 
104+           if [[ "${{ matrix.build-compiler }}" == '1' ]]; then 
105+             ARTIFACT_NAME="${ARTIFACT_NAME}-hostbuild" 
106+           fi 
107+           # artifacts need a unique name so we suffix with the matrix arch(s) 
108+           if [[ ! -z "${{ matrix.arch }}" ]]; then 
109+             ARTIFACT_NAME="${ARTIFACT_NAME}-$(echo ${{ matrix.arch }} | tr ',' '-')" 
110+           fi 
111+           ARTIFACT_NAME="${ARTIFACT_NAME}${ARTIFACT_EXT}" 
112+ 
113+           # There is no way to prevent even a single-file artifact from being zipped: 
114+           # https://github.com/actions/upload-artifact?tab=readme-ov-file#zip-archives 
115+           # so the actual artifact download will look like: 
116+           # swift-6.1-RELEASE_android-0.1-x86_64.artifactbundle.tar.gz.zip 
117+           echo "artifact-name=${ARTIFACT_NAME}" >> $GITHUB_OUTPUT 
118+        - name : Upload SDK artifactbundle 
119+         uses : actions/upload-artifact@v4 
120+         with :
121+           compression-level : 0 
122+           name : ${{ steps.info.outputs.artifact-name }} 
123+           path : ${{ steps.info.outputs.artifact-path }} 
124+       - name : Cleanup 
125+         if : ${{ matrix.runner != 'self-hosted' }} 
126+         run : | 
127+           # need to free up some space or else when installing we get: No space left on device 
128+           df -h 
129+           rm -rf ${WORKDIR}/{build,source} 
130+           sudo docker image prune --all --force 
131+           sudo docker builder prune -a 
132+           df -h 
133+        - name : Install artifactbundle 
134+         if : ${{ matrix.runner != 'self-hosted' }} 
135+         shell : bash 
136+         run : | 
137+           set -ex 
138+           ${{ steps.info.outputs.swift-path }} sdk install ${{ steps.info.outputs.artifact-path }} 
139+           ${{ steps.info.outputs.swift-path }} sdk configure --show-configuration $(${{ steps.info.outputs.swift-path }} sdk list | head -n 1) ${{ steps.info.outputs.sdk-id }} 
140+           # recent releases require that ANDROID_NDK_ROOT *not* be set 
141+           # see https://github.com/swiftlang/swift-driver/pull/1879 
142+           echo "ANDROID_NDK_ROOT=" >> $GITHUB_ENV 
143+ 
144+        - name : Create Demo Project 
145+         if : ${{ matrix.runner != 'self-hosted' }} 
146+         run : | 
147+           cd ${{ runner.temp }} 
148+           mkdir DemoProject 
149+           cd DemoProject 
150+           ${{ steps.info.outputs.swift-path }} --version 
151+           ${{ steps.info.outputs.swift-path }} package init 
152+           echo 'import Foundation' >> Sources/DemoProject/DemoProject.swift 
153+           echo 'import FoundationEssentials' >> Sources/DemoProject/DemoProject.swift 
154+           echo 'import FoundationXML' >> Sources/DemoProject/DemoProject.swift 
155+           echo 'import FoundationNetworking' >> Sources/DemoProject/DemoProject.swift 
156+           echo 'import Dispatch' >> Sources/DemoProject/DemoProject.swift 
157+           echo 'import Android' >> Sources/DemoProject/DemoProject.swift 
158+        - name : Test Demo Project on Android 
159+         uses : skiptools/swift-android-action@main 
160+         if : ${{ matrix.runner != 'self-hosted' }} 
161+         with :
162+           #  only test for the complete arch SDK build to speed up CI
163+           # run-tests: ${{ matrix.arch == '' }}
164+           package-path : ${{ runner.temp }}/DemoProject 
165+           installed-sdk : ${{ steps.info.outputs.sdk-id }} 
166+           installed-swift : ${{ steps.info.outputs.swift-root }} 
167+ 
168+       - name : Checkout swift-algorithms 
169+         if : ${{ matrix.runner != 'self-hosted' }} 
170+         uses : actions/checkout@v4 
171+         with :
172+           repository : apple/swift-algorithms 
173+           path : swift-algorithms 
174+       - name : Test swift-algorithms 
175+         if : ${{ matrix.runner != 'self-hosted' }} 
176+         uses : skiptools/swift-android-action@main 
177+         with :
178+           package-path : swift-algorithms 
179+           installed-sdk : ${{ steps.info.outputs.sdk-id }} 
180+           installed-swift : ${{ steps.info.outputs.swift-root }} 
0 commit comments