Skip to content

Commit b668333

Browse files
authored
Merge pull request #632 from aws/fabisev/release-toolchains-fix
fix(ci): write JDK 8 toolchains.xml for release builds
2 parents aff4425 + e6290f4 commit b668333

7 files changed

Lines changed: 73 additions & 8 deletions

File tree

.github/actions/configure-release-aws-credentials/action.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ runs:
2323
aws-region: ${{ inputs.aws-region }}
2424
role-to-assume: ${{ inputs.role-to-assume }}
2525
role-session-name: ${{ inputs.role-session-name }}
26-
# Short-lived: the job only needs the role briefly to read two secrets.
27-
role-duration-seconds: 300
26+
# Kept short: the job only needs the role briefly to read two secrets.
27+
# 900s is STS's minimum for assume-role; anything lower is rejected.
28+
role-duration-seconds: 900

.github/workflows/release-runtime-interface-client.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ env:
4040
MAVEN_ARGS: "-B --no-transfer-progress"
4141
AWS_REGION: ${{ vars.AWS_REGION_MAVEN_RELEASE }}
4242
OIDC_ROLE_ARN: ${{ secrets.AWS_ROLE_MAVEN_RELEASE }}
43+
# ECR pull-through cache used for the native JNI base images. ECR_REGISTRY is
44+
# the login target; BASE_REGISTRY (with the /ecr-public prefix) is passed to
45+
# the Dockerfiles as a build-arg.
46+
ECR_REGISTRY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ vars.AWS_REGION_MAVEN_RELEASE }}.amazonaws.com
47+
BASE_REGISTRY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ vars.AWS_REGION_MAVEN_RELEASE }}.amazonaws.com/ecr-public
4348

4449
jobs:
4550
# Build each architecture's native libs (glibc + musl) on a native runner.
@@ -79,6 +84,17 @@ jobs:
7984
echo "JAVA_HOME=$JAVA_8_HOME" >> "$GITHUB_ENV"
8085
echo "$JAVA_8_HOME/bin" >> "$GITHUB_PATH"
8186
"$JAVA_8_HOME/bin/java" -version
87+
mkdir -p "$HOME/.m2"
88+
cat > "$HOME/.m2/toolchains.xml" <<EOF
89+
<?xml version="1.0" encoding="UTF-8"?>
90+
<toolchains>
91+
<toolchain>
92+
<type>jdk</type>
93+
<provides><version>8</version></provides>
94+
<configuration><jdkHome>$JAVA_8_HOME</jdkHome></configuration>
95+
</toolchain>
96+
</toolchains>
97+
EOF
8298
8399
# Route all mvn resolution through the CodeArtifact mirror. Must precede
84100
# resolve-release-version, which invokes `mvn help:evaluate`. Ambient
@@ -92,6 +108,14 @@ jobs:
92108
module: ${{ env.MODULE }}
93109
release-version-override: ${{ env.RELEASE_VERSION_INPUT }}
94110

111+
# The native JNI build shells out to `docker build` against the ECR
112+
# pull-through cache (see src/main/jni/Dockerfile.*). Authenticate first so
113+
# the base-image pulls don't hit public.ecr.aws. Uses ambient runner creds.
114+
- name: Log in to Amazon ECR (pull-through cache)
115+
run: |
116+
aws ecr get-login-password --region "$AWS_REGION" \
117+
| docker login --username AWS --password-stdin "$ECR_REGISTRY"
118+
95119
# -DskipTests: only installed so the module compiles, not released here.
96120
- name: Install intra-repo dependencies
97121
run: |
@@ -149,6 +173,17 @@ jobs:
149173
echo "JAVA_HOME=$JAVA_8_HOME" >> "$GITHUB_ENV"
150174
echo "$JAVA_8_HOME/bin" >> "$GITHUB_PATH"
151175
"$JAVA_8_HOME/bin/java" -version
176+
mkdir -p "$HOME/.m2"
177+
cat > "$HOME/.m2/toolchains.xml" <<EOF
178+
<?xml version="1.0" encoding="UTF-8"?>
179+
<toolchains>
180+
<toolchain>
181+
<type>jdk</type>
182+
<provides><version>8</version></provides>
183+
<configuration><jdkHome>$JAVA_8_HOME</jdkHome></configuration>
184+
</toolchain>
185+
</toolchains>
186+
EOF
152187
153188
# Route all mvn resolution through the CodeArtifact mirror. Must precede
154189
# resolve-release-version (which invokes `mvn help:evaluate`) and the OIDC
@@ -163,6 +198,14 @@ jobs:
163198
module: ${{ env.MODULE }}
164199
release-version-override: ${{ env.RELEASE_VERSION_INPUT }}
165200

201+
# The native JNI build shells out to `docker build` against the ECR
202+
# pull-through cache (see src/main/jni/Dockerfile.*). Authenticate first so
203+
# the base-image pulls don't hit public.ecr.aws. Uses ambient runner creds.
204+
- name: Log in to Amazon ECR (pull-through cache)
205+
run: |
206+
aws ecr get-login-password --region "$AWS_REGION" \
207+
| docker login --username AWS --password-stdin "$ECR_REGISTRY"
208+
166209
- name: Resolve next development version and tag
167210
run: |
168211
# Next development version: use the override, or bump the patch.
@@ -200,7 +243,7 @@ jobs:
200243
- name: Run tests
201244
env:
202245
IS_JAVA_8: true
203-
run: mvn test --file "$MODULE/pom.xml"
246+
run: mvn test -DargLineForReflectionTestOnly="" --file "$MODULE/pom.xml"
204247

