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 (#886)

* Adjust CI GitHub workflows so it works in staging repo as well.

* Add missing cd command

* Bring in composite action refactor

* Rename composite action

---------

Co-authored-by: Sichan Yoo <chanyoo@amazon.com>
  • Loading branch information
sichanyoo and Sichan Yoo authored Dec 24, 2024
1 parent d51fb5d commit fac5c3a
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 138 deletions.
51 changes: 51 additions & 0 deletions .github/actions/checkout-aws-sdk-swift-composite-action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'Checkout aws-sdk-swift composite action'
description: 'A composite action that sets up aws-sdk-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 != 'smithy-lang/smithy-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 aws-sdk-swift branch
if: ${{ github.repository != 'smithy-lang/smithy-swift' }}
run: |
cd smithy-swift
ORIGINAL_REPO_HEAD_REF="$GITHUB_HEAD_REF" \
DEPENDENCY_REPO_URL="git@github.com:${{ inputs.STAGING_PARTNER_REPO }}.git" \
./scripts/ci_steps/select_dependency_branch.sh
shell: bash
- name: Checkout staging aws-sdk-swift
if: ${{ github.repository != 'smithy-lang/smithy-swift' }}
uses: actions/checkout@v4
with:
repository: ${{ inputs.STAGING_PARTNER_REPO }}
ref: ${{ env.DEPENDENCY_REPO_SHA }}
path: aws-sdk-swift
ssh-key: ${{ inputs.AUTOMATION_USER_SSH_PRIVATE_KEY }}
- name: Select aws-sdk-swift branch
if: ${{ github.repository == 'smithy-lang/smithy-swift' }}
run: |
cd smithy-swift
ORIGINAL_REPO_HEAD_REF="$GITHUB_HEAD_REF" \
DEPENDENCY_REPO_URL="https://github.com/awslabs/aws-sdk-swift.git" \
./scripts/ci_steps/select_dependency_branch.sh
shell: bash
- name: Checkout aws-sdk-swift
if: ${{ github.repository == 'smithy-lang/smithy-swift' }}
uses: actions/checkout@v4
with:
repository: awslabs/aws-sdk-swift
ref: ${{ env.DEPENDENCY_REPO_SHA }}
path: aws-sdk-swift
30 changes: 30 additions & 0 deletions .github/actions/setup-common-tools-composite-action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: 'Setup Common Tools'
description: 'A composite action that caches Gradle, caches Swift, and sets up Java.'
runs:
using: 'composite'
steps:
- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: 1-${{ runner.os }}-gradle-${{ hashFiles('settings.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
1-${{ runner.os }}-gradle-${{ hashFiles('settings.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
1-${{ runner.os }}-gradle-
- name: Cache Swift
uses: actions/cache@v4
with:
path: |
~/Library/Caches/org.swift.swiftpm
~/.cache/org.swift.swiftpm
key: 1-${{ runner.os }}-${{ matrix.xcode }}-spm-${{ hashFiles('Package.swift') }}
restore-keys: |
1-${{ runner.os }}-${{ matrix.xcode }}-spm-${{ hashFiles('Package.swift') }}
1-${{ runner.os }}-${{ matrix.xcode }}-spm-
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 17
168 changes: 30 additions & 138 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,8 @@ jobs:
sudo xcodebuild -runFirstLaunch
- name: Checkout smithy-swift
uses: actions/checkout@v4
- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: 1-${{ runner.os }}-gradle-${{ hashFiles('settings.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
1-${{ runner.os }}-gradle-${{ hashFiles('settings.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
1-${{ runner.os }}-gradle-
- name: Cache Swift
uses: actions/cache@v4
with:
path: |
~/Library/Caches/org.swift.swiftpm
~/.cache/org.swift.swiftpm
key: 1-${{ runner.os }}-${{ matrix.xcode }}-spm-${{ hashFiles('Package.swift') }}
restore-keys: |
1-${{ runner.os }}-${{ matrix.xcode }}-spm-${{ hashFiles('Package.swift') }}
1-${{ runner.os }}-${{ matrix.xcode }}-spm-
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 17
- name: Setup common tools
uses: ./.github/actions/setup-common-tools-composite-action
- name: Build & Run smithy-swift Kotlin Unit Tests
run: ./gradlew build
- name: Build & Run smithy-swift Swift Unit Tests
Expand Down Expand Up @@ -159,55 +136,24 @@ jobs:
sudo xcodebuild -runFirstLaunch
- name: Checkout smithy-swift
uses: actions/checkout@v4
- name: Select aws-sdk-swift branch
run: |
ORIGINAL_REPO_HEAD_REF="$GITHUB_HEAD_REF" \
DEPENDENCY_REPO_URL="https://github.com/awslabs/aws-sdk-swift.git" \
./scripts/ci_steps/select_dependency_branch.sh
- name: Checkout aws-sdk-swift
uses: actions/checkout@v4
with:
repository: awslabs/aws-sdk-swift
ref: ${{ env.DEPENDENCY_REPO_SHA }}
path: aws-sdk-swift
- name: Move aws-sdk-swift into place
run: mv aws-sdk-swift ..
- name: Cache Gradle
uses: actions/cache@v4
path: smithy-swift
- name: Checkout aws-sdk-swift with composite action
uses: ./smithy-swift/.github/actions/checkout-aws-sdk-swift-composite-action
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: 1-${{ runner.os }}-gradle-${{ hashFiles('settings.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
1-${{ runner.os }}-gradle-${{ hashFiles('settings.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
1-${{ runner.os }}-gradle-
- name: Cache Swift
uses: actions/cache@v4
with:
path: |
~/Library/Caches/org.swift.swiftpm
~/.cache/org.swift.swiftpm
key: 1-${{ runner.os }}-${{ matrix.xcode }}-spm-${{ hashFiles('Package.swift') }}
restore-keys: |
1-${{ runner.os }}-${{ matrix.xcode }}-spm-${{ hashFiles('Package.swift') }}
1-${{ runner.os }}-${{ matrix.xcode }}-spm-
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 17
AUTOMATION_USER_SSH_PRIVATE_KEY: ${{ secrets.AUTOMATION_USER_SSH_PRIVATE_KEY }}
STAGING_PARTNER_REPO: ${{ secrets.STAGING_PARTNER_REPO }}
- name: Setup common tools
uses: ./smithy-swift/.github/actions/setup-common-tools-composite-action
- name: Tools Versions
run: |
cd ../aws-sdk-swift
./scripts/ci_steps/log_tool_versions.sh
run: ./aws-sdk-swift/scripts/ci_steps/log_tool_versions.sh
- name: Prepare aws-sdk-swift Protocol & Unit Tests
run: |
cd ../aws-sdk-swift
cd aws-sdk-swift
./scripts/ci_steps/prepare_protocol_and_unit_tests.sh
- name: Build and Run aws-sdk-swift Unit Tests
run: |
cd ../aws-sdk-swift
cd aws-sdk-swift
set -o pipefail && \
NSUnbufferedIO=YES xcodebuild \
-scheme aws-sdk-swift-Package \
Expand All @@ -216,7 +162,7 @@ jobs:
| xcbeautify
- name: Build and Run aws-sdk-swift Protocol Tests
run: |
cd ../aws-sdk-swift/codegen
cd aws-sdk-swift/codegen
set -o pipefail && \
NSUnbufferedIO=YES xcodebuild \
-scheme aws-sdk-swift-protocol-tests-Package \
Expand All @@ -238,40 +184,17 @@ jobs:
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
steps:
- name: Checkout Sources
uses: actions/checkout@v3
- name: Checkout smithy-swift
uses: actions/checkout@v4
- name: Install openssl
run: |
if [ -x "$(command -v apt)" ]; then
apt-get update && apt-get install -y libssl-dev
else
yum install -y openssl-devel which
fi
- name: Cache Gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: 1-${{ runner.os }}-gradle-${{ hashFiles('settings.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
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:
path: |
~/Library/Caches/org.swift.swiftpm
~/.cache/org.swift.swiftpm
key: 1-${{ runner.os }}-${{ matrix.xcode }}-spm-${{ hashFiles('Package.swift') }}
restore-keys: |
1-${{ runner.os }}-${{ matrix.xcode }}-spm-${{ hashFiles('Package.swift') }}
1-${{ runner.os }}-${{ matrix.xcode }}-spm-
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 17
- name: Setup common tools
uses: ./.github/actions/setup-common-tools-composite-action
- name: Build & Run Kotlin Unit Tests
run: ./gradlew build
- name: Build & Run Swift Unit Tests
Expand All @@ -291,70 +214,39 @@ jobs:
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
steps:
- name: Checkout Sources
uses: actions/checkout@v3
- name: Select aws-sdk-swift branch
run: |
ORIGINAL_REPO_HEAD_REF="$GITHUB_HEAD_REF" \
DEPENDENCY_REPO_URL="https://github.com/awslabs/aws-sdk-swift.git" \
./scripts/ci_steps/select_dependency_branch.sh
- name: Checkout aws-sdk-swift
uses: actions/checkout@v3
with:
repository: awslabs/aws-sdk-swift
ref: ${{ env.DEPENDENCY_REPO_SHA }}
path: aws-sdk-swift
- name: Move aws-sdk-swift into place
run: mv aws-sdk-swift ..
- name: Install openssl
run: |
if [ -x "$(command -v apt)" ]; then
apt-get update && apt-get install -y libssl-dev
else
yum install -y openssl-devel which
fi
- name: Cache Gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: 1-${{ runner.os }}-gradle-${{ hashFiles('settings.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
1-${{ runner.os }}-gradle-${{ hashFiles('settings.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
1-${{ runner.os }}-gradle-
- name: Cache Swift
uses: actions/cache@v3
- name: Checkout smithy-swift
uses: actions/checkout@v4
with:
path: |
~/Library/Caches/org.swift.swiftpm
~/.cache/org.swift.swiftpm
key: 1-${{ runner.os }}-${{ matrix.xcode }}-spm-${{ hashFiles('Package.swift') }}
restore-keys: |
1-${{ runner.os }}-${{ matrix.xcode }}-spm-${{ hashFiles('Package.swift') }}
1-${{ runner.os }}-${{ matrix.xcode }}-spm-
- name: Setup Java
uses: actions/setup-java@v3
path: smithy-swift
- name: Checkout aws-sdk-swift with composite action
uses: ./smithy-swift/.github/actions/checkout-aws-sdk-swift-composite-action
with:
distribution: corretto
java-version: 17
AUTOMATION_USER_SSH_PRIVATE_KEY: ${{ secrets.AUTOMATION_USER_SSH_PRIVATE_KEY }}
STAGING_PARTNER_REPO: ${{ secrets.STAGING_PARTNER_REPO }}
- name: Setup common tools
uses: ./smithy-swift/.github/actions/setup-common-tools-composite-action
- name: Tools Versions
run: |
cd ../aws-sdk-swift
./scripts/ci_steps/log_tool_versions.sh
run: ./aws-sdk-swift/scripts/ci_steps/log_tool_versions.sh
- name: Prepare aws-sdk-swift Protocol & Unit Tests
run: |
cd ../aws-sdk-swift
cd aws-sdk-swift
./scripts/ci_steps/prepare_protocol_and_unit_tests.sh
- name: Build and Run aws-sdk-swift Unit Tests
run: |
cd ../aws-sdk-swift
cd aws-sdk-swift
swift test
- name: Build and Run aws-sdk-swift Protocol Tests
run: |
export AWS_REGION=us-west-2
export AWS_ACCESS_KEY_ID=test-key-id
export AWS_SECRET_ACCESS_KEY=test-secret-access-key
cd ../aws-sdk-swift/codegen
cd aws-sdk-swift/codegen
swift test

0 comments on commit fac5c3a

Please sign in to comment.