Skip to content

Commit

Permalink
chore: Make GH workflows pass in staging & refactor using composite a…
Browse files Browse the repository at this point in the history
…ctions (#1848)

* Update workflows so they pass in staging repo too.

* Use composite action to reduce duplication

---------

Co-authored-by: Sichan Yoo <[email protected]>
  • Loading branch information
sichanyoo and Sichan Yoo authored Dec 24, 2024
1 parent f08b058 commit 7ed9099
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 99 deletions.
51 changes: 51 additions & 0 deletions .github/actions/checkout-smithy-swift-composite-action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'Checkout smithy-swift composite action'
description: 'A composite action that sets up smithy-swift for the workflow.'
inputs:
AUTOMATION_USER_SSH_PRIVATE_KEY:
description: 'SSH private key for the automation user'
required: true
STAGING_PARTNER_REPO:
description: 'The staging partner repository'
required: true
runs:
using: 'composite'
steps:
- name: Set up SSH key
if: ${{ github.repository != 'awslabs/aws-sdk-swift' }}
run: |
mkdir -p ~/.ssh
echo "${{ inputs.AUTOMATION_USER_SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
shell: bash
- name: Select staging smithy-swift branch
if: ${{ github.repository != 'awslabs/aws-sdk-swift' }}
run: |
cd aws-sdk-swift
ORIGINAL_REPO_HEAD_REF="$GITHUB_HEAD_REF" \
DEPENDENCY_REPO_URL="[email protected]:${{ inputs.STAGING_PARTNER_REPO }}.git" \
./scripts/ci_steps/select_dependency_branch.sh
shell: bash
- name: Checkout staging smithy-swift
if: ${{ github.repository != 'awslabs/aws-sdk-swift' }}
uses: actions/checkout@v4
with:
repository: ${{ inputs.STAGING_PARTNER_REPO }}
ref: ${{ env.DEPENDENCY_REPO_SHA }}
path: smithy-swift
ssh-key: ${{ inputs.AUTOMATION_USER_SSH_PRIVATE_KEY }}
- name: Select smithy-swift branch
if: ${{ github.repository == 'awslabs/aws-sdk-swift' }}
run: |
cd aws-sdk-swift
ORIGINAL_REPO_HEAD_REF="$GITHUB_HEAD_REF" \
DEPENDENCY_REPO_URL="https://github.com/smithy-lang/smithy-swift.git" \
./scripts/ci_steps/select_dependency_branch.sh
shell: bash
- name: Checkout smithy-swift
if: ${{ github.repository == 'awslabs/aws-sdk-swift' }}
uses: actions/checkout@v4
with:
repository: smithy-lang/smithy-swift
ref: ${{ env.DEPENDENCY_REPO_SHA }}
path: smithy-swift
40 changes: 20 additions & 20 deletions .github/workflows/codegen-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,16 @@ jobs:
DEVELOPER_DIR: /Applications/Xcode_16.1.app/Contents/Developer
steps:
- name: Checkout aws-sdk-swift
uses: actions/checkout@v3
- name: Select smithy-swift branch
run: |
ORIGINAL_REPO_HEAD_REF="${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}" \
DEPENDENCY_REPO_URL="https://github.com/smithy-lang/smithy-swift.git" \
./scripts/ci_steps/select_dependency_branch.sh
- name: Checkout smithy-swift
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: aws-sdk-swift
- name: Checkout smithy-swift with composite action
uses: ./aws-sdk-swift/.github/actions/checkout-smithy-swift-composite-action
with:
repository: smithy-lang/smithy-swift
ref: ${{ env.DEPENDENCY_REPO_SHA }}
path: smithy-swift
- name: Move smithy-swift into place
run: mv smithy-swift ..
AUTOMATION_USER_SSH_PRIVATE_KEY: ${{ secrets.AUTOMATION_USER_SSH_PRIVATE_KEY }}
STAGING_PARTNER_REPO: ${{ secrets.STAGING_PARTNER_REPO }}
- name: Cache Gradle
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
Expand All @@ -44,7 +38,7 @@ jobs:
2-${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
2-${{ runner.os }}-gradle-
- name: Cache Swift
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/Library/Caches/org.swift.swiftpm
Expand All @@ -54,15 +48,21 @@ jobs:
1-${{ runner.os }}-${{ matrix.xcode }}-${{ hashFiles('Package.swift', 'AWSSDKSwiftCLI/Package.swift') }}
1-${{ runner.os }}-${{ matrix.xcode }}-
- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 17
- name: Tools Versions
run: ./scripts/ci_steps/log_tool_versions.sh
run: ./aws-sdk-swift/scripts/ci_steps/log_tool_versions.sh
- name: Code-Generate SDK
run: ./scripts/ci_steps/codegen_sdk.sh
run: |
cd aws-sdk-swift
./scripts/ci_steps/codegen_sdk.sh
- name: Build SDK with Unit Tests
run: swift build --build-tests
run: |
cd aws-sdk-swift
swift build --build-tests
- name: Run Unit Tests
run: swift test --skip-build
run: |
cd aws-sdk-swift
swift test --skip-build
65 changes: 29 additions & 36 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,13 @@ jobs:
sudo xcodebuild -runFirstLaunch
- name: Checkout aws-sdk-swift
uses: actions/checkout@v4
- name: Select smithy-swift branch
run: |
ORIGINAL_REPO_HEAD_REF="$GITHUB_HEAD_REF" \
DEPENDENCY_REPO_URL="https://github.com/smithy-lang/smithy-swift.git" \
./scripts/ci_steps/select_dependency_branch.sh
- name: Checkout smithy-swift
uses: actions/checkout@v4
with:
repository: smithy-lang/smithy-swift
ref: ${{ env.DEPENDENCY_REPO_SHA }}
path: smithy-swift
- name: Move smithy-swift into place
run: mv smithy-swift ..
path: aws-sdk-swift
- name: Checkout smithy-swift with composite action
uses: ./aws-sdk-swift/.github/actions/checkout-smithy-swift-composite-action
with:
AUTOMATION_USER_SSH_PRIVATE_KEY: ${{ secrets.AUTOMATION_USER_SSH_PRIVATE_KEY }}
STAGING_PARTNER_REPO: ${{ secrets.STAGING_PARTNER_REPO }}
- name: Cache Gradle
uses: actions/cache@v4
with:
Expand All @@ -103,20 +97,22 @@ jobs:
distribution: corretto
java-version: 17
- name: Tools Versions
run: ./scripts/ci_steps/log_tool_versions.sh
run: ./aws-sdk-swift/scripts/ci_steps/log_tool_versions.sh
- name: Run CLI Unit Tests
if: ${{ matrix.destination == 'platform=macOS' }}
run: |
cd AWSSDKSwiftCLI
cd aws-sdk-swift/AWSSDKSwiftCLI
swift test
cd ../SPRCLI
unset AWS_SWIFT_SDK_USE_LOCAL_DEPS
swift build
- name: Prepare Protocol & Unit Tests
run: |
cd aws-sdk-swift
./scripts/ci_steps/prepare_protocol_and_unit_tests.sh
- name: Build and Run Unit Tests
run: |
cd aws-sdk-swift
set -o pipefail && \
NSUnbufferedIO=YES xcodebuild \
-scheme aws-sdk-swift-Package \
Expand All @@ -125,7 +121,7 @@ jobs:
| xcbeautify
- name: Build and Run Protocol Tests
run: |
cd codegen/
cd aws-sdk-swift/codegen/
set -o pipefail && \
NSUnbufferedIO=YES xcodebuild \
-scheme aws-sdk-swift-protocol-tests-Package \
Expand All @@ -150,22 +146,16 @@ jobs:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
steps:
- name: Checkout aws-sdk-swift
uses: actions/checkout@v3
- name: Select smithy-swift branch
run: |
ORIGINAL_REPO_HEAD_REF="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME:-main}}" \
DEPENDENCY_REPO_URL="https://github.com/smithy-lang/smithy-swift.git" \
./scripts/ci_steps/select_dependency_branch.sh
- name: Checkout smithy-swift
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: aws-sdk-swift
- name: Checkout smithy-swift with composite action
uses: ./aws-sdk-swift/.github/actions/checkout-smithy-swift-composite-action
with:
repository: smithy-lang/smithy-swift
ref: ${{ env.DEPENDENCY_REPO_SHA }}
path: smithy-swift
- name: Move smithy-swift into place
run: mv smithy-swift ..
AUTOMATION_USER_SSH_PRIVATE_KEY: ${{ secrets.AUTOMATION_USER_SSH_PRIVATE_KEY }}
STAGING_PARTNER_REPO: ${{ secrets.STAGING_PARTNER_REPO }}
- name: Cache Gradle
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
Expand All @@ -175,7 +165,7 @@ jobs:
2-${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
2-${{ runner.os }}-gradle-
- name: Cache Swift
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/Library/Caches/org.swift.swiftpm
Expand All @@ -185,28 +175,31 @@ jobs:
1-${{ runner.os }}-swift-${{ matrix.version }}-spm-${{ hashFiles('Package.swift', 'AWSSDKSwiftCLI/Package.swift') }}
1-${{ runner.os }}-swift-${{ matrix.version }}-spm-
- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 17
- name: Install OpenSSL (all OS) and which (AL2 only)
run: ./scripts/ci_steps/install_native_linux_dependencies.sh
run: ./aws-sdk-swift/scripts/ci_steps/install_native_linux_dependencies.sh
- name: Tools Versions
run: ./scripts/ci_steps/log_tool_versions.sh
run: ./aws-sdk-swift/scripts/ci_steps/log_tool_versions.sh
- name: Run CLI Unit Tests
run: |
cd AWSSDKSwiftCLI
cd aws-sdk-swift/AWSSDKSwiftCLI
swift test
cd ../SPRCLI
unset AWS_SWIFT_SDK_USE_LOCAL_DEPS
swift build
- name: Prepare Protocol & Unit Tests
run: |
cd aws-sdk-swift
./scripts/ci_steps/prepare_protocol_and_unit_tests.sh
- name: Build and Run Unit Tests on Linux
run: swift test
run: |
cd aws-sdk-swift
swift test
- name: Build and Run Protocol Tests on Linux
run: |
cd codegen/
cd aws-sdk-swift/codegen/
swift test
cd ..
Loading

0 comments on commit 7ed9099

Please sign in to comment.