205248
# JARs to attach + .so files for the fat main JAR.
206249
- name: Download native artifacts

.github/workflows/release.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ jobs:
9595
echo "JAVA_HOME=$JAVA_8_HOME" >> "$GITHUB_ENV"
9696
echo "$JAVA_8_HOME/bin" >> "$GITHUB_PATH"
9797
"$JAVA_8_HOME/bin/java" -version
98+
mkdir -p "$HOME/.m2"
99+
cat > "$HOME/.m2/toolchains.xml" <<EOF
100+
<?xml version="1.0" encoding="UTF-8"?>
101+
<toolchains>
102+
<toolchain>
103+
<type>jdk</type>
104+
<provides><version>8</version></provides>
105+
<configuration><jdkHome>$JAVA_8_HOME</jdkHome></configuration>
106+
</toolchain>
107+
</toolchains>
108+
EOF
98109
99110
# Route all mvn resolution through the CodeArtifact mirror. Runs before the
100111
# OIDC step (which would shadow the runner-role creds this needs) and on

aws-lambda-java-runtime-interface-client/src/main/jni/Dockerfile.glibc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
FROM public.ecr.aws/amazonlinux/amazonlinux:2
1+
ARG BASE_REGISTRY=public.ecr.aws
2+
FROM ${BASE_REGISTRY}/amazonlinux/amazonlinux:2
23

34
ARG CURL_VERSION
5+
ARG AWS_REGION
6+
7+
RUN if [ -n "${AWS_REGION}" ]; then echo "${AWS_REGION}" > /etc/yum/vars/awsregion; fi
48

59
RUN yum install -y \
610
cmake3 \

aws-lambda-java-runtime-interface-client/src/main/jni/Dockerfile.musl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM public.ecr.aws/docker/library/alpine:3
1+
ARG BASE_REGISTRY=public.ecr.aws
2+
FROM ${BASE_REGISTRY}/docker/library/alpine:3
23

34
ARG CURL_VERSION
45

aws-lambda-java-runtime-interface-client/src/main/jni/build-jni-lib.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ MULTI_ARCH=${2}
99
BUILD_OS=${3}
1010
BUILD_ARCH=${4}
1111
CURL_VERSION=7.83.1
12+
# Registry hosting the base images. Defaults to public.ecr.aws for local and
13+
# GitHub-hosted builds; the release workflow overrides it with the ECR
14+
# pull-through cache so egress-locked runners don't hit public.ecr.aws.
15+
BASE_REGISTRY="${BASE_REGISTRY:-public.ecr.aws}"
16+
AWS_REGION="${AWS_REGION:-${AWS_DEFAULT_REGION:-}}"
1217

1318
function get_docker_platform() {
1419
arch=$1
@@ -45,7 +50,7 @@ function build_for_libc_arch() {
4550

4651
if [[ "${MULTI_ARCH}" == "true" ]]; then
4752
docker build --platform="${docker_platform}" -f "${SRC_DIR}/Dockerfile.${libc_impl}" \
48-
--build-arg CURL_VERSION=${CURL_VERSION} "${SRC_DIR}" -o - \
53+
--build-arg CURL_VERSION=${CURL_VERSION} --build-arg BASE_REGISTRY=${BASE_REGISTRY} --build-arg AWS_REGION=${AWS_REGION} "${SRC_DIR}" -o - \
4954
| tar -xOf - src/aws-lambda-runtime-interface-client.so > "${artifact}"
5055
else
5156
echo "multi-arch not requested, assuming this is a workaround to goofyness when docker buildx is enabled on Linux CI environments."
@@ -63,7 +68,7 @@ function build_for_libc_arch() {
6368
docker build --platform="${docker_platform}" \
6469
-t "${image_name}" \
6570
-f "${SRC_DIR}/Dockerfile.${libc_impl}" \
66-
--build-arg CURL_VERSION=${CURL_VERSION} "${SRC_DIR}" ${EXTRA_LOAD_ARG}
71+
--build-arg CURL_VERSION=${CURL_VERSION} --build-arg BASE_REGISTRY=${BASE_REGISTRY} --build-arg AWS_REGION=${AWS_REGION} "${SRC_DIR}" ${EXTRA_LOAD_ARG}
6772

6873
echo "Docker image has been successfully built"
6974

aws-lambda-java-runtime-interface-client/src/test/java/com/amazonaws/services/lambda/crac/DNSCacheManagerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void positiveDnsCacheShouldBeEmpty() throws CheckpointException, RestoreE
6969
StatefulResource resource = new StatefulResource();
7070
Core.getGlobalContext().register(resource);
7171

72-
String[] hosts = {"www.stackoverflow.com", "www.amazon.com", "www.yahoo.com"};
72+
String[] hosts = {"github.com", "amazonaws.com"};
7373
for(String singleHost : hosts) {
7474
InetAddress address = InetAddress.getByName(singleHost);
7575
}

0 commit comments

Comments
 (0)