Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Musl testing #544

Merged
merged 88 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 87 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
e8e2174
Test branch for musl builds and artifact path resolution
bretambrose Oct 6, 2022
30afc19
Redirect stderr too because that's what ldd outputs to on alpine
bretambrose Oct 6, 2022
4a339c5
Append stderr as well
bretambrose Oct 6, 2022
060dbd4
Include stderr in the runtime check
bretambrose Oct 6, 2022
92a2b02
Remove particular error check that fails on other C runtimes
bretambrose Oct 19, 2022
5b4a9ca
Environment and system property architecture override support; make a…
bretambrose Oct 19, 2022
819fb44
Merge branch 'ArchOverrides' into Musl
bretambrose Oct 19, 2022
8fcc303
Initial CI attempt
bretambrose Oct 19, 2022
66e197b
qemu step
bretambrose Oct 19, 2022
3fa0695
Updated runtime tag for non-linux
bretambrose Oct 19, 2022
8038aff
Allow default credentials on s3 native client test
bretambrose Oct 20, 2022
00245a8
Install openjdk8 first to try and prevent 17 from screwing things up
bretambrose Oct 20, 2022
a5c5a57
Remove problematic test
bretambrose Oct 24, 2022
5196b31
Merge branch 'main' into MuslTesting
bretambrose Oct 24, 2022
594ca15
Restore test fixture
bretambrose Oct 24, 2022
44cf4f3
Remove old arm jobs
bretambrose Oct 24, 2022
ffd339b
Merge branch 'main' into MuslTesting
bretambrose Nov 7, 2022
b8c0dcd
Option to disable PQ crypto entirely, which appears to be broken on A…
bretambrose Nov 8, 2022
84bad24
Alternative switch with auto detection
bretambrose Nov 8, 2022
1d1b1b5
Move to before submodule evaluation
bretambrose Nov 8, 2022
2598171
Make success check use strict to (1) not crash on musl and (2) make t…
bretambrose Nov 10, 2022
8023fcb
Strict Pkcs11 for tls context options test too
bretambrose Nov 10, 2022
e20a335
surefire version switch and try and skip s3 client gen on alpine
bretambrose Nov 14, 2022
1f9350f
Remove s3 client gen for now
bretambrose Nov 14, 2022
0517372
Try to disable gradle s3 client build on alpine only
bretambrose Nov 14, 2022
4b84f31
Maybe fix raspbian job
bretambrose Nov 14, 2022
505dffb
Submodule
bretambrose Nov 14, 2022
315e436
Raspberry
bretambrose Nov 14, 2022
260a293
Merge branch 'main' into MuslTesting
bretambrose Nov 14, 2022
f1c3d93
Merge conflict
bretambrose Nov 14, 2022
3d89676
Openwrt wip
bretambrose Nov 17, 2022
2271978
WIP
bretambrose Nov 17, 2022
ad4f917
WIP
bretambrose Nov 17, 2022
8b18e25
Merge branch 'main' into MuslTesting
bretambrose Jan 3, 2023
ca21259
Builder update + openwrt CI first attempt
bretambrose Jan 3, 2023
7ee64f7
Should have kept it the old-fashioned way
bretambrose Jan 3, 2023
ce994ff
Update script for new artifact path
bretambrose Jan 3, 2023
a989400
Missed a mac compat check branch
bretambrose Jan 4, 2023
9e6b6b2
Checkpoint to experiment with codebuild-based CD using the builder
bretambrose Jan 5, 2023
395ccf0
Codebuild project test def
bretambrose Jan 5, 2023
bc1d4cc
Iteration
bretambrose Jan 5, 2023
8d950c3
WIP
bretambrose Jan 6, 2023
82293da
First attempt at classifier artifact
bretambrose Jan 6, 2023
35d4215
Undefined value
bretambrose Jan 9, 2023
3742361
Update README, codebuild classifier scripts for musl x86_64
bretambrose Jan 9, 2023
c0ef451
Update to common with c runtime detection
bretambrose Jan 12, 2023
ed3e9cf
Submodule
bretambrose Jan 12, 2023
e5c4bae
Update submodules
bretambrose Jan 12, 2023
c21ddf0
Update s2n
bretambrose Jan 12, 2023
316d122
Merge branch 'main' into MuslTesting
bretambrose Jan 12, 2023
f533afb
Don't know what I'm doing
bretambrose Jan 12, 2023
02ef03c
Js infection
bretambrose Jan 12, 2023
23aad01
Reverting to a builder version that didn't fail release containers
bretambrose Jan 12, 2023
97577a8
Update command io submodules to correct errno usage, hopefully addres…
bretambrose Jan 13, 2023
c0c8fc8
Use non-broken release
bretambrose Jan 17, 2023
060a5eb
move some more copy/paste into _run_java_tests()
graebm Jan 17, 2023
b4797a4
Merge branch 'main' into musl-support-3
waahm7 Jun 21, 2023
3428f31
Use Strict finalization and remove alpine profile
waahm7 Jun 21, 2023
94871f8
remove crt ci prep
waahm7 Jun 21, 2023
14d9c3a
Merge branch 'main' into musl-support-3
waahm7 Jun 21, 2023
79ad925
non strict test
waahm7 Jun 22, 2023
64bd389
openssl package
waahm7 Jun 22, 2023
ac4c649
reset
waahm7 Jun 22, 2023
cfb0cbb
Add armv7 build job
waahm7 Jul 3, 2023
b31fadf
Remove -U
waahm7 Jul 5, 2023
f32d136
fix test steps
waahm7 Jul 5, 2023
e8b4d44
remove some more steps
waahm7 Jul 5, 2023
5b80507
+ packages
waahm7 Jul 6, 2023
63680bb
fix maven install
waahm7 Jul 6, 2023
bca396e
add aarch64
waahm7 Jul 6, 2023
c627673
reset linux arm action
waahm7 Jul 6, 2023
1f7cc80
Try ubuntu host
waahm7 Jul 6, 2023
dc7d3dd
mount current directory instead
waahm7 Jul 6, 2023
7b1c138
fix docker build
waahm7 Jul 6, 2023
4b69681
remove --abrev=0, now I know why that is dangerous.
waahm7 Jul 6, 2023
59708c2
replace extra spaces as well
waahm7 Jul 6, 2023
f563d31
fix test platform specific jars
waahm7 Jul 6, 2023
9f313e9
fix builder.json
waahm7 Jul 7, 2023
e195642
remove blank line
waahm7 Jul 7, 2023
1f1c0d2
Merge branch 'main' into musl-support-3
waahm7 Jul 7, 2023
a1629c7
latest submodules
waahm7 Jul 7, 2023
18a1e3a
Update to env.shell.exec
waahm7 Jul 7, 2023
7e15325
Add no auto-detect in Readme
waahm7 Jul 7, 2023
b27ca81
update comment
waahm7 Jul 7, 2023
9d1fd13
PR feedback
waahm7 Jul 10, 2023
813e9c5
re-add jdk
waahm7 Jul 10, 2023
f78c41a
Update .github/workflows/ci.yml
waahm7 Jul 11, 2023
509fece
Update ci.yml
waahm7 Jul 11, 2023
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
39 changes: 18 additions & 21 deletions .builder/actions/aws_crt_java_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,25 @@

