Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: CI/CD

on:
push: # A push indicates that a PR is merged and CD should be triggered
branches:
- main
# push: # A push indicates that a PR is merged and CD should be triggered
# branches:
# - main
pull_request: # For PRs, we run CI, which is the same as CD without the release step(s)
branches:
- main
Expand Down Expand Up @@ -54,26 +54,33 @@ jobs:
setup:
runs-on: ubuntu-latest
outputs:
# The packages that use Uniffi bindings
ffi_packages: ${{ steps.set_ffi_packages.outputs.ffi_packages }}
# Swift/FFI jobs (array of objects: crate_name, swift_package)
ffi_packages: ${{ steps.set_matrices.outputs.ffi_packages }}
steps:
- id: set_ffi_packages
run: echo 'ffi_packages=["algokit_transact"]' >> $GITHUB_OUTPUT
- id: set_matrices
run: |
python3 - <<'PY' >> "$GITHUB_OUTPUT"
import json
# Crates that produce FFI bindings
crates = ["algokit_transact"]
items = []
for crate in crates:
pascal = ''.join(p.capitalize() for p in crate.split('_'))
# Brand fixups
pascal = pascal.replace('Algokit', 'AlgoKit')
items.append({"crate_name": crate, "swift_package": pascal})
print('ffi_packages=' + json.dumps(items))
PY

python_uniffi_ci_cd:
swift_ci:
needs:
- setup
uses: ./.github/workflows/python_uniffi_ci_cd.yml
uses: ./.github/workflows/swift_ci.yml
strategy:
matrix:
crate: ${{ fromJSON(needs.setup.outputs.ffi_packages) }}
include: ${{ fromJSON(needs.setup.outputs.ffi_packages) }}
with:
crate: ${{ matrix.crate }}
crate: ${{ matrix.crate_name }}
package: ${{ matrix.swift_package }}
release: ${{ github.event_name == 'push' }}
secrets:
BOT_ID: ${{ secrets.BOT_ID }}
BOT_SK: ${{ secrets.BOT_SK }}
deploy_docs:
# Only run on pushes to main (not on PRs)
if: github.event_name == 'push'
uses: ./.github/workflows/deploy_docs.yml

68 changes: 38 additions & 30 deletions .github/workflows/swift_ci.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,45 @@
name: Swift CI

on:
# Temporarily disable automatic CI for swift while we focus on Python and TS
# push:
# branches:
# - main
# tags:
# - "*"
# pull_request:
# branches:
# - main
workflow_call:
inputs:
crate:
description: "Crate name to build Swift package from"
required: true
type: string
package:
description: "Swift package (Xcode scheme) name"
required: true
type: string
release:
description: "Whether to commit generated package (push only)"
required: false
type: boolean
default: false
workflow_dispatch:
inputs:
crate:
description: "Crate name"
required: true
type: string
default: algokit_transact
package:
description: "Swift package name"
required: true
type: string
default: AlgoKitTransact
release:
description: "Commit generated package"
required: false
type: boolean
default: false

permissions:
contents: write

env:
CRATE: algokit_transact
PACKAGE: AlgoKitTransact
CRATE: ${{ inputs.crate }}
PACKAGE: ${{ inputs.package }}

jobs:
build_and_test:
Expand All @@ -31,28 +53,14 @@ jobs:
with:
toolchain: 1.85.0
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
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Xcode
uses: mxcl/xcodebuild@v3
with:
swift: ^6
action: none
platform: macOS
- name: Install iOS Simulator
run: xcodebuild -downloadPlatform iOS
- name: Build
run: bun scripts/build ${{ env.CRATE }} swift
run: cargo pkg ${{ env.CRATE }} swift

# 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
- name: Test (macOS)
run: cd packages/swift/${{ env.PACKAGE }} && xcodebuild -scheme ${{ env.PACKAGE }} test -destination "platform=macOS"
- name: Test (iOS)
run: cd packages/swift/${{ env.PACKAGE }} && xcodebuild -scheme ${{ env.PACKAGE }} test -destination "platform=iOS Simulator,name=iPhone 16,OS=latest"
- name: Test (macOS)
run: cd packages/swift/${{ env.PACKAGE }} && xcodebuild -scheme ${{ env.PACKAGE }} test -destination "platform=macOS"
- name: Test (Catalyst)
run: cd packages/swift/${{ env.PACKAGE }} && xcodebuild -scheme ${{ env.PACKAGE }} test -destination "platform=macOS,variant=Mac Catalyst"
- name: Commit Package
uses: stefanzweifel/git-auto-commit-action@v5
if: github.event_name == 'push'
with:
commit_message: "Swift CI ${{ env.PACKAGE }} package"

Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@
<array>
<dict>
<key>BinaryPath</key>
<string>libalgokit_transact_ffi.a</string>
<string>libalgokit_transact_ffi-ios-sim.a</string>
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>libalgokit_transact_ffi.a</string>
<string>libalgokit_transact_ffi-ios-sim.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
Expand Down Expand Up @@ -58,22 +61,19 @@
</dict>
<dict>
<key>BinaryPath</key>
<string>libalgokit_transact_ffi-ios-sim.a</string>
<string>libalgokit_transact_ffi.a</string>
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>libalgokit_transact_ffi-ios-sim.a</string>
<string>libalgokit_transact_ffi.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand Down
Loading