diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c4855070..444a7989 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: path: ${{ env.PRIVATE_REPO }} test: - name: Gradle ${{ matrix.gradle }} on Java ${{ matrix.java }} + name: Gradle ${{ matrix.gradle }} on Java ${{ matrix.java }}${{ matrix.toolchainJavaVersion && format(' (Java {0} Container)', matrix.toolchainJavaVersion) || '' }} runs-on: ubuntu-latest needs: build @@ -48,16 +48,30 @@ jobs: - java: 11 gradle: '7.6.4' + - java: 11 + gradle: '7.6.4' + toolchainJavaVersion: 17 + - java: 17 gradle: '7.6.4' + + - java: 17 + gradle: '7.6.4' + toolchainJavaVersion: 21 - java: 17 gradle: '8.6' + + - java: 17 + gradle: '8.6' + toolchainJavaVersion: 21 env: TEST_ALL_CONTAINERS: ${{ matrix.container }} GRADLE_VERSION: ${{ matrix.gradle }} EXTRA_PROPERTIES: ${{ matrix.properties }} + TOOLCHAIN_JAVA_ARGS: "${{ matrix.toolchainJavaVersion && format('-PtoolchainJavaVersion={0}', matrix.toolchainJavaVersion) || '' }}" + GRADLE_TEST_TASK: "${{ matrix.toolchainJavaVersion && 'testAllJavaToolchain' || 'testAll' }}" steps: - uses: actions/checkout@v3 @@ -92,8 +106,8 @@ jobs: ../gradlew --no-daemon \ --warning-mode all \ -PprivateRepoDir=$PRIVATE_REPO \ - $EXTRA_PROPERTIES \ + $EXTRA_PROPERTIES $TOOLCHAIN_JAVA_ARGS \ -PgeckoDriverPlatform=linux64 \ -PtestAllContainers=$TEST_ALL_CONTAINERS \ - testAll + $GRADLE_TEST_TASK working-directory: integrationTests diff --git a/.gitignore b/.gitignore index 78ae5c55..5d4e9da2 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ build *.iws bin/ .DS_Store +.docker-gradle/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..3a195bd1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,45 @@ +FROM ubuntu as base +RUN apt-get update + +FROM base as base-utils +ENV _BASH_UTILS_DIR=/root/.bashrc.d +COPY <<-EOF $_BASH_UTILS_DIR/0_on_bash_ready.bash +shopt -s expand_aliases +export _on_bash_ready_i=\$(find $_BASH_UTILS_DIR -type f | wc -l) +function on_bash_ready (){ + ((_on_bash_ready_i++)) + local file="$_BASH_UTILS_DIR/\${_on_bash_ready_i}.bash" + echo "\$@" >> \$file && \ + sed -i 's/\r\$//' \$file && \ + source \$file +} +EOF +RUN sed -i 's/\r$//' $_BASH_UTILS_DIR/0_on_bash_ready.bash +RUN echo "while read -r FILE; do source \$FILE; done < <( find $_BASH_UTILS_DIR -name '*.bash' | sort)" >> ~/.profile +SHELL ["/bin/bash", "-l", "-c"] + + +FROM base-utils as firefox +RUN apt-get install -y wget +RUN install -d -m 0755 /etc/apt/keyrings +RUN wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- | tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null +RUN echo 'deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main' | tee -a /etc/apt/sources.list.d/mozilla.list > /dev/null +RUN apt-get update && apt-get install -y firefox-devedition-l10n-eu +RUN ln -s /usr/bin/firefox-devedition /usr/bin/firefox + + +FROM firefox as firefox-sdkman +RUN apt-get install -y curl unzip zip findutils +RUN curl -s "https://get.sdkman.io?rcupdate=false" | bash +RUN on_bash_ready source /root/.sdkman/bin/sdkman-init.sh + +FROM firefox-sdkman as firefox-jdk +ARG JAVA_VERSIONS="8.0.412-amzn" +ENV JAVA_VERSIONS="$JAVA_VERSIONS" +RUN on_bash_ready 'alias install_jdk="sdk install java $1"' +RUN for version in ${JAVA_VERSIONS//,/ } ; do install_jdk $version ; done + + +FROM firefox-jdk as firefox-jdk-gradle +ARG GRADLE_VERSION="6.9.4" +RUN sdk install gradle $GRADLE_VERSION diff --git a/docker_gradlew.sh b/docker_gradlew.sh new file mode 100644 index 00000000..1a224216 --- /dev/null +++ b/docker_gradlew.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +set -e + +function build_docker_gradlew_image(){ + docker build -t "docker_gradlew" . \ + --build-arg JAVA_VERSIONS="$_javas" \ + --build-arg GRADLE_VERSION="$_gradle" +} + +function run_docker(){ + build_docker_gradlew_image "$*" + + local working_dir="-w //project/${_working_dir}" + + local project_volume="-v //$(realpath .)://project" + + local gradle_home_volume="" + if [ "$_gradle_home" ]; then + gradle_home_volume="-v //$(realpath $_gradle_home)://root/.gradle" + fi + + local params="$DOCKER_ARGS $project_volume $working_dir $gradle_home_volume" + + + echo "RUNNING:" docker run --rm -it $params docker_gradlew "$@" + docker run --rm -it $params docker_gradlew "$@" +} + +function run_docker_gradle() { + run_docker bash -lc "gradle $*" +} + + +JDK["8"]="8.0.412-amzn" +JDK["11"]="11.0.23-amzn" +JDK["17"]="17.0.11-amzn" +JDK["21"]="21.0.3-amzn" + +GRADLE["6"]="6.9.4" +GRADLE["7"]="7.6.4" +GRADLE["8"]="8.6" + +POSITIONAL_ARGS=() +while [[ $# -gt 0 ]]; do + case "$1" in + -j|--java) export _javas+=",${JDK[$2]:=$2}" && shift 2 ;; + -g|--gradle) export _gradle=${GRADLE[$2]:=$2} && shift 2 ;; + -h|--gradle-home) export _gradle_home=$2 && shift 2 ;; + -w|--working-dir) export _working_dir=$2 && shift 2 ;; + -b|--bash) export _bash="Yes" && shift 1 ;; + + *) POSITIONAL_ARGS+=("$1") && shift ;; + esac +done +set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters + +if [ "$_bash" ]; then + run_docker bash -l +else + run_docker_gradle "${@}" +fi \ No newline at end of file diff --git a/docker_integration_tests.sh b/docker_integration_tests.sh new file mode 100644 index 00000000..f49f3b23 --- /dev/null +++ b/docker_integration_tests.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +set -e + +export common_gradle_args="--console=plain --no-daemon -Porg.gradle.java.installations.auto-download=false -PgeckoDriverPlatform=linux64" + +#ci.yml plugin build step +./docker_gradlew.sh \ + --java 11 \ + --gradle 7 \ + --gradle-home .docker-gradle \ + $common_gradle_args \ + publishToPrivateRepo + +#ci.yml matrix case #1 +./docker_gradlew.sh \ + --java 11 \ + --gradle 7 \ + --gradle-home .docker-gradle \ + --working-dir integrationTests \ + $common_gradle_args \ + testAll + +#ci.yml matrix case #2 +./docker_gradlew.sh \ + --java 17 \ + --gradle 7 \ + --gradle-home .docker-gradle \ + --working-dir integrationTests \ + $common_gradle_args \ + testAll + +#ci.yml matrix case #3 +./docker_gradlew.sh \ + --java 17 \ + --gradle 8 \ + --gradle-home .docker-gradle \ + --working-dir integrationTests \ + $common_gradle_args \ + testAll