class AWSCrtJavaTest(Builder.Action):

def _run_java_tests(self, *cmd_args):
def _run_java_tests(self, *extra_args):
if os.path.exists('log.txt'):
os.remove('log.txt')

profiles = 'continuous-integration'

cmd_args = [
"mvn", "-B",
"-P", profiles,
"-DredirectTestOutputToFile=true",
"-DreuseForks=false",
"-Daws.crt.memory.tracing=2",
"-Daws.crt.debugnative=true",
"-Daws.crt.aws_trace_log_per_test",
"-Daws.crt.ci=true",
]
cmd_args.extend(extra_args)
cmd_args.append("test")

result = self.env.shell.exec(*cmd_args, check=False)
if result.returncode:
if os.path.exists('log.txt'):
Expand All @@ -23,29 +38,11 @@ def start_maven_tests(self, env):
# tests must run with leak detection turned on
env.shell.setenv('AWS_CRT_MEMORY_TRACING', '2')

self._run_java_tests(
"mvn", "-P", "continuous-integration", "-B", "test",
"-DredirectTestOutputToFile=true",
"-DreuseForks=false",
"-DrerunFailingTestsCount=5",
"-Daws.crt.memory.tracing=2",
"-Daws.crt.debugnative=true",
"-Daws.crt.aws_trace_log_per_test",
"-Daws.crt.ci=true",
)
self._run_java_tests("-DrerunFailingTestsCount=5")

