Repository navigation
ci(native): build and test the native Swift packages on macOS #7984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # Copyright (c) Meta Platforms, Inc. and affiliates. | ||
|
|
||
| # Native Swift: builds and tests every Swift package in @astryxdesign/native | ||
| # (AST-082) on macOS, for macOS and the iOS Simulator. The package is | ||
| # experimental and canary-only. Its contract drift check runs with the rest of | ||
| # the package in the Node tests; this lane is where its Swift compiles and its | ||
| # Swift tests run. | ||
| name: Native Swift | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: ['main'] | ||
| paths: | ||
| - 'packages/native/**/*.swift' | ||
| - 'packages/native/**/Package.swift' | ||
| - '.github/workflows/native-swift.yml' | ||
| push: | ||
| branches: ['main'] | ||
| paths: | ||
| - 'packages/native/**/*.swift' | ||
| - 'packages/native/**/Package.swift' | ||
| - '.github/workflows/native-swift.yml' | ||
|
|
||
| permissions: {} | ||
|
|
||
| concurrency: | ||
| group: 'native-swift-${{ github.head_ref || github.run_id }}' | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| swift: | ||
| runs-on: macos-15 | ||
| timeout-minutes: 30 | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
|
|
||
| - name: Show the toolchain | ||
| run: | | ||
| xcodebuild -version | ||
| swift --version | ||
|
|
||
| # One package per directory that holds a Package.swift, such as apple/ | ||
| # (generated contracts) and each versioned swift-ios-<n>/. A package | ||
| # that supports macOS runs its tests there; every package builds for | ||
| # the iOS Simulator, and an iOS-only package runs its tests there. | ||
| - name: Build and test each package | ||
| run: | | ||
| set -euo pipefail | ||
| packages=$(find packages/native -name Package.swift -not -path '*/.build/*' -not -path '*/node_modules/*' -exec dirname {} \; | sort) | ||
| if [ -z "$packages" ]; then | ||
| echo 'No Swift package found under packages/native.' | ||
| exit 1 | ||
| fi | ||
| for package in $packages; do | ||
| echo "::group::$package" | ||
| ( | ||
| cd "$package" | ||
| swift package dump-package > "$RUNNER_TEMP/package.json" | ||
| read -r macos tests < <(python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); print(any(p["platformName"]=="macos" for p in d.get("platforms",[])) or not d.get("platforms"), any(t["type"]=="test" for t in d["targets"]))' "$RUNNER_TEMP/package.json") | ||
| # Xcode names the whole-package scheme <name>-Package when a | ||
| # package has several products, and after its product otherwise. | ||
| xcodebuild -list -json > "$RUNNER_TEMP/schemes.json" | ||
| scheme=$(python3 -c 'import json,sys; s=json.load(open(sys.argv[1]))["workspace"]["schemes"]; print(next((x for x in s if x.endswith("-Package")), s[0]))' "$RUNNER_TEMP/schemes.json") | ||
| if [ "$macos" = True ]; then | ||
| swift test | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| xcodebuild build -scheme "$scheme" -destination 'generic/platform=iOS Simulator' -quiet | ||
| elif [ "$tests" = True ]; then | ||
| xcodebuild test -scheme "$scheme" -destination 'platform=iOS Simulator,name=iPhone 16' -quiet | ||
| else | ||
| xcodebuild build -scheme "$scheme" -destination 'generic/platform=iOS Simulator' -quiet | ||
| fi | ||
| ) | ||
| echo '::endgroup::' | ||
| done | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
pull_requestpath filter makes the Swift build a separately routed lane. The CI classifier already routespackages/native/**toshared-or-unknown, and AST-030 FR11 says new coverage inside an existing surface must join that owner instead of creating a separately routed lane. Consider running this job from the broad lane inci.yml, added to thetestjoin, or admitting a native surface through an FR10 amendment first. Thepush: maintrigger below is outside AST-030's scope.