diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index e63951ff12..4599dcd0b8 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -82,43 +82,23 @@ jobs: run: c2cciutils-checks - run: make build - - run: make acceptance-tests-up - - run: make acceptance-tests-run - - # Extract artifacts - - run: docker run --rm --detach --name=builder mapfish_print_builder || true - if: always() - - run: docker cp builder:/src/core/build/ core/build/ || true - if: always() - - run: ls -l core/build/distributions - if: always() - - - run: docker cp mapfish-print_tests_1:/src/examples/build/ examples/build/ || true - if: always() - - - run: c2cciutils-docker-logs || true + - run: make checks + - run: cat .github/workflows/main.yaml if: failure() + - run: make tests - - run: mkdir -p core/build/resources/actual examples/build/reports core/build/reports examples/build/resources/test/examples - if: always() - uses: actions/upload-artifact@v3 with: name: Test results - path: core/build/resources/ + path: core/build/resources/test/org/mapfish/print/ if-no-files-found: ignore if: failure() - - uses: actions/upload-artifact@v3 - with: - name: Reports examples - path: examples/build/reports - if-no-files-found: ignore - if: failure() - - uses: actions/upload-artifact@v3 - with: - name: Reports core - path: core/build/reports - if-no-files-found: ignore + + - run: make acceptance-tests-up + - run: make acceptance-tests-run + - run: c2cciutils-docker-logs || true if: failure() + - uses: actions/upload-artifact@v3 with: name: Examples @@ -126,17 +106,6 @@ jobs: if-no-files-found: ignore if: failure() - - name: Collect test results - run: | - mkdir -p /tmp/test_results/junit - find . -name '*TEST-*.xml' -exec cp -v {} /tmp/test_results/junit/ \; - if: failure() - - uses: actions/upload-artifact@v3 - with: - name: Test results - path: /tmp/test_results - if: failure() - - name: Publish run: c2cciutils-publish if: env.HAS_SECRETS == 'HAS_SECRETS' diff --git a/Dockerfile b/Dockerfile index 3c141c3a3d..2c1bcba11d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,44 +3,38 @@ FROM gradle:8.1.1-jdk11 AS builder RUN --mount=type=cache,target=/var/cache,sharing=locked \ --mount=type=cache,target=/root/.cache \ apt-get update && \ - apt-get install --yes --no-install-recommends fonts-liberation gettext curl && \ - gradle --version + apt-get install --yes --no-install-recommends fonts-liberation gettext curl WORKDIR /src +ENV GRADLE_OPTS=-Dorg.gradle.daemon=false + +RUN --mount=type=cache,target=/home/gradle/.gradle \ + gradle --version + COPY gradle/ ./gradle/ -COPY gradle.properties build.gradle settings.gradle CI.asc ./ +COPY gradle.properties build.gradle settings.gradle CI.asc checkstyle_* ./ COPY examples/build.gradle ./examples/ COPY docs/build.gradle ./docs/ COPY publish/build.gradle ./publish/ COPY core ./core - -RUN --mount=type=cache,target=/home/gradle/.gradle \ - gradle :core:processResources :core:classes -COPY checkstyle_* ./ -# '&& touch success || true' is a trick to be able to get out some artifacts -RUN --mount=type=cache,target=/home/gradle/.gradle \ - (gradle :core:checkstyleMain :core:spotbugsMain :core:violations --stacktrace) \ - && ( (gradle :core:build :core:explodedWar :core:libSourcesJar :core:libJavadocJar > /tmp/logs 2>&1 && touch success) || true) +COPY publish ./publish +COPY examples ./examples +COPY docs ./docs ARG GIT_HEAD ENV GIT_HEAD=${GIT_HEAD} -COPY publish ./publish - +# Exclude the tasks that will run our of the docker build (in a docker run) RUN --mount=type=cache,target=/home/gradle/.gradle \ - ([ -e success ] && ( (gradle :publish:build >> /tmp/logs 2>&1) && touch success-publish)) || true + gradle --exclude-task=:core:test --exclude-task=:core:spotbugsMain --exclude-task=:core:checkstyleMain \ + :core:build :core:explodedWar :publish:build :examples:build buildDocs -COPY examples ./examples -COPY docs ./docs +RUN mkdir -p core/build/resources/test/org/mapfish/print/ \ + && chmod -R go=u /home/gradle /tmp/mapfish-print/ . \ + && chmod o+t -R core/build/resources +# Backup cache RUN --mount=type=cache,target=/home/gradle/.gradle \ - ([ -e success ] && ( (gradle :examples:build buildDocs >> /tmp/logs 2>&1) && touch success-examples-docs)) || true - -RUN chmod -R go=u /home/gradle . - -FROM builder AS test-builder - -RUN cat /tmp/logs && ls success success-publish success-examples-docs - -VOLUME [ "/src/core" ] + cp -r /home/gradle/.gradle /home/gradle/.gradle-backup +RUN mv /home/gradle/.gradle-backup /home/gradle/.gradle diff --git a/Makefile b/Makefile index 647b7bdae1..d060ebf6b6 100644 --- a/Makefile +++ b/Makefile @@ -2,19 +2,41 @@ GIT_HEAD_ARG = --build-arg=GIT_HEAD=$(shell git rev-parse HEAD) export DOCKER_BUILDKIT = 1 .PHONY: build -build: +build: build-builder # Required and not necessarily exists touch CI.asc - docker build $(GIT_HEAD_ARG) --target=builder --tag=mapfish_print_builder . - docker build $(GIT_HEAD_ARG) . - docker build $(GIT_HEAD_ARG) --target=runner --tag=camptocamp/mapfish_print core docker build $(GIT_HEAD_ARG) --target=tester --tag=mapfish_print_tester core docker build $(GIT_HEAD_ARG) --target=watcher --tag=mapfish_print_watcher core +.PHONY: build-builder +build-builder: + docker build $(GIT_HEAD_ARG) --target=builder --tag=mapfish_print_builder . + +.PHONY: checks +checks: build-builder + docker run --rm \ + --volume=$(PWD)/core/src/:/src/core/src/ \ + --volume=$(PWD)/reports/:/src/core/build/reports/ \ + mapfish_print_builder \ + gradle :core:spotbugsMain :core:checkstyleMain + +.PHONY: tests +tests: build-builder + docker stop print-builder || true + docker run --rm --detach --name=print-builder mapfish_print_builder tail --follow /dev/null + + docker exec print-builder gradle :core:test + + # Get the result + mkdir -p core/build/resources/test/org/mapfish/print/ + docker cp print-builder:/src/core/build/resources/test/org/mapfish/print/ core/build/resources/test/org/mapfish/print/ + + docker stop print-builder + .PHONY: acceptance-tests-up -acceptance-tests-up: +acceptance-tests-up: build docker-compose down --remove-orphan mkdir /tmp/geoserver-data || true @@ -24,7 +46,7 @@ acceptance-tests-up: cp -r examples/geoserver-data/* /tmp/geoserver-data/ cp -r core/src/test/resources/map-data/* /tmp/geoserver-data/www/ - USER_ID=$(shell id -u):$(shell id -g) docker-compose up -d + USER_ID=$(shell id -u):$(shell id -g) docker-compose up --detach .PHONY: acceptance-tests-run acceptance-tests-run: diff --git a/build.gradle b/build.gradle index 73c4aad5df..71753d06d1 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,6 @@ buildscript { dependencies { classpath "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.7.5" - classpath "se.bjurr.violations:violations-gradle-plugin:1.52.5" } } @@ -37,7 +36,6 @@ configure(subprojects.findAll { ['core', 'examples'].contains(it.name) }) { apply plugin: 'idea' apply plugin: 'project-report' apply plugin: 'checkstyle' - apply plugin: 'se.bjurr.violations.violations-gradle-plugin' jar.dependsOn(checkstyleMain) @@ -45,8 +43,6 @@ configure(subprojects.findAll { ['core', 'examples'].contains(it.name) }) { toolVersion = "6.19" // com.puppycrawl.tools:checkstyle configFile = file("$rootProject.rootDir/checkstyle_checks.xml") configProperties = ['basedir': project.rootDir.path] - ignoreFailures = true - reportsDir = file("$project.buildDir/reports/checkstyleReports") } checkstyleTest.enabled = false @@ -71,10 +67,10 @@ configure(subprojects.findAll { ['core', 'examples'].contains(it.name) }) { } check.finalizedBy violations - sourceCompatibility = 1.11 - targetCompatibility = 1.11 - - compileJava.options.compilerArgs = ['-Xlint:deprecation', '-Xlint:unchecked'] + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + + task violations(type: se.bjurr.violations.gradle.plugin.ViolationsTask) { dependencies { testImplementation( diff --git a/docker-compose.yaml b/docker-compose.yaml index 563a32f037..932009b29a 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -11,11 +11,11 @@ services: image: mapfish_print_tester user: ${USER_ID} volumes: - - ./examples/src/test/resources/examples:/usr/local/tomcat/webapps/ROOT/print-apps + - ./examples/src/test/resources/examples:/usr/local/tomcat/webapps/ROOT/print-apps:ro ports: - 8080:8080 environment: - PRINT_YAML_MAX_ALIASES: 200 + PRINT_YAML_MAX_ALIASES: '200' LOG_LEVEL: DEBUG JASPER_LOG_LEVEL: DEBUG @@ -26,5 +26,5 @@ services: volumes: - ./examples/src/test/resources/examples:/src/examples/src/test/resources/examples environment: - PRINT_YAML_MAX_ALIASES: 200 + PRINT_YAML_MAX_ALIASES: '200' GRADLE_USER_HOME: /home/gradle/.gradle