# run the ShutdownTest by itself
env.shell.setenv('AWS_CRT_SHUTDOWN_TESTING', '1')
self._run_java_tests(
"mvn", "-P", "continuous-integration", "-B", "test",
"-DredirectTestOutputToFile=true",
"-DreuseForks=false",
"-Daws.crt.memory.tracing=2",
"-Daws.crt.debugnative=true",
"-Daws.crt.aws_trace_log_per_test",
"-Daws.crt.ci=true",
"-Dtest=ShutdownTest",
)
self._run_java_tests("-Dtest=ShutdownTest")

# run the elasticurl integration tests
python = sys.executable
Expand Down
15 changes: 15 additions & 0 deletions .builder/actions/build-classifier.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

import Builder
import sys
import os
import tempfile
from builder.core.host import current_host

# This action is used by the musl-linux-build.sh script to build the binaries for release.
class BuildClassifier(Builder.Action):
waahm7 marked this conversation as resolved.
Show resolved Hide resolved


def run(self, env):
crt_classifier = os.getenv("CRT_CLASSIFIER")
if crt_classifier is not None:
env.shell.exec("mvn", "-B", "install", "-DskipTests", "-Dshared-lib.skip=true", f"-Dcrt.classifier={crt_classifier}", check=True)
43 changes: 42 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'docs'

env:
BUILDER_VERSION: v0.9.45
BUILDER_VERSION: v0.9.46
BUILDER_SOURCE: releases
BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net
PACKAGE_NAME: aws-crt-java
Expand Down Expand Up @@ -79,6 +79,47 @@ jobs:
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')"
chmod a+x builder
./builder build -p ${{ env.PACKAGE_NAME }} --target=linux-${{ matrix.arch }} --spec=downstream

linux-musl:
runs-on: ubuntu-22.04 # latest
strategy:
matrix:
image:
- alpine-3.16-x64
- alpine-3.16-armv6
- alpine-3.16-arm64
- openwrt-x64-openjdk8
steps:
- name: Install qemu/docker
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Checkout Sources
uses: actions/checkout@v2
with:
submodules: true
- name: Build ${{ env.PACKAGE_NAME }}
run: |
aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }}

# armv7 needs its own action due to inability to differentiate at runtime armv6 vs armv7 in the jvm:
#
# At build time we can properly figure out that we're targeting armv7.
# At run time we have to force armv7 (via environment variable) in order to achieve proper resource path
# resolution.
linux-musl-armv7:
Copy link
Contributor

Choose a reason for hiding this comment

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

likewise, don't forget to make this required before merging

runs-on: ubuntu-20.04 # latest
steps:
- name: Install qemu/docker
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Checkout Sources
uses: actions/checkout@v2
with:
submodules: true
- name: Build ${{ env.PACKAGE_NAME }}
run: |
export AWS_CRT_ARCH=armv7
bretambrose marked this conversation as resolved.
Show resolved Hide resolved
aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-alpine-3.16-armv7 build -p ${{ env.PACKAGE_NAME }}

raspberry:
runs-on: ubuntu-22.04 # latest
Expand Down
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ endif()
include(UseJava)
include(AwsPlatformDetect)
include(AwsSharedLibSetup)
include(AwsCRuntime)

aws_determine_local_c_runtime(AWS_C_RUNTIME)

