Skip to content

Commit b32bf23

Browse files
authored
fix: linux ci (#286)
1 parent 77992a7 commit b32bf23

File tree

7 files changed

+84
-10
lines changed

7 files changed

+84
-10
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ env:
2020
SMITHY_SWIFT_CI_DIR: /Users/runner/work/aws-sdk-swift/aws-sdk-swift/target/build/deps/smithy-swift
2121

2222
jobs:
23-
#TODO: add linux compatibility after aws-crt-swift supports Linux appropriately.
2423
ios-compat:
2524
runs-on: macos-11
2625
env:
@@ -72,4 +71,31 @@ jobs:
7271
run: |
7372
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')"
7473
chmod a+x builder.pyz
75-
GIT_ASKPASS="$(pwd)/.github/scripts/git-ci-askpass.sh" 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 }}" ./builder.pyz build -p ${{ env.PACKAGE_NAME }}
74+
GIT_ASKPASS="$(pwd)/.github/scripts/git-ci-askpass.sh" 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 }}" ./builder.pyz build -p ${{ env.PACKAGE_NAME }}
75+
linux-compat:
76+
runs-on: ubuntu-latest
77+
strategy:
78+
matrix:
79+
image:
80+
- aws-crt-swift-5-al2-x64
81+
steps:
82+
- name: Checkout Sources
83+
uses: actions/checkout@v2
84+
- name: Build and Test ${{ env.PACKAGE_NAME }}
85+
env:
86+
CI_USER: ${{ secrets.CI_USER }}
87+
CI_ACCESS_TOKEN: ${{ secrets.CI_ACCESS_TOKEN }}
88+
run: |
89+
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u awslabs --password-stdin
90+
export DOCKER_IMAGE=docker.pkg.github.com/awslabs/aws-crt-builder/${{ matrix.image }}:${{ env.BUILDER_VERSION }}
91+
docker pull $DOCKER_IMAGE
92+
docker run --mount type=bind,source=$(pwd),target=/root/${{ env.PACKAGE_NAME }} \
93+
--env GITHUB_REF \
94+
--env GITHUB_HEAD_REF \
95+
--env CI_USER \
96+
--env CI_ACCESS_TOKEN \
97+
--env GIT_ASKPASS="/root/${{ env.PACKAGE_NAME }}/.github/scripts/git-ci-askpass.sh" \
98+
--env AWS_CRT_SWIFT_CI_DIR="/root/${{ env.PACKAGE_NAME }}/target/build/deps/aws-crt-swift" \
99+
--env AWS_SDK_SWIFT_CI_DIR="/root/${{ env.PACKAGE_NAME }}" \
100+
--env SMITHY_SWIFT_CI_DIR="/root/${{ env.PACKAGE_NAME }}/target/build/deps/smithy-swift" \
101+
$DOCKER_IMAGE build -p ${{ env.PACKAGE_NAME }} --build-dir=/root/${{ env.PACKAGE_NAME }} --spec=downstream

AWSClientRuntime/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM swift:5.4-focal
2+
# TODO: Remove the following 2 lines when repos are public
3+
ARG GIT_ACCESS_TOKEN
4+
RUN git config --global url."https://${GIT_ACCESS_TOKEN}@github.com".insteadOf "https://github.com"
5+
6+
WORKDIR /package
7+
8+
COPY . ./
9+
10+
# to test on al2 swift images uncomment this and comment out other line.
11+
# RUN yum -y install openssl-devel
12+
RUN apt-get update -qq
13+
RUN apt-get -y install libssl-dev
14+
15+
RUN swift package clean
16+
17+
RUN swift build
18+
19+
CMD ["swift", "test", "-Xcc", "-g"]
20+

AWSClientRuntime/Tests/Protocols/RestJSON/RestJSONErrorTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class RestJSONErrorTests: HttpResponseTestBase {
4646
} else {
4747
XCTFail("The deserialized error type does not match expected type")
4848
}
49-
print(try? GreetingWithErrorsError(errorType: nil, httpResponse: httpResponse, decoder: decoder, message: nil, requestID: nil))
5049
}
5150

5251
func testSanitizeErrorName() {

AWSClientRuntime/Tests/UserAgent/UserAgentTests.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,19 @@ class UserAgentTests: XCTestCase {
2525
apiMetadata: apiMeta,
2626
osMetadata: osMeta,
2727
languageMetadata: langMeta)
28-
let expected = "aws-sdk-swift/1.2.3 api/test-service/1.2.3 os/macOS/11.4 lang/swift/9.9"
28+
var expected: String = ""
29+
switch currentOS {
30+
case .linux:
31+
expected = "aws-sdk-swift/1.2.3 api/test-service/1.2.3 os/linux/11.4 lang/swift/9.9"
32+
case .macOS:
33+
expected = "aws-sdk-swift/1.2.3 api/test-service/1.2.3 os/macOS/11.4 lang/swift/9.9"
34+
case .iOS:
35+
expected = "aws-sdk-swift/1.2.3 api/test-service/1.2.3 os/iOS/11.4 lang/swift/9.9"
36+
case .unknown:
37+
expected = "aws-sdk-swift/1.2.3 api/test-service/1.2.3 os/unknown/11.4 lang/swift/9.9"
38+
default:
39+
XCTFail("Unexpected OS")
40+
}
2941
XCTAssert(awsUserAgent.xAmzUserAgent == expected, awsUserAgent.xAmzUserAgent)
3042
}
3143
}

TestLambdaSdk/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM swift:5.4.2-amazonlinux2 as builder
2+
ARG TARGET_NAME
3+
# TODO: Remove the following 2 lines when repos are public
4+
ARG GIT_ACCESS_TOKEN
5+
RUN git config --global url."https://${GIT_ACCESS_TOKEN}@github.com".insteadOf "https://github.com"
6+
RUN yum -y install git jq tar zip openssl-devel
7+
WORKDIR /build-lambda
8+
COPY . ./
9+
RUN swift package clean
10+
RUN swift build
11+

TestLambdaSdk/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let package = Package(
1414
targets: [
1515
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
1616
// Targets can depend on other targets in this package, and on products in packages this package depends on.
17-
.target(
17+
.executableTarget(
1818
name: "TestSdk",
1919
dependencies: [
2020
"S3"

builder.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@
1717
],
1818
"build_dir": "target/build",
1919
"hosts": {
20-
"ubuntu": {
20+
"al2": {
2121
"packages": [
22-
"openjdk-8-jdk-headless"
23-
]
22+
"java-11-amazon-corretto-headless"
23+
],
24+
"env": {
25+
"JAVA_HOME": "/usr/lib/jvm/java-11-amazon-corretto.x86_64"
26+
}
2427
},
2528
"debian": {
2629
"packages": [
27-
"openjdk-8-jdk-headless"
28-
]
30+
"openjdk-11-jdk-headless"
31+
],
32+
"env": {
33+
"JAVA_HOME": "/usr/lib/jvm/openjdk-11-jdk"
34+
}
2935
}
3036
},
3137
"upstream": [

0 commit comments

Comments
 (0)