Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/scripts/generate-includes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python3
"""
Converts a list of model file paths to a formatted includes list for passing to bootstrap
"""
import sys
import os

not_supported_yet = ["ec2", "location", "elasticbeanstalk", "marketplacecommerceanalytics"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correctness: Elastic Beanstalk should be supported now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

marketplacecommerceanalytics can join the party as well.



def main():
lines = sys.stdin.readlines()
services = [os.path.basename(x).split(".")[0] for x in lines]
services = ["+" + x for x in services if x not in not_supported_yet]
sys.stdout.write(",".join(services))


if __name__ == "__main__":
main()


84 changes: 72 additions & 12 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ on:
branches: [ main ]
pull_request:
branches: [ main ]
paths-ignore:
- 'docs/**'
- '*.md'
workflow_dispatch:

env:
BUILDER_VERSION: v0.8.0
BUILDER_VERSION: v0.8.19
BUILDER_SOURCE: releases
# host owned by CRT team to host aws-crt-builder releases. Contact their on-call with any issues
BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net
Expand All @@ -21,21 +24,29 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build and Test ${{ env.PACKAGE_NAME }}
env:
CI_USER: ${{ secrets.CI_USER}}
CI_ACCESS_TOKEN: ${{ secrets.CI_ACCESS_TOKEN }}
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u awslabs --password-stdin
export DOCKER_IMAGE=docker.pkg.github.com/awslabs/aws-crt-builder/aws-crt-ubuntu-16-x64:${{ env.BUILDER_VERSION }}
docker pull $DOCKER_IMAGE
docker run --mount type=bind,source=$(pwd),target=/root/${{ env.PACKAGE_NAME }} \
--env GITHUB_REF \
--env GITHUB_HEAD_REF \
--env CI_USER \
--env CI_ACCESS_TOKEN \
--env GIT_ASKPASS=/root/${{ env.PACKAGE_NAME }}/.github/scripts/git-ci-askpass.sh \
$DOCKER_IMAGE build -p ${{ env.PACKAGE_NAME }} --build-dir=/root/${{ env.PACKAGE_NAME }}
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')"
chmod a+x builder.pyz
GIT_ASKPASS="$(pwd)/.github/scripts/git-ci-askpass.sh" ./builder.pyz build -p ${{ env.PACKAGE_NAME }}
- uses: actions/upload-artifact@v2
# uploads local m2 so built runtime artifacts can be re-used
name: Upload Published Maven Artifacts
with:
name: m2-${{ env.name }}-${{ github.sha }}
path: ~/.m2
retention-days: 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question

why 2 days here? I assume this repo caching is particular to a given PR. Would this be for day boundries?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really need the artifact past building the AWS services in parallel. 2 days seemed reasonable to me to debug and diagnose any build failures.


macos-compat:
runs-on: macos-latest
Expand All @@ -47,7 +58,7 @@ jobs:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build and Test ${{ env.PACKAGE_NAME }}
Expand All @@ -58,3 +69,52 @@ jobs:
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')"
chmod a+x builder.pyz
GIT_ASKPASS="$(pwd)/.github/scripts/git-ci-askpass.sh" ./builder.pyz build -p ${{ env.PACKAGE_NAME }}

build-aws-services-batch:
name: Build AWS services parallel
runs-on: ubuntu-latest
continue-on-error: false
needs: linux-compat
strategy:
matrix:
# run jobs in parallel
JOB: [1,2,3,4,5,6,7,8,9,10,11,12]
env:
JOBS: 12
JOB: ${{ matrix.JOB }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- uses: actions/download-artifact@v2
name: Download Maven Artifacts
with:
name: m2-${{ env.name }}-${{ github.sha }}
path: ~/.m2
- name: Generate SDKs
run: |
ls -lsa ~/.m2/repository
find codegen/sdk/aws-models -name '*.json' | sort | awk "NR % $JOBS == $JOB - 1" > services.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question

I take it this is what breaks the work up for each worker?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it splits the list of services into batches modulo the number of "jobs".

echo "Building the following services"
cat services.txt
./gradlew --no-daemon :codegen:sdk:bootstrap -Paws.services=$(cat services.txt | .github/scripts/generate-includes.py)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Why is the generate-includes.py script necessary if we can specify which protocols/services not to build? Won't this be equivalent and simpler?

./gradlews -Paws.services=-location,-marketplacecommerceanalytics -Paws.protocols=-ec2Query :codegen:sdk:bootstrap

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is executed in batches. We only want to build n services per runner (where n = 1/NUM_JOBS). So the include list enforces that only those services even exist in the build. Honestly, this can all evolve I just wanted to get something that runs in a reasonable amount of time in the short term.

- name: Build AWS Services
run: |
./gradlew --parallel build

build-aws-services:
if: ${{ always() }}
name: Build all AWS services
runs-on: ubuntu-latest
needs: build-aws-services-batch
steps:
- name: Check batch matrix status
if: ${{ needs.build-aws-services-batch.result != 'success' }}
run: exit 1
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Generated sources are not checked into the repository, you first have to generat


```sh
./gradlew :codegen:sdk:bootstrap
./gradlew --no-daemon :codegen:sdk:bootstrap
```
Comment on lines 20 to 22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Why are we recommending --no-daemon now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should help prevent having to call ./gradlew --stop before executing.


NOTE: This task will respect the AWS services specified by project properties. See options below.
Expand All @@ -41,7 +41,7 @@ To see list of all projects run `./gradlew projects`
See the local.properties definition above to specify this in a config file.

```sh
./gradlew -Paws.services=+lambda :codegen:sdk:bootstrap
./gradlew --no-daemon -Paws.services=+lambda :codegen:sdk:bootstrap
```

##### Testing Locally
Expand Down
2 changes: 1 addition & 1 deletion builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"gradlew": "{source_dir}/gradlew -p {source_dir}"
},
"build_steps": [
"{gradlew} -x test -x jvmTest -x allTests build"
"{gradlew} assemble"
],
"test_steps": [
"{gradlew} publishToMavenLocal",
Expand Down
12 changes: 6 additions & 6 deletions codegen/protocol-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ tasks["clean"].doFirst {
delete("smithy-build.json")
}

tasks.create<SmithyBuild>("buildSdk") {
tasks.create<SmithyBuild>("generateSdk") {
group = "codegen"
// ensure the generated clients use the same version of the runtime as the aws aws-runtime
val smithyKotlinVersion: String by project
doFirst {
Expand All @@ -70,13 +71,12 @@ tasks.create<SmithyBuild>("buildSdk") {
addRuntimeClasspath = true
dependsOn(tasks["generateSmithyBuild"])
inputs.file(projectDir.resolve("smithy-build.json"))
// ensure smithy-aws-kotlin-codegen is up to date
inputs.files(configurations.compileClasspath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment

very nice! I was trying to get these gradle configurations to work at one point but couldn't make it work. Well done!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to solve it but let me know if you see issues still. For me it seemed to rebuild appropriately now. However, I still have issues where I have to call ./gradlew --stop but at least everything is up-to date. Running codegen with --no-daemon seems to help some FWIW

}

// Run the `buildSdk` automatically.
tasks["build"].finalizedBy(tasks["buildSdk"])

// force rebuild every time while developing
tasks["buildSdk"].outputs.upToDateWhen { false }
tasks["generateSdk"].outputs.upToDateWhen { false }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice rename


data class ProtocolTest(val projectionName: String, val serviceShapeId: String) {
val packageName: String
Expand Down Expand Up @@ -172,7 +172,7 @@ open class ProtocolTestTask : DefaultTask() {

enabledProtocols.forEach {
tasks.register<ProtocolTestTask>("testProtocol-${it.projectionName}") {
dependsOn(tasks.build)
dependsOn(tasks["generateSdk"])
group = "Verification"
protocol = it.projectionName
plugin = "kotlin-codegen"
Expand Down
2 changes: 2 additions & 0 deletions codegen/sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ tasks.create<SmithyBuild>("generateSdk") {
addRuntimeClasspath = true
dependsOn(tasks["generateSmithyBuild"])
inputs.file(projectDir.resolve("smithy-build.json"))
// ensure smithy-aws-kotlin-codegen is up to date
inputs.files(configurations.compileClasspath)
}

// Remove generated model file for clean
Expand Down
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
kotlin.code.style=official
kkotlin.incremental.js=true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correctness: kkotlinkotlin

kotlin.incremental.multiplatform=true
kotlin.parallel.tasks.in.project=true
kotlin.mpp.stability.nowarn=true
kotlin.native.ignoreDisabledTargets=true

# gradle
# FIXME - see https://github.com/Kotlin/dokka/issues/1405
org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1G
org.gradle.jvmargs=-Xmx6g -XX:MaxPermSize=6g -XX:MaxMetaspaceSize=1G

# sdk
sdkVersion=0.4.0-SNAPSHOT
Expand Down