Skip to content

Commit

Permalink
chore: Improve the iOS CI job (#1000)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbelkins authored Jun 27, 2023
1 parent 7b04329 commit af2f5e4
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 18 deletions.
66 changes: 49 additions & 17 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,65 @@ jobs:
ios-compat:
runs-on: macos-13
env:
DEVELOPER_DIR: /Applications/Xcode_14.3.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_14.3.1.app/Contents/Developer
steps:
- name: Checkout Sources
uses: actions/checkout@v2
- uses: actions/cache@v2
- name: Checkout aws-sdk-swift
uses: actions/checkout@v3
- name: Select smithy-swift branch
run: |
ORIGINAL_REPO_HEAD_REF="$GITHUB_HEAD_REF" \
DEPENDENCY_REPO_URL="https://github.com/awslabs/smithy-swift.git" \
./scripts/ci_steps/select_dependency_branch.sh
- name: Checkout smithy-swift
uses: actions/checkout@v3
with:
repository: awslabs/smithy-swift
ref: ${{ env.DEPENDENCY_REPO_SHA }}
path: smithy-swift
- name: Move smithy-swift into place
run: mv smithy-swift ..
- name: Cache Gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
key: 1-${{ runner.os }}-gradle-${{ hashFiles('settings.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- uses: actions/setup-java@v1
1-${{ runner.os }}-gradle-${{ hashFiles('settings.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
1-${{ runner.os }}-gradle-
- name: Cache Swift
uses: actions/cache@v3
with:
java-version: '11'
path: |
~/Library/Caches/org.swift.swiftpm
~/.cache/org.swift.swiftpm
key: 1-${{ runner.os }}-swift5.8.1-spm-${{ hashFiles('Package.swift', 'AWSSDKSwiftCLI/Package.swift') }}
restore-keys: |
1-${{ runner.os }}-swift5.8.1-spm-${{ hashFiles('Package.swift', 'AWSSDKSwiftCLI/Package.swift') }}
1-${{ runner.os }}-swift5.8.1-spm-
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 17
- name: Setup xcbeautify
run: HOMEBREW_NO_AUTO_UPDATE=1 brew install xcbeautify
- name: Tools Versions
run: ./scripts/ci_steps/log_tool_versions.sh
- name: Prepare Protocol & Unit Tests
run: |
which swiftc
swiftc --version
echo
which xcodebuild
xcodebuild -version
- name: Build and Test ${{ env.PACKAGE_NAME }}
./scripts/ci_steps/prepare_protocol_and_unit_tests.sh
- name: Build and Run Protocol & Unit Tests on iOS Simulator
run: |
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')"
chmod a+x builder.pyz
./builder.pyz build -p ${{ env.PACKAGE_NAME }} --target=ios-armv8
unset SMITHY_SWIFT_CI_DIR
unset AWS_SDK_SWIFT_CI_DIR
set -o pipefail && \
NSUnbufferedIO=YES xcodebuild \
-scheme aws-sdk-swift \
-destination 'platform=iOS Simulator,OS=16.4,name=iPhone 14' \
test 2>&1 \
| xcbeautify
macos-compat:
runs-on: macos-11
env:
Expand Down
11 changes: 10 additions & 1 deletion scripts/ci_steps/log_tool_versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

# Log location & version for swiftc, xcodebuild, java
# Log location & version for swiftc, xcodebuild, java, xcbeautify

if command -v swiftc &> /dev/null
then
Expand Down Expand Up @@ -30,3 +30,12 @@ then
else
echo "java not installed"
fi

if command -v xcbeautify &> /dev/null
then
which xcbeautify
xcbeautify --version
echo
else
echo "xcbeautify not installed"
fi
25 changes: 25 additions & 0 deletions scripts/ci_steps/prepare_protocol_and_unit_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -e

# Delete all generated services & their tests
rm -rf Sources/Services/*
rm -rf Tests/Services/*

# Regenerate the SDK Package.swift without the services and with protocol tests
cd AWSSDKSwiftCLI
swift run AWSSDKSwiftCLI generate-package-manifest --include-protocol-tests ..
cd ..

# Dump the Package.swift contents to the logs
cat Package.swift

# Code-generate protocol tests
./gradlew -p codegen/smithy-aws-swift-codegen build
./gradlew -p codegen/protocol-test-codegen build
./gradlew -p codegen/protocol-test-codegen-local build
./gradlew --stop
./scripts/mergeModels.sh codegen/protocol-test-codegen/build/smithyprojections/protocol-test-codegen/aws-restjson/swift-codegen/AWSRestJsonTestSDK/models

# Run aws-sdk-swift protocol and unit tests as a separate step
# (allows for use of either Xcode or pure Swift toolchains)

0 comments on commit af2f5e4

Please sign in to comment.