Skip to content

Commit 0efede3

Browse files
committed
ci: passing swift CI
1 parent cd0421c commit 0efede3

File tree

2 files changed

+63
-48
lines changed

2 files changed

+63
-48
lines changed

.github/workflows/ci_cd.yml

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: CI/CD
22

33
on:
4-
push: # A push indicates that a PR is merged and CD should be triggered
5-
branches:
6-
- main
4+
# push: # A push indicates that a PR is merged and CD should be triggered
5+
# branches:
6+
# - main
77
pull_request: # For PRs, we run CI, which is the same as CD without the release step(s)
88
branches:
99
- main
@@ -54,26 +54,33 @@ jobs:
5454
setup:
5555
runs-on: ubuntu-latest
5656
outputs:
57-
# The packages that use Uniffi bindings
58-
ffi_packages: ${{ steps.set_ffi_packages.outputs.ffi_packages }}
57+
# Swift/FFI jobs (array of objects: crate_name, swift_package)
58+
ffi_packages: ${{ steps.set_matrices.outputs.ffi_packages }}
5959
steps:
60-
- id: set_ffi_packages
61-
run: echo 'ffi_packages=["algokit_transact"]' >> $GITHUB_OUTPUT
60+
- id: set_matrices
61+
run: |
62+
python3 - <<'PY' >> "$GITHUB_OUTPUT"
63+
import json
64+
# Crates that produce FFI bindings
65+
crates = ["algokit_transact"]
66+
items = []
67+
for crate in crates:
68+
pascal = ''.join(p.capitalize() for p in crate.split('_'))
69+
# Brand fixups
70+
pascal = pascal.replace('Algokit', 'AlgoKit')
71+
items.append({"crate_name": crate, "swift_package": pascal})
72+
print('ffi_packages=' + json.dumps(items))
73+
PY
6274
63-
python_uniffi_ci_cd:
75+
swift_ci:
6476
needs:
6577
- setup
66-
uses: ./.github/workflows/python_uniffi_ci_cd.yml
78+
uses: ./.github/workflows/swift_ci.yml
6779
strategy:
6880
matrix:
69-
crate: ${{ fromJSON(needs.setup.outputs.ffi_packages) }}
81+
include: ${{ fromJSON(needs.setup.outputs.ffi_packages) }}
7082
with:
71-
crate: ${{ matrix.crate }}
83+
crate: ${{ matrix.crate_name }}
84+
package: ${{ matrix.swift_package }}
7285
release: ${{ github.event_name == 'push' }}
73-
secrets:
74-
BOT_ID: ${{ secrets.BOT_ID }}
75-
BOT_SK: ${{ secrets.BOT_SK }}
76-
deploy_docs:
77-
# Only run on pushes to main (not on PRs)
78-
if: github.event_name == 'push'
79-
uses: ./.github/workflows/deploy_docs.yml
86+

.github/workflows/swift_ci.yml

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,45 @@
11
name: Swift CI
22

33
on:
4-
# Temporarily disable automatic CI for swift while we focus on Python and TS
5-
# push:
6-
# branches:
7-
# - main
8-
# tags:
9-
# - "*"
10-
# pull_request:
11-
# branches:
12-
# - main
4+
workflow_call:
5+
inputs:
6+
crate:
7+
description: "Crate name to build Swift package from"
8+
required: true
9+
type: string
10+
package:
11+
description: "Swift package (Xcode scheme) name"
12+
required: true
13+
type: string
14+
release:
15+
description: "Whether to commit generated package (push only)"
16+
required: false
17+
type: boolean
18+
default: false
1319
workflow_dispatch:
20+
inputs:
21+
crate:
22+
description: "Crate name"
23+
required: true
24+
type: string
25+
default: algokit_transact
26+
package:
27+
description: "Swift package name"
28+
required: true
29+
type: string
30+
default: AlgoKitTransact
31+
release:
32+
description: "Commit generated package"
33+
required: false
34+
type: boolean
35+
default: false
1436

1537
permissions:
1638
contents: write
1739

1840
env:
19-
CRATE: algokit_transact
20-
PACKAGE: AlgoKitTransact
41+
CRATE: ${{ inputs.crate }}
42+
PACKAGE: ${{ inputs.package }}
2143

2244
jobs:
2345
build_and_test:
@@ -31,28 +53,14 @@ jobs:
3153
with:
3254
toolchain: 1.85.0
3355
targets: aarch64-apple-ios, x86_64-apple-ios, aarch64-apple-ios-sim, x86_64-apple-ios, aarch64-apple-ios-macabi, x86_64-apple-ios-macabi, aarch64-apple-darwin, x86_64-apple-darwin
34-
- uses: oven-sh/setup-bun@v2
35-
with:
36-
bun-version: latest
37-
- name: Setup Xcode
38-
uses: mxcl/xcodebuild@v3
39-
with:
40-
swift: ^6
41-
action: none
42-
platform: macOS
43-
- name: Install iOS Simulator
44-
run: xcodebuild -downloadPlatform iOS
4556
- name: Build
46-
run: bun scripts/build ${{ env.CRATE }} swift
57+
run: cargo pkg ${{ env.CRATE }} swift
58+
4759
# Ideally we'd use a matrix for the platforms, but due to the limitations of Mac runners on GitHub it's probably better to just have a single job with multiple steps
48-
- name: Test (macOS)
49-
run: cd packages/swift/${{ env.PACKAGE }} && xcodebuild -scheme ${{ env.PACKAGE }} test -destination "platform=macOS"
5060
- name: Test (iOS)
5161
run: cd packages/swift/${{ env.PACKAGE }} && xcodebuild -scheme ${{ env.PACKAGE }} test -destination "platform=iOS Simulator,name=iPhone 16,OS=latest"
62+
- name: Test (macOS)
63+
run: cd packages/swift/${{ env.PACKAGE }} && xcodebuild -scheme ${{ env.PACKAGE }} test -destination "platform=macOS"
5264
- name: Test (Catalyst)
5365
run: cd packages/swift/${{ env.PACKAGE }} && xcodebuild -scheme ${{ env.PACKAGE }} test -destination "platform=macOS,variant=Mac Catalyst"
54-
- name: Commit Package
55-
uses: stefanzweifel/git-auto-commit-action@v5
56-
if: github.event_name == 'push'
57-
with:
58-
commit_message: "Swift CI ${{ env.PACKAGE }} package"
66+

0 commit comments

Comments
 (0)