file(GLOB AWS_CRT_JAVA_HEADERS
"include/aws/jni/*.h"
Expand Down Expand Up @@ -156,7 +159,7 @@ file(GLOB CRT_JAVA_SRC
# figure out the target platform info and output the lib there
aws_detect_target_platform(TARGET_OS TARGET_ARCH)
message(STATUS "Compiling for ${TARGET_OS}-${TARGET_ARCH}")
set(TARGET_LIB_DIR "${AWS_LIBRARY_OUTPUT_DIR}/${TARGET_OS}/${TARGET_ARCH}")
set(TARGET_LIB_DIR "${AWS_LIBRARY_OUTPUT_DIR}/${TARGET_OS}/${TARGET_ARCH}/${AWS_C_RUNTIME}")

# shared lib that contains the CRT and JNI bindings, to be loaded by java
add_library(${PROJECT_NAME} SHARED ${CRT_JAVA_HEADERS} ${CRT_JAVA_SRC})
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,14 @@ The `aws-crt` JAR in Maven Central is a large "uber" jar that contains compiled

### Available platform classifiers

- linux-armv6
- linux-armv7
- linux-armv6 (no auto-detect)
- linux-armv7 (no auto-detect)
- linux-aarch_64
- linux-x86_32
- linux-x86_64
- linux-x86_64-musl (no auto-detect)
- linux-armv7-musl (no auto-detect)
- linux-aarch_64-musl (no auto-detect)
graebm marked this conversation as resolved.
Show resolved Hide resolved
- osx-aarch_64
- osx-x86_64
- windows-x86_32
Expand All @@ -97,6 +100,8 @@ The `aws-crt` JAR in Maven Central is a large "uber" jar that contains compiled
The [os-maven-plugin](https://github.com/trustin/os-maven-plugin) can automatically detect your platform's classifier at build time.

**NOTES**: The auto-detected `linux-arm_32` platform classifier is not supported, you must specify `linux-armv6` or `linux-armv7`.
Additionally, musl vs glibc detection is not supported either. If you are deploying to a musl-based system and wish to use
a classifier-based jar, you must specify the classifier name yourself.

``` xml
<build>
Expand Down
22 changes: 22 additions & 0 deletions builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,28 @@
"-DBUILD_TESTING=OFF"
]
}
},
"hosts": {
"_comment": "Reset the overrides from targets/linux/architectures/arm* for Alpine",
"alpine": {
graebm marked this conversation as resolved.
Show resolved Hide resolved
"!packages": [
"maven",
"openjdk8"
],
"!build_steps": [
"mvn -P continuous-integration -B compile",
"build-classifier"
waahm7 marked this conversation as resolved.
Show resolved Hide resolved
],
"!test_steps": [
"aws-crt-java-test"
]
},
"openwrt": {
"!packages": [],
"!build_steps": [
"mvn -P continuous-integration -B compile"
]
}
}
},
"android": {
Expand Down
2 changes: 1 addition & 1 deletion codebuild/cd/deploy-platform-specific-jars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ else
DEPLOY_REPOSITORY_URL=https://aws.oss.sonatype.org:443/service/local/staging/deployByRepositoryId/${STAGING_REPO_ID}
fi

CLASSIFIERS_ARRAY=("linux-armv6" "linux-armv7" "linux-aarch_64" "linux-x86_32" "linux-x86_64" "osx-aarch_64" "osx-x86_64" "windows-x86_32" "windows-x86_64")
CLASSIFIERS_ARRAY=("linux-armv6" "linux-armv7" "linux-aarch_64" "linux-x86_32" "linux-x86_64" "osx-aarch_64" "osx-x86_64" "windows-x86_32" "windows-x86_64" "linux-x86_64-musl" "linux-armv7-musl" "linux-aarch_64-musl")

for str in ${CLASSIFIERS_ARRAY[@]}; do
FILES="${FILES}target/aws-crt-1.0.0-SNAPSHOT-$str.jar,"
Expand Down
22 changes: 22 additions & 0 deletions codebuild/cd/musl-arm64-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 0.2
phases:
install:
commands:
pre_build:
commands:
- export CC=gcc
build:
commands:
- cd aws-crt-java
- ./codebuild/cd/musl-linux-build.sh aws-crt-alpine-3.16-arm64 linux-aarch_64-musl

post_build:
commands:

artifacts:
files:
- 'dist/**/*'

cache:
paths:
- '/root/.m2/**/*'
23 changes: 23 additions & 0 deletions codebuild/cd/musl-armv7-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 0.2
phases:
install:
commands:
pre_build:
commands:
- export CC=gcc
build:
commands:
- cd aws-crt-java
- export AWS_CRT_ARCH=armv7
- ./codebuild/cd/musl-linux-build.sh aws-crt-alpine-3.16-armv7 linux-armv7-musl

post_build:
commands:

artifacts:
files:
- 'dist/**/*'

cache:
paths:
- '/root/.m2/**/*'
29 changes: 29 additions & 0 deletions codebuild/cd/musl-linux-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

set -ex

IMAGE_NAME=$1
shift
CLASSIFIER=$1
shift

# Pry the builder version this CRT is using out of ci.yml
BUILDER_VERSION=$(cat .github/workflows/ci.yml | grep 'BUILDER_VERSION:' | sed 's/\s*BUILDER_VERSION:\s*\(.*\)/\1/')
echo "Using builder version ${BUILDER_VERSION}"

aws ecr get-login-password | docker login 123124136734.dkr.ecr.us-east-1.amazonaws.com -u AWS --password-stdin
export DOCKER_IMAGE=123124136734.dkr.ecr.us-east-1.amazonaws.com/${IMAGE_NAME}:${BUILDER_VERSION}
export QEMU_IMAGE=123124136734.dkr.ecr.us-east-1.amazonaws.com/multiarch-qemu-user-static:latest
docker run --rm --privileged ${QEMU_IMAGE} --reset -p yes


export CRT_CLASSIFIER=${CLASSIFIER}
export BRANCH_TAG=$(git describe --tags)
docker run --mount type=bind,src=$(pwd),dst=/root/aws-crt-java --env AWS_ACCESS_KEY_ID --env AWS_SECRET_ACCESS_KEY --env AWS_DEFAULT_REGION --env CXXFLAGS --env AWS_CRT_ARCH --env CRT_CLASSIFIER $DOCKER_IMAGE --version=${BUILDER_VERSION} build -p aws-crt-java --branch ${BRANCH_TAG} run_tests=false
docker container prune -f

# Upload the artifacts to S3
export GIT_TAG=$(git describe --tags)

aws s3 cp --recursive --include "*.so" target/cmake-build/lib s3://aws-crt-java-pipeline/${GIT_TAG}/lib
aws s3 cp target/ s3://aws-crt-java-pipeline/${GIT_TAG}/jar/ --recursive --exclude "*" --include "aws-crt*.jar"
22 changes: 22 additions & 0 deletions codebuild/cd/musl-x64-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 0.2
phases:
install:
commands:
pre_build:
commands:
- export CC=gcc
build:
commands:
- cd aws-crt-java
- ./codebuild/cd/musl-linux-build.sh aws-crt-alpine-3.16-x64 linux-x86_64-musl

post_build:
commands:

artifacts:
files:
- 'dist/**/*'

cache:
paths:
- '/root/.m2/**/*'
2 changes: 1 addition & 1 deletion codebuild/cd/test-platform-specific-jar-snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -ex

PLATFORM_ARRAY=("linux-armv6" "linux-armv7" "linux-aarch_64" "linux-x86_32" "linux-x86_64" "osx-aarch_64" "osx-x86_64" "windows-x86_32" "windows-x86_64")
PLATFORM_ARRAY=("linux-armv6" "linux-armv7" "linux-aarch_64" "linux-x86_32" "linux-x86_64" "osx-aarch_64" "osx-x86_64" "windows-x86_32" "windows-x86_64" "linux-x86_64-musl" "linux-armv7-musl" "linux-aarch_64-musl")

# test uber jar
mvn -B dependency:get -DrepoUrl=https://aws.oss.sonatype.org/content/repositories/snapshots -Dartifact=software.amazon.awssdk.crt:aws-crt:${CRT_VERSION}-SNAPSHOT -Dtransitive=false
Expand Down
4 changes: 2 additions & 2 deletions codebuild/macos_compatibility_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def main():
# version 10.9
# sdk 12.1
# Load command 9
otool_cmd = "otool -l target/cmake-build/lib/osx/{}/libaws-crt-jni.dylib | grep -A3 \'LC_VERSION_MIN_MACOSX\' | grep -E version | tr -s ' ' | cut -f3 -d' ' | tr -d '[:space:]'".format(arch)
otool_cmd = "otool -l target/cmake-build/lib/osx/{}/cruntime/libaws-crt-jni.dylib | grep -A3 \'LC_VERSION_MIN_MACOSX\' | grep -E version | tr -s ' ' | cut -f3 -d' ' | tr -d '[:space:]'".format(arch)

if len(sys.argv) > 1:
# Parsing the macos archtecture
Expand All @@ -39,7 +39,7 @@ def main():
arch = "armv8"
# The oldest version we can target on arm64 is 11.0
supported_version = "11.0"
otool_cmd = "otool -l target/cmake-build/lib/osx/{}/libaws-crt-jni.dylib | grep -E minos | tr -s ' ' | cut -f3 -d' ' | tr -d ' ' | tr -d '[:space:]'".format(arch)
otool_cmd = "otool -l target/cmake-build/lib/osx/{}/cruntime/libaws-crt-jni.dylib | grep -E minos | tr -s ' ' | cut -f3 -d' ' | tr -d ' ' | tr -d '[:space:]'".format(arch)

print("Start to validate the build binary for MacOS with architecture {}, expected min os version: {}".format(arch,supported_version))
result = subprocess.check_output(otool_cmd, shell=True).decode("utf-8")
Expand Down
2 changes: 1 addition & 1 deletion crt/aws-c-io
Loading