Skip to content

Commit ad9a05c

Browse files
authored
ci: compile with openjdk11, validate against other JDKs (#293)
1 parent 62f7e04 commit ad9a05c

15 files changed

+216
-54
lines changed

buildspec.yml

+75-16
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,89 @@
11
version: 0.2
22

3+
# TODO: Replace/Augment build-graph with build-matrix
4+
# Note: It's possible that 9 builds will be running concurrently with the current arrangement
5+
36
batch:
47
fast-fail: false
5-
build-list:
6-
- identifier: openjdk8
7-
buildspec: codebuild/openjdk8.yml
8+
build-graph:
9+
- identifier: static_analysis
10+
buildspec: codebuild/ci/static-analysis.yml
11+
env:
12+
compute-type: BUILD_GENERAL1_MEDIUM
13+
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
14+
######### Start Vector tests #########
15+
- identifier: vectors_ci_openjdk8
16+
buildspec: codebuild/ci/vectors-ci.yml
817
env:
9-
env:
18+
compute-type: BUILD_GENERAL1_LARGE
19+
variables:
20+
JAVA_ENV_VERSION: openjdk8
1021
image: aws/codebuild/standard:3.0
11-
- identifier: openjdk11
12-
buildspec: codebuild/openjdk11.yml
22+
- identifier: vectors_ci_openjdk11
23+
buildspec: codebuild/ci/vectors-ci.yml
1324
env:
14-
env:
25+
compute-type: BUILD_GENERAL1_LARGE
26+
variables:
27+
JAVA_ENV_VERSION: openjdk11
1528
image: aws/codebuild/standard:3.0
16-
- identifier: corretto8
17-
buildspec: codebuild/corretto8.yml
29+
- identifier: vectors_ci_corretto8
30+
buildspec: codebuild/ci/vectors-ci.yml
1831
env:
19-
env:
32+
compute-type: BUILD_GENERAL1_LARGE
33+
variables:
34+
JAVA_ENV_VERSION: corretto8
2035
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
21-
- identifier: corretto11
22-
buildspec: codebuild/corretto11.yml
36+
- identifier: vectors_ci_corretto11
37+
buildspec: codebuild/ci/vectors-ci.yml
2338
env:
24-
env:
39+
compute-type: BUILD_GENERAL1_LARGE
40+
variables:
41+
JAVA_ENV_VERSION: corretto11
2542
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
26-
- identifier: static_analysis
27-
buildspec: codebuild/static-analysis.yml
43+
######### End Vector tests #########
44+
- identifier: release_ci
45+
buildspec: codebuild/ci/release-ci.yml
46+
env:
47+
compute-type: BUILD_GENERAL1_LARGE
48+
image: aws/codebuild/standard:3.0
49+
######### Start JAR Smoke tests #########
50+
- identifier: validate_ci_openjdk8
51+
depend-on:
52+
- release_ci
53+
buildspec: codebuild/ci/validate-ci.yml
54+
env:
55+
variables:
56+
JAVA_ENV_VERSION: openjdk8
57+
JAVA_NUMERIC_VERSION: 8
58+
image: aws/codebuild/standard:3.0
59+
- identifier: validate_ci_openjdk11
60+
depend-on:
61+
- release_ci
62+
buildspec: codebuild/ci/validate-ci.yml
63+
env:
64+
compute-type: BUILD_GENERAL1_MEDIUM
65+
variables:
66+
JAVA_ENV_VERSION: openjdk11
67+
JAVA_NUMERIC_VERSION: 11
68+
image: aws/codebuild/standard:3.0
69+
- identifier: validate_ci_corretto8
70+
depend-on:
71+
- release_ci
72+
buildspec: codebuild/ci/validate-ci.yml
73+
env:
74+
compute-type: BUILD_GENERAL1_MEDIUM
75+
variables:
76+
JAVA_ENV_VERSION: corretto8
77+
JAVA_NUMERIC_VERSION: 8
78+
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
79+
- identifier: validate_ci_corretto11
80+
depend-on:
81+
- release_ci
82+
buildspec: codebuild/ci/validate-ci.yml
2883
env:
29-
env:
84+
compute-type: BUILD_GENERAL1_MEDIUM
85+
variables:
86+
JAVA_ENV_VERSION: corretto11
87+
JAVA_NUMERIC_VERSION: 11
3088
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
89+
######### End JAR Smoke tests #########

codebuild/ci/release-ci.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
version: 0.2
2+
3+
env:
4+
variables:
5+
REGION: us-east-1
6+
DOMAIN: crypto-tools-internal
7+
REPOSITORY: java-esdk-ci
8+
NAMESPACE: com.amazonaws
9+
PACKAGE: aws-encryption-sdk-java
10+
parameter-store:
11+
ACCOUNT: /CodeBuild/AccountId
12+
secrets-manager:
13+
GPG_KEY: Maven-GPG-Keys-Credentials:Keyname
14+
GPG_PASS: Maven-GPG-Keys-Credentials:Passphrase
15+
16+
phases:
17+
install:
18+
runtime-versions:
19+
java: openjdk11
20+
pre_build:
21+
commands:
22+
- export SETTINGS_FILE=$(pwd)/codebuild/release/settings.xml
23+
- export CODEARTIFACT_TOKEN=$(aws codeartifact get-authorization-token --domain $DOMAIN --domain-owner $ACCOUNT --query authorizationToken --output text --region ${REGION})
24+
- export CODEARTIFACT_REPO_URL=https://${DOMAIN}-${ACCOUNT}.d.codeartifact.${REGION}.amazonaws.com/maven/${REPOSITORY}
25+
- aws secretsmanager get-secret-value --region us-west-2 --secret-id Maven-GPG-Keys --query SecretBinary --output text | base64 -d > ~/mvn_gpg.tgz
26+
- tar -xvf ~/mvn_gpg.tgz -C ~
27+
build:
28+
commands:
29+
- VERSION_HASH="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)-$CODEBUILD_RESOLVED_SOURCE_VERSION"
30+
# See https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
31+
- echo "Setting version in POM to $VERSION_HASH"
32+
- mvn versions:set -DnewVersion="$VERSION_HASH" --no-transfer-progress
33+
- echo "Version is now $(grep version pom.xml | head -n 1 | sed -n 's/[ \t]*<version>\(.*\)<\/version>/\1/p')"
34+
- |
35+
mvn deploy \
36+
-PpublishingCodeArtifact \
37+
-Dmaven.test.skip=true \
38+
-DperformRelease \
39+
-Dgpg.homedir="$HOME/mvn_gpg" \
40+
-DautoReleaseAfterClose=true \
41+
-Dgpg.keyname="$GPG_KEY" \
42+
-Dgpg.passphrase="$GPG_PASS" \
43+
-Dcodeartifact.token=$CODEARTIFACT_TOKEN \
44+
-DaltDeploymentRepository=codeartifact::default::$CODEARTIFACT_REPO_URL \
45+
--no-transfer-progress \
46+
-T 8 \
47+
-s $SETTINGS_FILE
48+
finally:
49+
- |
50+
if expr ${CODEBUILD_BUILD_SUCCEEDING} != 1; then
51+
echo "An error occured while building and uploading $REPOSITORY."
52+
echo "Did a previous build already upload $VERSION_HASH to $REPOSITORY?"
53+
echo "Try deleting $VERSION_HASH from $REPOSITORY and restart"
54+
echo "Delete Package Version Command \n
55+
aws codeartifact delete-package-versions --domain $DOMAIN \
56+
--repository $REPOSITORY \
57+
--format maven \
58+
--namespace $NAMESPACE \
59+
--package $PACKAGE \
60+
--versions $VERSION_HASH \
61+
--region $REGION";
62+
fi

codebuild/ci/settings.xml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
4+
http://maven.apache.org/xsd/settings-1.0.0.xsd">
5+
<servers>
6+
<server>
7+
<id>codeartifact</id>
8+
<username>aws</username>
9+
<password>${codeartifact.token}</password>
10+
</server>
11+
</servers>
12+
13+
<profiles>
14+
<profile>
15+
<id>codeartifact</id>
16+
<repositories>
17+
<repository>
18+
<id>codeartifact</id>
19+
<name>codeartifact</name>
20+
<url>${codeartifact.url}</url> <!-- passed via command line to avoid hardcoding it here -->
21+
</repository>
22+
</repositories>
23+
</profile>
24+
</profiles>
25+
</settings>

codebuild/static-analysis.yml renamed to codebuild/ci/static-analysis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ phases:
77
java: corretto11
88
build:
99
commands:
10-
- mvn com.coveo:fmt-maven-plugin:check
10+
- mvn -T 4 -ntp com.coveo:fmt-maven-plugin:check
1111
- ./util/test-conditions.sh

codebuild/ci/validate-ci.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
version: 0.2
2+
3+
env:
4+
variables:
5+
REGION: us-east-1
6+
DOMAIN: crypto-tools-internal
7+
REPOSITORY: java-esdk-ci
8+
parameter-store:
9+
ACCOUNT: /CodeBuild/AccountId
10+
11+
phases:
12+
install:
13+
commands:
14+
- pip install awscli
15+
runtime-versions:
16+
java: $JAVA_ENV_VERSION
17+
pre_build:
18+
commands:
19+
- VERSION_HASH="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)-$CODEBUILD_RESOLVED_SOURCE_VERSION"
20+
- export SETTINGS_FILE=$(pwd)/codebuild/ci/settings.xml
21+
- git clone https://github.com/aws-samples/busy-engineers-document-bucket.git
22+
- cd busy-engineers-document-bucket/exercises/java/encryption-context-complete
23+
- export CODEARTIFACT_TOKEN=$(aws codeartifact get-authorization-token --domain $DOMAIN --domain-owner $ACCOUNT --query authorizationToken --output text --region ${REGION})
24+
- export CODEARTIFACT_REPO_URL=https://${DOMAIN}-${ACCOUNT}.d.codeartifact.${REGION}.amazonaws.com/maven/${REPOSITORY}
25+
build:
26+
commands:
27+
- |
28+
mvn verify \
29+
-Pcodeartifact \
30+
-Dcheckstyle.skip \
31+
-Desdk.version=$VERSION_HASH \
32+
-Dmaven.compiler.target=$JAVA_NUMERIC_VERSION \
33+
-Dmaven.compiler.source=$JAVA_NUMERIC_VERSION \
34+
-Dcodeartifact.token=$CODEARTIFACT_TOKEN \
35+
-Dcodeartifact.url=$CODEARTIFACT_REPO_URL \
36+
--no-transfer-progress \
37+
-T 4 \
38+
-s $SETTINGS_FILE

codebuild/ci/vectors-ci.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 0.2
2+
3+
phases:
4+
install:
5+
runtime-versions:
6+
java: $JAVA_ENV_VERSION
7+
build:
8+
commands:
9+
- mvn install -T 8 -Dgpg.skip=true -ntp "-DtestVectorZip=file://$CODEBUILD_SRC_DIR/src/test/resources/aws-encryption-sdk-test-vectors/vectors/awses-decrypt/python-2.3.0-mrks.zip"

codebuild/corretto11.yml

-9
This file was deleted.

codebuild/corretto8.yml

-9
This file was deleted.

codebuild/openjdk11.yml

-9
This file was deleted.

codebuild/openjdk8.yml

-9
This file was deleted.

codebuild/release/release-prod.yml

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ phases:
3636
-Dgpg.passphrase="$GPG_PASS" \
3737
-Dsonatype.username="$SONA_USERNAME" \
3838
-Dsonatype.password="$SONA_PASSWORD" \
39+
--no-transfer-progress \
3940
-s $SETTINGS_FILE
4041
4142

codebuild/release/release-staging.yml

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ phases:
4242
-Dgpg.passphrase="$GPG_PASS" \
4343
-Dcodeartifact.token=$CODEARTIFACT_TOKEN \
4444
-DaltDeploymentRepository=codeartifact::default::$CODEARTIFACT_REPO_URL \
45+
--no-transfer-progress \
4546
-s $SETTINGS_FILE
4647
4748
batch:

codebuild/release/validate-prod.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ phases:
1515
-Dcheckstyle.skip \
1616
-Desdk.version=$VERSION \
1717
-Dmaven.compiler.target=$JAVA_NUMERIC_VERSION \
18-
-Dmaven.compiler.source=$JAVA_NUMERIC_VERSION
18+
-Dmaven.compiler.source=$JAVA_NUMERIC_VERSION \
19+
--no-transfer-progress

codebuild/release/validate-staging.yml

+1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ phases:
3232
-Dmaven.compiler.source=$JAVA_NUMERIC_VERSION \
3333
-Dcodeartifact.token=$CODEARTIFACT_TOKEN \
3434
-Dcodeartifact.url=$CODEARTIFACT_REPO_URL \
35+
--no-transfer-progress \
3536
-s $SETTINGS_FILE
3637

pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
<maxmemory>1024m</maxmemory>
130130
<doclint>none</doclint>
131131
<source>8</source>
132+
<quiet>true</quiet>
132133
</configuration>
133134
</plugin>
134135

0 commit comments

Comments
 (0)