Skip to content

Commit 53fbde2

Browse files
authored
chore: Improved downstream task (#568)
1 parent 4d965ac commit 53fbde2

File tree

2 files changed

+152
-26
lines changed

2 files changed

+152
-26
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 119 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,109 @@ on:
77
workflow_dispatch:
88

99
env:
10-
BUILDER_VERSION: v0.9.11
11-
BUILDER_SOURCE: releases
12-
# host owned by CRT team to host aws-crt-builder releases. Contact their on-call with any issues
13-
BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net
14-
PACKAGE_NAME: smithy-swift
15-
LINUX_BASE_IMAGE: ubuntu-16-x64
16-
RUN: ${{ github.run_id }}-${{ github.run_number }}
17-
AWS_SDK_SWIFT_CI_DIR: /Users/runner/work/smithy-swift/smithy-swift/target/build/deps/aws-sdk-swift
18-
AWS_CRT_SWIFT_CI_DIR: /Users/runner/work/smithy-swift/smithy-swift/target/build/deps/aws-crt-swift
19-
SMITHY_SWIFT_CI_DIR: /Users/runner/work/smithy-swift/smithy-swift
10+
AWS_SWIFT_SDK_USE_LOCAL_DEPS: 1
2011

2112
jobs:
2213
downstream:
23-
runs-on: macos-13
14+
runs-on: ${{ matrix.runner }}
2415
env:
25-
DEVELOPER_DIR: /Applications/Xcode_14.3.app/Contents/Developer
16+
DEVELOPER_DIR: /Applications/${{ matrix.xcode }}.app/Contents/Developer
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
# This matrix runs tests on iOS sim & Mac, on oldest & newest supported Xcodes
21+
runner:
22+
- macos-12
23+
- macos-13
24+
xcode:
25+
- Xcode_14.0.1
26+
- Xcode_15.0
27+
destination:
28+
- 'platform=iOS Simulator,OS=16.0,name=iPhone 13'
29+
- 'platform=iOS Simulator,OS=17.0,name=iPhone 15'
30+
- 'platform=OS X'
31+
exclude:
32+
# Don't run old macOS with new Xcode
33+
- runner: macos-12
34+
xcode: Xcode_15.0
35+
# Don't run new macOS with old Xcode
36+
- runner: macos-13
37+
xcode: Xcode_14.0.1
38+
# Don't run old iOS simulator with new Xcode
39+
- destination: 'platform=iOS Simulator,OS=16.0,name=iPhone 13'
40+
xcode: Xcode_15.0
41+
# Don't run new iOS simulator with old Xcode
42+
- destination: 'platform=iOS Simulator,OS=17.0,name=iPhone 15'
43+
xcode: Xcode_14.0.1
2644
steps:
27-
- name: Checkout sources
45+
- name: Checkout smithy-swift
2846
uses: actions/checkout@v3
29-
- uses: actions/cache@v3
47+
- name: Select aws-sdk-swift branch
48+
run: |
49+
ORIGINAL_REPO_HEAD_REF="$GITHUB_HEAD_REF" \
50+
DEPENDENCY_REPO_URL="https://github.com/awslabs/aws-sdk-swift.git" \
51+
./scripts/ci_steps/select_dependency_branch.sh
52+
- name: Checkout aws-sdk-swift
53+
uses: actions/checkout@v3
54+
with:
55+
repository: awslabs/aws-sdk-swift
56+
ref: ${{ env.DEPENDENCY_REPO_SHA }}
57+
path: aws-sdk-swift
58+
- name: Move aws-sdk-swift into place
59+
run: mv aws-sdk-swift ..
60+
- name: Cache Gradle
61+
uses: actions/cache@v3
3062
with:
3163
path: |
3264
~/.gradle/caches
3365
~/.gradle/wrapper
34-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
66+
key: 1-${{ runner.os }}-gradle-${{ hashFiles('settings.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
67+
restore-keys: |
68+
1-${{ runner.os }}-gradle-${{ hashFiles('settings.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
69+
1-${{ runner.os }}-gradle-
70+
- name: Cache Swift
71+
uses: actions/cache@v3
72+
with:
73+
path: |
74+
~/Library/Caches/org.swift.swiftpm
75+
~/.cache/org.swift.swiftpm
76+
key: 1-${{ runner.os }}-${{ matrix.xcode }}-spm-${{ hashFiles('Package.swift') }}
3577
restore-keys: |
36-
${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
37-
${{ runner.os }}-gradle-
38-
- uses: actions/setup-java@v3
78+
1-${{ runner.os }}-${{ matrix.xcode }}-spm-${{ hashFiles('Package.swift') }}
79+
1-${{ runner.os }}-${{ matrix.xcode }}-spm-
80+
- name: Setup Java
81+
uses: actions/setup-java@v3
3982
with:
4083
distribution: corretto
4184
java-version: 17
42-
- name: Build and Test ${{ env.PACKAGE_NAME }} Downstream Consumers
85+
- name: Tools Versions
86+
run: |
87+
cd ../aws-sdk-swift
88+
./scripts/ci_steps/log_tool_versions.sh
89+
- name: Build & Run smithy-swift Kotlin Unit Tests
90+
run: ./gradlew build
91+
- name: Build & Run smithy-swift Swift Unit Tests
92+
run: |
93+
set -o pipefail && \
94+
NSUnbufferedIO=YES xcodebuild \
95+
-scheme smithy-swift-Package \
96+
-destination '${{ matrix.destination }}' \
97+
test 2>&1 \
98+
| xcpretty
99+
- name: Prepare aws-sdk-swift Protocol & Unit Tests
43100
run: |
44-
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')"
45-
chmod a+x builder
46-
AWS_CRT_SWIFT_CI_DIR="${{ env.AWS_CRT_SWIFT_CI_DIR }}" AWS_SDK_SWIFT_CI_DIR="${{ env.AWS_SDK_SWIFT_CI_DIR }}" SMITHY_SWIFT_CI_DIR="${{ env.SMITHY_SWIFT_CI_DIR }}" AWS_SWIFT_SDK_USE_LOCAL_DEPS=1 ./builder build -p ${{ env.PACKAGE_NAME }} --spec downstream
101+
cd ../aws-sdk-swift
102+
./scripts/ci_steps/prepare_protocol_and_unit_tests.sh
103+
- name: Build and Run aws-sdk-swift Protocol & Unit Tests
104+
run: |
105+
cd ../aws-sdk-swift
106+
set -o pipefail && \
107+
NSUnbufferedIO=YES xcodebuild \
108+
-scheme aws-sdk-swift \
109+
-destination '${{ matrix.destination }}' \
110+
test 2>&1 \
111+
| xcpretty
112+
47113
linux:
48114
runs-on: ubuntu-latest
49115
strategy:
@@ -57,14 +123,41 @@ jobs:
57123
container:
58124
image: swift:${{ matrix.swift }}
59125
steps:
126+
- name: Checkout Sources
127+
uses: actions/checkout@v3
60128
- name: Install openssl
61129
run: |
62130
if [ -x "$(command -v apt)" ]; then
63131
apt-get update && apt-get install -y libssl-dev
64132
else
65-
yum install -y openssl-devel
133+
yum install -y openssl-devel which
66134
fi
67-
- name: Checkout Sources
68-
uses: actions/checkout@v3
69-
- name: Build and Test
135+
- name: Cache Gradle
136+
uses: actions/cache@v3
137+
with:
138+
path: |
139+
~/.gradle/caches
140+
~/.gradle/wrapper
141+
key: 1-${{ runner.os }}-gradle-${{ hashFiles('settings.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
142+
restore-keys: |
143+
1-${{ runner.os }}-gradle-${{ hashFiles('settings.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
144+
1-${{ runner.os }}-gradle-
145+
- name: Cache Swift
146+
uses: actions/cache@v3
147+
with:
148+
path: |
149+
~/Library/Caches/org.swift.swiftpm
150+
~/.cache/org.swift.swiftpm
151+
key: 1-${{ runner.os }}-${{ matrix.xcode }}-spm-${{ hashFiles('Package.swift') }}
152+
restore-keys: |
153+
1-${{ runner.os }}-${{ matrix.xcode }}-spm-${{ hashFiles('Package.swift') }}
154+
1-${{ runner.os }}-${{ matrix.xcode }}-spm-
155+
- name: Setup Java
156+
uses: actions/setup-java@v3
157+
with:
158+
distribution: corretto
159+
java-version: 17
160+
- name: Build & Run Kotlin Unit Tests
161+
run: ./gradlew build
162+
- name: Build & Run Swift Unit Tests
70163
run: swift test
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# This script selects the Git reference for a locally installed dependency of another "original" repo.
6+
# It matches the original's checked-out branch name if available, and if not, falls back to main.
7+
8+
# Checks to see if Git repository at DEPENDENCY_REPO_URL has a branch named ORIGINAL_REPO_HEAD_REF.
9+
# If so, the latest SHA for that branch is obtained and stored as DEPENDENCY_REPO_SHA in the Github env.
10+
#
11+
# If a branch named ORIGINAL_REPO_HEAD_REF does not exist in the Git repository at DEPENDENCY_REPO_URL,
12+
# the SHA for the main branch is obtained and stored as DEPENDENCY_REPO_SHA in the Github env.
13+
14+
# Parameters:
15+
# ORIGINAL_REPO_HEAD_REF : the branch or tag name for the original repo branch being built.
16+
# DEPENDENCY_REPO_URL : the URL to the dependency that will be matched to the branch
17+
18+
# Output:
19+
# DEPENDENCY_REPO_SHA : the Git SHA for the dependency repo commit to be built (set in the Github environment)
20+
21+
echo "Finding correct branch for dependency repo: $DEPENDENCY_REPO_URL"
22+
DEPENDENCY_BRANCH_SHA=`git ls-remote --heads "$DEPENDENCY_REPO_URL" "refs/heads/$ORIGINAL_REPO_HEAD_REF" | awk '{print $1}'`
23+
if [[ ! -z "${DEPENDENCY_BRANCH_SHA}" ]]; then
24+
echo "Ref $ORIGINAL_REPO_HEAD_REF was found on dependency repo at SHA $DEPENDENCY_BRANCH_SHA"
25+
echo "Selecting dependency repo branch $ORIGINAL_REPO_HEAD_REF at $DEPENDENCY_BRANCH_SHA"
26+
echo "DEPENDENCY_REPO_SHA=$DEPENDENCY_BRANCH_SHA" >> "$GITHUB_ENV"
27+
else
28+
echo "Ref $ORIGINAL_REPO_HEAD_REF was not found on dependency repo at SHA $DEPENDENCY_BRANCH_SHA"
29+
DEPENDENCY_MAIN_SHA=`git ls-remote --heads "$ORIGINAL_REPO_HEAD_REF" "refs/heads/main" | awk '{print $1}'`
30+
echo "Selecting dependency repo main branch at $DEPENDENCY_MAIN_SHA"
31+
echo "DEPENDENCY_REPO_SHA=$DEPENDENCY_MAIN_SHA" >> "$GITHUB_ENV"
32+
fi
33+

0 commit comments

Comments
 (0)