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