-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Has working unit tests for amplify-android and amplify-ui-android
- Loading branch information
1 parent
8b5c12c
commit 0e93b6a
Showing
17 changed files
with
747 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
.gradle | ||
build/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/modules.xml | ||
.idea/jarRepositories.xml | ||
.idea/compiler.xml | ||
.idea/libraries/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
|
||
### Kotlin ### | ||
.kotlin | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
bin/ | ||
!**/src/main/**/bin/ | ||
!**/src/test/**/bin/ | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store | ||
|
||
### CDK ### | ||
cdk.out/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Amplify Android CI/CD CDK | ||
|
||
This project contains the build infrastructure definitions for Amplify Android's CI/CD processes. | ||
|
||
## Developing | ||
|
||
### Update CDK | ||
|
||
To use a new version of the CDK, set the version number in `gradle/libs.versions.toml` and sync the project. | ||
|
||
## How to Deploy | ||
|
||
### Install dependencies | ||
|
||
To deploy the stacks defined in this project you will need to have the [CDK CLI](https://docs.aws.amazon.com/cdk/v2/guide/cli.html) installed. | ||
|
||
``` | ||
npm install -g aws-cdk | ||
``` | ||
|
||
### Bootstrap the CDK | ||
|
||
This only needs to be done once *per account*. [Bootstrap the account](https://docs.aws.amazon.com/cdk/v2/guide/bootstrapping-env.html) for CDK access by running this command in the terminal: | ||
|
||
``` | ||
cdk bootstrap --profile <your_aws_cli_profile> | ||
``` | ||
|
||
### Setup Prerequisites | ||
|
||
#### GitHub PAT | ||
|
||
A PAT is required to be available in SecretsManager so that CodeBuild can create a webhook for running PR checks. | ||
|
||
1. In GitHub, with the `awsmobilesdk` account (or relevant account for the repository being targeted), create a PAT (Classic) with the following scopes: | ||
- repo | ||
- workflow | ||
- admin:repo_hook | ||
2. In the AWS account, create a secret in SecretsManager with the name `github/pat/amplify-android`. Store the PAT under the key `amplify_android_pat`. | ||
|
||
### Deploy stacks | ||
|
||
To deploy, run the follow command in the terminal: | ||
|
||
``` | ||
cdk deploy --profile <your_aws_cli_profile> | ||
``` |
19 changes: 19 additions & 0 deletions
19
src/build_infrastructure/android/kotlin/ci/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
plugins { | ||
kotlin("jvm") version "2.0.10" | ||
application | ||
} | ||
|
||
dependencies { | ||
implementation(libs.aws.cdk) | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
} | ||
kotlin { | ||
jvmToolchain(21) | ||
} | ||
|
||
application { | ||
mainClass.set("MainKt") | ||
} |
62 changes: 62 additions & 0 deletions
62
src/build_infrastructure/android/kotlin/ci/buildspecs/ui_unit_test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
version: 0.2 | ||
# This file is used as part of the build process implemented using AWS CodeBuild [1]. | ||
# The CodeBuild documentation [2] provides an introduction of the service and its capabilities. In general | ||
# terms, it allows us to configure the actions executed when a build is triggered by a commit to the | ||
# amplify-android GitHub repository. | ||
# | ||
# For the purposes of this repo, we're simply running a build by using "./gradlew build" | ||
# command and in the post-build phase, we consolidate the JUnit report files in one location. | ||
# In the reports section, we're instructing CodeBuild to publish those reports which can be | ||
# viewed in the AWS CodeBuild console (Future work will be to publish those to Github for easier access). | ||
# | ||
# [1] - https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html | ||
# [2] - https://docs.aws.amazon.com/codebuild/latest/userguide/planning.html | ||
env: | ||
shell: /bin/sh | ||
phases: | ||
install: | ||
runtime-versions: | ||
nodejs: 18 | ||
java: corretto17 | ||
commands: | ||
- echo 'Install phase starting' | ||
### INSTALL ANDROID 31 | ||
- export ANDROID_TOOLS_FILENAME="commandlinetools-linux-9123335_latest.zip" | ||
- wget https://dl.google.com/android/repository/$ANDROID_TOOLS_FILENAME -P ~ > /dev/null | ||
- unzip ~/$ANDROID_TOOLS_FILENAME -d ~ > /dev/null 2>&1 | ||
- mkdir -p /usr/local/android-sdk-linux/cmdline-tools | ||
- mv ~/cmdline-tools /usr/local/android-sdk-linux/cmdline-tools/latest | ||
- export PATH=/usr/local/android-sdk-linux/cmdline-tools/latest:/usr/local/android-sdk-linux/cmdline-tools/latest/bin:/usr/local/android-sdk-linux/platform-tools:$PATH | ||
- export ANDROID_SDK_ROOT=/usr/local/android-sdk-linux | ||
- yes | sdkmanager --licenses > /dev/null | ||
- sdkmanager "platform-tools" "platforms;android-33" > /dev/null | ||
- sdkmanager "build-tools;33.0.1" > /dev/null | ||
- sdkmanager --install "cmake;3.22.1" > /dev/null | ||
### END INSTALL ANDROID 31 | ||
finally: | ||
- echo 'Install phase completed.' | ||
pre_build: | ||
commands: | ||
- echo 'Pre-build phase starting' | ||
finally: | ||
- echo 'Pre-build phase completed.' | ||
build: | ||
commands: | ||
- echo 'Build phase starting.' | ||
- JAVA_HOME=$JDK_17_HOME ./gradlew build | ||
finally: | ||
- echo 'Build phase completed.' | ||
post_build: | ||
commands: | ||
- echo 'Post-build phase starting' | ||
- pwd | ||
- mkdir -p build/allTests | ||
- cp -f ./*/build/test-results/testDebugUnitTest/*.xml ./build/allTests | ||
finally: | ||
- echo 'Post-build phase completed.' | ||
reports: | ||
amplify-ui-android-unit-tests: | ||
files: | ||
- build/allTests/* | ||
discard-paths: yes | ||
file-format: JUNITXML |
61 changes: 61 additions & 0 deletions
61
src/build_infrastructure/android/kotlin/ci/buildspecs/unit_test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
version: 0.2 | ||
# This file is used as part of the build process implemented using AWS CodeBuild [1]. | ||
# The CodeBuild documentation [2] provides an introduction of the service and its capabilities. In general | ||
# terms, it allows us to configure the actions executed when a build is triggered by a commit to the | ||
# amplify-android GitHub repository. | ||
# | ||
# For the purposes of this repo, we're simply running a build by using "./gradlew build" | ||
# command and in the post-build phase, we consolidate the JUnit report files in one location. | ||
# In the reports section, we're instructing CodeBuild to publish those reports which can be | ||
# viewed in the AWS CodeBuild console (Future work will be to publish those to Github for easier access). | ||
# | ||
# [1] - https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html | ||
# [2] - https://docs.aws.amazon.com/codebuild/latest/userguide/planning.html | ||
env: | ||
shell: /bin/sh | ||
phases: | ||
install: | ||
runtime-versions: | ||
nodejs: 16 | ||
java: corretto17 | ||
commands: | ||
- echo 'Install phase starting' | ||
### INSTALL ANDROID 31 | ||
- export ANDROID_TOOLS_FILENAME="commandlinetools-linux-9123335_latest.zip" | ||
- wget https://dl.google.com/android/repository/$ANDROID_TOOLS_FILENAME -P ~ > /dev/null | ||
- unzip ~/$ANDROID_TOOLS_FILENAME -d ~ > /dev/null 2>&1 | ||
- mkdir -p /usr/local/android-sdk-linux/cmdline-tools | ||
- mv ~/cmdline-tools /usr/local/android-sdk-linux/cmdline-tools/latest | ||
- export PATH=/usr/local/android-sdk-linux/cmdline-tools/latest:/usr/local/android-sdk-linux/cmdline-tools/latest/bin:/usr/local/android-sdk-linux/platform-tools:$PATH | ||
- export ANDROID_SDK_ROOT=/usr/local/android-sdk-linux | ||
- yes | sdkmanager --licenses > /dev/null | ||
- sdkmanager "platform-tools" "platforms;android-31" > /dev/null | ||
- sdkmanager "build-tools;31.0.0" > /dev/null | ||
### END INSTALL ANDROID 31 | ||
finally: | ||
- echo 'Install phase completed.' | ||
pre_build: | ||
commands: | ||
- echo 'Pre-build phase starting' | ||
finally: | ||
- echo 'Pre-build phase completed.' | ||
build: | ||
commands: | ||
- echo 'Build phase starting.' | ||
- JAVA_HOME=$JDK_17_HOME ./gradlew build | ||
finally: | ||
- echo 'Build phase completed.' | ||
post_build: | ||
commands: | ||
- echo 'Post-build phase starting' | ||
- pwd | ||
- mkdir -p build/allTests | ||
- cp -f ./*/build/test-results/testDebugUnitTest/*.xml ./build/allTests | ||
finally: | ||
- echo 'Post-build phase completed.' | ||
reports: | ||
amplify-android-unit-tests: | ||
files: | ||
- build/allTests/* | ||
discard-paths: yes | ||
file-format: JUNITXML |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"app": "./gradlew build run", | ||
"context": { | ||
"@aws-cdk/core:stackRelativeExports": "true", | ||
"@aws-cdk/aws-ecs-patterns:removeDefaultDesiredCount": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
kotlin.code.style=official |
5 changes: 5 additions & 0 deletions
5
src/build_infrastructure/android/kotlin/ci/gradle/libs.versions.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[versions] | ||
cdk = "2.129.0" | ||
|
||
[libraries] | ||
aws-cdk = { module = "software.amazon.awscdk:aws-cdk-lib", version.ref = "cdk" } |
Binary file added
BIN
+59.3 KB
src/build_infrastructure/android/kotlin/ci/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
src/build_infrastructure/android/kotlin/ci/gradle/wrapper/gradle-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#Wed Dec 04 13:24:05 AST 2024 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.