Skip to content

Commit d9012cc

Browse files
feat(codegen): test non-AWS client builds (#2876)
1 parent 99d9267 commit d9012cc

File tree

5 files changed

+161
-0
lines changed

5 files changed

+161
-0
lines changed

Diff for: .github/workflows/generic-client-tests.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: generic-client-tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- uses: actions/setup-java@v1
17+
with:
18+
java-version: '11'
19+
20+
- uses: actions/setup-node@v2
21+
with:
22+
node-version: '14'
23+
cache: 'yarn'
24+
25+
- name: build and publish smithy-typescript
26+
run: |
27+
git clone --depth 1 https://github.com/awslabs/smithy-typescript.git
28+
cd smithy-typescript
29+
./gradlew clean build publishToMavenLocal
30+
cd ..
31+
32+
- name: build codegen and generate generic client
33+
run: |
34+
cd codegen
35+
./gradlew clean smithy-aws-typescript-codegen:build generic-client-test-codegen:build
36+
37+
- name: build generic client
38+
run: |
39+
cd codegen/generic-client-test-codegen/build/smithyprojections/generic-client-test-codegen/aws-echo-service/typescript-codegen/
40+
yarn install && yarn build

Diff for: codegen/generic-client-test-codegen/build.gradle.kts

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
import software.amazon.smithy.gradle.tasks.SmithyBuild
17+
18+
plugins {
19+
id("software.amazon.smithy") version "0.5.3"
20+
}
21+
22+
dependencies {
23+
implementation("software.amazon.smithy:smithy-aws-protocol-tests:[1.11.0, 1.12.0[")
24+
implementation(project(":smithy-aws-typescript-codegen"))
25+
}
26+
27+
// This project doesn't produce a JAR.
28+
tasks["jar"].enabled = false
29+
30+
// Run the SmithyBuild task manually since this project needs the built JAR
31+
// from smithy-aws-typescript-codegen.
32+
tasks["smithyBuildJar"].enabled = false
33+
34+
tasks.create<SmithyBuild>("buildSdk") {
35+
addRuntimeClasspath = true
36+
}
37+
38+
// Run the `buildSdk` automatically.
39+
tasks["build"].finalizedBy(tasks["buildSdk"])
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
$version: "1.0"
2+
3+
namespace aws.test.generic
4+
5+
use aws.protocols#restJson1
6+
7+
@restJson1
8+
service EchoService {
9+
version: "2018-05-10",
10+
operations: [Echo, Length],
11+
}
12+
13+
@http(code: 200, method: "POST", uri: "/echo",)
14+
operation Echo {
15+
input: EchoInput,
16+
output: EchoOutput,
17+
errors: [PalindromeException],
18+
}
19+
20+
@readonly
21+
@http(code: 200, method: "GET", uri: "/length/{string}")
22+
operation Length {
23+
input: LengthInput,
24+
output: LengthOutput,
25+
errors: [PalindromeException],
26+
}
27+
28+
structure EchoInput {
29+
string: String,
30+
}
31+
32+
structure EchoOutput {
33+
string: String,
34+
}
35+
36+
structure LengthInput {
37+
@required
38+
@httpLabel
39+
string: String,
40+
}
41+
42+
structure LengthOutput {
43+
length: Integer,
44+
}
45+
46+
/// For some reason, this service does not like palindromes!
47+
@httpError(400)
48+
@error("client")
49+
structure PalindromeException {
50+
message: String,
51+
}
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"version": "1.0",
3+
"imports": ["model/echo.smithy"],
4+
"projections": {
5+
"aws-echo-service": {
6+
"transforms": [
7+
{
8+
"name": "includeServices",
9+
"args": {
10+
"services": ["aws.test.generic#EchoService"]
11+
}
12+
}
13+
],
14+
"plugins": {
15+
"typescript-codegen": {
16+
"package": "@aws-sdk/aws-echo-service",
17+
"packageVersion": "1.0.0-alpha.1",
18+
"packageJson": {
19+
"author": {
20+
"name": "AWS SDK for JavaScript Team",
21+
"url": "https://aws.amazon.com/javascript/"
22+
},
23+
"license": "Apache-2.0"
24+
},
25+
"private": true
26+
}
27+
}
28+
}
29+
}
30+
}

Diff for: codegen/settings.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ rootProject.name = "codegen"
1717
include(":smithy-aws-typescript-codegen")
1818
include(":sdk-codegen")
1919
include(":protocol-test-codegen")
20+
include(":generic-client-test-codegen")

0 commit comments

Comments
 (0)