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