Skip to content

Commit

Permalink
Add build_api18 step for verifying keystore implementation for 18-22 …
Browse files Browse the repository at this point in the history
…API levels
  • Loading branch information
Karthikeyan Vasuki Balasubramaniam committed May 23, 2019
1 parent 229ead4 commit 7f31921
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 19 deletions.
69 changes: 65 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@ commands:
# This is required becaused AWSCore has a compileOnly
# dependency on API Level 23.
sudo yes | sdkmanager "platforms;android-23"
setup_android_platform18:
description: >-
setup android platform 18
steps:
- run:
name: download android platform 18
command: |
# This is required becaused AWSCore has a compileOnly
# dependency on API Level 18.
sudo yes | sdkmanager "platforms;android-18"
skip_test_job:
description: >-
check if the test job can be skipped
Expand Down Expand Up @@ -288,6 +298,7 @@ jobs:
- checkout
- generate_gradle_wrapper
- setup_android_platform23
- setup_android_platform18
- run:
name: build the whole project
command: |
Expand Down Expand Up @@ -334,7 +345,40 @@ jobs:
- run:
name: build the whole project
command: |
bash gradlew :aws-android-sdk-core:build -x test
bash gradlew :aws-android-sdk-core:build -x test
build_api18:
working_directory: ~/code
docker:
- image: circleci/android:api-27-alpha
environment:
JVM_OPTS: -Xmx3200m
steps:
- skip_job_if_required
- checkout
- generate_gradle_wrapper
- run:
name: download android-18
command:
sudo yes | sdkmanager "platforms;android-18"
- run:
name: install python3-pip
command: |
sudo apt-get update
sudo apt-get -y install python3-pip
- run:
name: install json parser
command: sudo pip3 install demjson
- run:
name: update code for API 18
command: |
python3 CircleciScripts/replace_android18.py "$(pwd)"
rm aws-android-sdk-core/src/main/java/com/amazonaws/internal/keyvaluestore/KeyProvider23.java
cat aws-android-sdk-core/src/main/java/com/amazonaws/internal/keyvaluestore/AWSKeyValueStore.java
- run:
name: build the whole project
command: |
export ANDROID_API_LEVEL=18; bash gradlew :aws-android-sdk-core:build -x test
unittest:
working_directory: ~/code
Expand All @@ -350,6 +394,7 @@ jobs:
- skip_test_job
- generate_gradle_wrapper
- setup_android_platform23
- setup_android_platform18
- run:
name: run unit tests
command: |
Expand Down Expand Up @@ -485,7 +530,7 @@ jobs:
- run:
name: Install Android build tools
command: |
sudo yes | /usr/local/bin/sdkmanager "platforms;android-21" "platforms;android-23" "platforms;android-27" "build-tools;27.0.1" "extras;google;m2repository" "extras;android;m2repository"
sudo yes | /usr/local/bin/sdkmanager "platforms;android-18" "platforms;android-21" "platforms;android-23" "platforms;android-27" "build-tools;27.0.1" "extras;google;m2repository" "extras;android;m2repository"
/usr/local/bin/sdkmanager --update
- run:
name: Install GPG
Expand Down Expand Up @@ -660,6 +705,7 @@ jobs:
- skip_test_job
- configure_aws
- setup_android_platform23
- setup_android_platform18
- run:
name: install python3-pip
command: |
Expand Down Expand Up @@ -717,6 +763,7 @@ jobs:
- skip_test_job
- configure_aws
- setup_android_platform23
- setup_android_platform18
- run:
name: checkout sample applications
command: |
Expand Down Expand Up @@ -1019,6 +1066,7 @@ jobs:
- skip_test_job
- configure_aws
- setup_android_platform23
- setup_android_platform18
- run:
name: install python3-pip
command: |
Expand Down Expand Up @@ -1150,7 +1198,11 @@ workflows:
- build_api10:
filters:
branches:
ignore: bump_sdk_version
ignore: bump_sdk_version
- build_api18:
filters:
branches:
ignore: bump_sdk_version
- unittest:
filters:
branches:
Expand Down Expand Up @@ -1466,6 +1518,7 @@ workflows:
- merge_to_master:
requires:
- build_api10
- build_api18
- build
- unittest
- post_integrationtest
Expand All @@ -1476,6 +1529,7 @@ workflows:
- prepare_release_sdk:
requires:
- build_api10
- build_api18
- build
- unittest
- post_integrationtest
Expand All @@ -1496,7 +1550,13 @@ workflows:
branches:
ignore: /.*/
tags:
only: /^(release|beta)_v[0-9]+.[0-9]+.[0-9]+$/
only: /^(release|beta)_v[0-9]+.[0-9]+.[0-9]+$/
- build_api18:
filters:
branches:
ignore: /.*/
tags:
only: /^(release|beta)_v[0-9]+.[0-9]+.[0-9]+$/
- unittest:
filters:
branches:
Expand Down Expand Up @@ -1809,6 +1869,7 @@ workflows:
- unittest
- post_integrationtest
- build_api10
- build_api18
filters:
branches:
ignore: /.*/
Expand Down
14 changes: 1 addition & 13 deletions CircleciScripts/replace_android10.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,10 @@
"files" : [
"aws-android-sdk-core/build.gradle"
]
} ,
{
"match" : 'android-23.jar',
"replace" : 'android-10.jar',
"files" : [
"aws-android-sdk-core/build.gradle"
]
} ,
}
]
replacefiles(root, replaces)




AWSKeyValueStoreFile = os.path.join(root,"aws-android-sdk-core/src/main/java/com/amazonaws/internal/keyvaluestore/AWSKeyValueStore.java")
newcontent = ""
with open(AWSKeyValueStoreFile, 'r') as myfile:
Expand All @@ -40,5 +30,3 @@
newcontent = re.sub(pattern, repl, newcontent)
with open(AWSKeyValueStoreFile,"w") as myfile:
myfile.write(newcontent)


28 changes: 28 additions & 0 deletions CircleciScripts/replace_android18.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from utils import replacefiles
import demjson
import sys
import re
import os
root = sys.argv[1]

replaces = [
{
"match" : 'android-23',
"replace" : 'android-18',
"files" : [
"aws-android-sdk-core/build.gradle"
]
}
]
replacefiles(root, replaces)

AWSKeyValueStoreFile = os.path.join(root,"aws-android-sdk-core/src/main/java/com/amazonaws/internal/keyvaluestore/AWSKeyValueStore.java")
newcontent = ""
with open(AWSKeyValueStoreFile, 'r') as myfile:
content = myfile.read()
pattern = r'//@apiLevel23Start[\s\S]*?//@apiLevel23End'
repl = r""
newcontent = re.sub(pattern, repl, content)

with open(AWSKeyValueStoreFile,"w") as myfile:
myfile.write(newcontent)
6 changes: 4 additions & 2 deletions aws-android-sdk-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ dependencies {
// The following command (is idempotent)
// removes the libs folder, creates libs folder and
// creates a symbolic link to android-23.jar.
task myTask(type:Exec) {
task getApi23(type:Exec) {
print 'Creating a symlink for Android API Level 23.'
workingDir '.'
commandLine 'sh', '-c', "rm -rf libs && mkdir libs && ln -s $System.env.ANDROID_HOME/platforms/android-23/android.jar libs/android-23.jar"
}

compileJava.dependsOn(myTask)

compileJava.dependsOn(getApi23)

sourceCompatibility = "1.7"
targetCompatibility = "1.7"

0 comments on commit 7f31921

Please sign in to comment.