Skip to content

Commit c1f68d3

Browse files
committed
Update CI
1 parent 8666be9 commit c1f68d3

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

.github/workflows/scripts/install-and-build-with-sdk.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ find_latest_sdk_snapshot() {
203203
log "Finding latest ${sdk_name}-sdk for Swift nightly-${version}"
204204
log "Fetching development snapshots from swift.org API..."
205205

206+
if [[ "${sdk_name}" == "android" ]]; then
207+
# FIXME: hardwired Android nightly until there is an API endpoint
208+
echo "swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a|451844c232cf1fa02c52431084ed3dc27a42d103635c6fa71bae8d66adba2500"
209+
return
210+
fi
211+
206212
local sdk_json
207213
sdk_json=$(curl -fsSL "${SWIFT_API_INSTALL_ROOT}/dev/${version}/${sdk_name}-sdk.json") || fatal "Failed to fetch ${sdk_name}-sdk development snapshots"
208214

.github/workflows/swift_package_test.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ on:
5050
type: string
5151
description: "Exclude Wasm Swift SDK version list (JSON)"
5252
default: "[{\"swift_version\": \"\"}]"
53+
android_sdk_versions:
54+
type: string
55+
description: "Android Swift SDK version list (JSON)"
56+
default: "[\"nightly-main\", \"nightly-6.2\", \"6.2\"]"
57+
android_exclude_swift_versions:
58+
type: string
59+
description: "Exclude Android Swift SDK version list (JSON)"
60+
default: "[{\"swift_version\": \"\"}]"
5361
windows_swift_versions:
5462
type: string
5563
description: "Include Windows Swift version list (JSON)"
@@ -79,6 +87,10 @@ on:
7987
type: string
8088
description: "Linux command to execute before building the Swift package with the Embedded Swift SDK for Wasm"
8189
default: ""
90+
android_sdk_pre_build_command:
91+
type: string
92+
description: "Linux command to execute before building the Swift package with the Embedded Swift SDK for Android"
93+
default: ""
8294
macos_pre_build_command:
8395
type: string
8496
description: "macOS command to execute before building the Swift package"
@@ -99,6 +111,10 @@ on:
99111
type: string
100112
description: "Command to use when building the package with the Swift SDK for Wasm"
101113
default: "swift build"
114+
android_sdk_build_command:
115+
type: string
116+
description: "Command to use when building the package with the Swift SDK for Android"
117+
default: "swift build"
102118
windows_pre_build_command:
103119
type: string
104120
description: "Windows Command Prompt command to execute before building the Swift package"
@@ -135,6 +151,10 @@ on:
135151
type: boolean
136152
description: "Boolean to enable building with the Embedded Swift SDK for Wasm. Defaults to false"
137153
default: false
154+
enable_android_sdk_build:
155+
type: boolean
156+
description: "Boolean to enable building with the Swift SDK for Android. Defaults to false"
157+
default: false
138158
enable_macos_checks:
139159
type: boolean
140160
description: "Boolean to enable macOS testing. Defaults to false"
@@ -355,6 +375,63 @@ jobs:
355375
curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \
356376
bash -s -- --wasm --flags="$BUILD_FLAGS" --build-command="${{ inputs.wasm_sdk_build_command }}" ${{ matrix.swift_version }}
357377
378+
android-sdk-build:
379+
name: Swift SDK for Android Build (${{ matrix.swift_version }} - ${{ matrix.os_version }})
380+
if: ${{ inputs.enable_android_sdk_build }}
381+
runs-on: ubuntu-latest
382+
strategy:
383+
fail-fast: false
384+
matrix:
385+
swift_version: ${{ fromJson(inputs.android_sdk_versions) }}
386+
os_version: ${{ fromJson(inputs.linux_os_versions) }}
387+
exclude:
388+
- ${{ fromJson(inputs.android_exclude_swift_versions) }}
389+
container:
390+
image: ${{ (contains(matrix.swift_version, 'nightly') && 'swiftlang/swift') || 'swift' }}:${{ matrix.swift_version }}-${{ matrix.os_version }}
391+
steps:
392+
- name: Swift version
393+
run: swift --version
394+
- name: Clang version
395+
run: clang --version
396+
- name: Checkout repository
397+
uses: actions/checkout@v4
398+
if: ${{ matrix.os_version != 'amazonlinux2' }}
399+
- name: Checkout repository
400+
uses: actions/checkout@v1
401+
if: ${{ matrix.os_version == 'amazonlinux2' }}
402+
- name: Provide token
403+
if: ${{ inputs.needs_token }}
404+
run: |
405+
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
406+
- name: Set environment variables
407+
if: ${{ inputs.linux_env_vars }}
408+
run: |
409+
for i in "${{ inputs.linux_env_vars }}"
410+
do
411+
printf "%s\n" $i >> $GITHUB_ENV
412+
done
413+
- name: Pre-build
414+
run: ${{ inputs.linux_pre_build_command }}
415+
- name: Install Swift SDK for Android and build
416+
env:
417+
BUILD_FLAGS: ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }}
418+
run: |
419+
${{ inputs.android_sdk_pre_build_command }}
420+
if command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy, focal
421+
apt-get -q update && apt-get -yq install curl
422+
elif command -v dnf >/dev/null 2>&1 ; then # rhel-ubi9
423+
dnf -y update
424+
dnf -y install curl-minimal
425+
elif command -v yum >/dev/null 2>&1 ; then # amazonlinux2
426+
yum -y update
427+
yum -y install curl
428+
else
429+
echo "Unknown package manager (tried apt-get, dnf, yum)" >&2
430+
exit 1
431+
fi
432+
curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \
433+
bash -s -- --android --flags="$BUILD_FLAGS" --build-command="${{ inputs.android_sdk_build_command }}" ${{ matrix.swift_version }}
434+
358435
embedded-wasm-sdk-build:
359436
name: Embedded Swift SDK for Wasm Build (${{ matrix.swift_version }} - ${{ matrix.os_version }})
360437
if: ${{ inputs.enable_embedded_wasm_sdk_build }}

0 commit comments

Comments
 (0)