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