Skip to content

Commit

Permalink
feat(codegen): test non-AWS client builds (#2876)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamthom-amzn authored Oct 6, 2021
1 parent 99d9267 commit d9012cc
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/generic-client-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: generic-client-tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions/setup-java@v1
with:
java-version: '11'

- uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'yarn'

- name: build and publish smithy-typescript
run: |
git clone --depth 1 https://github.com/awslabs/smithy-typescript.git
cd smithy-typescript
./gradlew clean build publishToMavenLocal
cd ..
- name: build codegen and generate generic client
run: |
cd codegen
./gradlew clean smithy-aws-typescript-codegen:build generic-client-test-codegen:build
- name: build generic client
run: |
cd codegen/generic-client-test-codegen/build/smithyprojections/generic-client-test-codegen/aws-echo-service/typescript-codegen/
yarn install && yarn build
39 changes: 39 additions & 0 deletions codegen/generic-client-test-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

import software.amazon.smithy.gradle.tasks.SmithyBuild

plugins {
id("software.amazon.smithy") version "0.5.3"
}

dependencies {
implementation("software.amazon.smithy:smithy-aws-protocol-tests:[1.11.0, 1.12.0[")
implementation(project(":smithy-aws-typescript-codegen"))
}

// This project doesn't produce a JAR.
tasks["jar"].enabled = false

// Run the SmithyBuild task manually since this project needs the built JAR
// from smithy-aws-typescript-codegen.
tasks["smithyBuildJar"].enabled = false

tasks.create<SmithyBuild>("buildSdk") {
addRuntimeClasspath = true
}

// Run the `buildSdk` automatically.
tasks["build"].finalizedBy(tasks["buildSdk"])
51 changes: 51 additions & 0 deletions codegen/generic-client-test-codegen/model/echo.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
$version: "1.0"

namespace aws.test.generic

use aws.protocols#restJson1

@restJson1
service EchoService {
version: "2018-05-10",
operations: [Echo, Length],
}

@http(code: 200, method: "POST", uri: "/echo",)
operation Echo {
input: EchoInput,
output: EchoOutput,
errors: [PalindromeException],
}

@readonly
@http(code: 200, method: "GET", uri: "/length/{string}")
operation Length {
input: LengthInput,
output: LengthOutput,
errors: [PalindromeException],
}

structure EchoInput {
string: String,
}

structure EchoOutput {
string: String,
}

structure LengthInput {
@required
@httpLabel
string: String,
}

structure LengthOutput {
length: Integer,
}

/// For some reason, this service does not like palindromes!
@httpError(400)
@error("client")
structure PalindromeException {
message: String,
}
30 changes: 30 additions & 0 deletions codegen/generic-client-test-codegen/smithy-build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"version": "1.0",
"imports": ["model/echo.smithy"],
"projections": {
"aws-echo-service": {
"transforms": [
{
"name": "includeServices",
"args": {
"services": ["aws.test.generic#EchoService"]
}
}
],
"plugins": {
"typescript-codegen": {
"package": "@aws-sdk/aws-echo-service",
"packageVersion": "1.0.0-alpha.1",
"packageJson": {
"author": {
"name": "AWS SDK for JavaScript Team",
"url": "https://aws.amazon.com/javascript/"
},
"license": "Apache-2.0"
},
"private": true
}
}
}
}
}
1 change: 1 addition & 0 deletions codegen/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ rootProject.name = "codegen"
include(":smithy-aws-typescript-codegen")
include(":sdk-codegen")
include(":protocol-test-codegen")
include(":generic-client-test-codegen")

0 comments on commit d9012cc

Please sign in to comment.