Skip to content

Commit

Permalink
Extract the code style and test from the Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jun 5, 2023
1 parent c283ec9 commit ccda98d
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 86 deletions.
10 changes: 5 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ ci
build/
*/build/

examples/*.jasper
examples/src/test/resources/examples_to_port
examples/src/test/resources/examples
examples/geoserver-data
core/docker/
core/src/test/

core/docker
examples/*.jasper
examples/src/test/
examples/geoserver-data/
59 changes: 20 additions & 39 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,59 +82,40 @@ 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
if: failure()

- 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/
if-no-files-found: ignore
if: failure()
- run: make checks
- uses: actions/upload-artifact@v3
with:
name: Reports examples
path: examples/build/reports
name: Checkstyle and Spotbugs reports
path: reports
if-no-files-found: ignore
if: failure()
if: always()

- run: make tests

- uses: actions/upload-artifact@v3
with:
name: Reports core
path: core/build/reports
name: Unit test results
path: core/build/resources/test/org/mapfish/print/
if-no-files-found: ignore
if: failure()
- uses: actions/upload-artifact@v3
with:
name: Examples
path: examples/build/resources/test/examples
name: Unit test report
path: core/build/reports/tests/test/
if-no-files-found: ignore
if: failure()
if: always()

- run: make acceptance-tests-up
- run: make acceptance-tests-run
- run: c2cciutils-docker-logs || true
if: always()

- 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
name: Acceptance tests (Examples)
path: examples/build/resources/test/examples/
if-no-files-found: ignore
if: failure()

- name: Publish
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
/build/
/*/build/

/docker-compose.override.yaml

/CI.asc
4 changes: 4 additions & 0 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Known breaking changes

## Version 3.31

- `HumanAlphaSerie` is moved from package `org.mapfish.print` to `org.mapfish.print.jasperreports`.

## Version 3.30

- Add support of MapServer 8.0, remove support of MapServer <= 7.4 (MAP_ANGLE => ANGLE).
Expand Down
44 changes: 21 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,42 @@ 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 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 out 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 --parallel --exclude-task=:core:test \
--exclude-task=:core:spotbugsMain --exclude-task=:core:checkstyleMain --exclude-task=:core:violations \
--exclude-task=:core:spotbugsTest --exclude-task=:core:checkstyleTest --exclude-task=:core:testCLI \
:core:build :core:explodedWar :publish:build :examples:build :docs: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
cp -r /home/gradle/.gradle /home/gradle/.gradle-backup
RUN mv /home/gradle/.gradle-backup /home/gradle/.gradle

RUN cat /tmp/logs && ls success success-publish success-examples-docs

VOLUME [ "/src/core" ]
COPY checkstyle_* ./
35 changes: 29 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,42 @@ 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
mkdir --parent reports
docker run --rm --user=$(shell id -u):$(shell id -g) \
--volume=$(PWD)/core/src/:/src/core/src/:ro \
--volume=$(PWD)/reports/:/src/core/build/reports/ \
mapfish_print_builder \
gradle --parallel :core:spotbugsMain :core:checkstyleMain :core:violations

.PHONY: tests
tests: build-builder
mkdir --parent core/build/reports/
mkdir --parent core/build/resources/
docker run --rm --user=$(shell id -u):$(shell id -g) \
--volume=$(PWD)/core/src/:/src/core/src/:ro \
--volume=$(PWD)/core/build/reports/:/src/core/build/reports/ \
--volume=$(PWD)/core/build/resources/:/src/core/build/resources/ \
mapfish_print_builder \
gradle --parallel --exclude-task=:core:spotbugsMain --exclude-task=:core:checkstyleMain --exclude-task=:core:violations \
--exclude-task=:core:spotbugsTest --exclude-task=:core:checkstyleTest \
:core:test

.PHONY: acceptance-tests-up
acceptance-tests-up:
acceptance-tests-up: build
docker-compose down --remove-orphan

mkdir /tmp/geoserver-data || true
Expand All @@ -24,7 +47,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:
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ configure(subprojects.findAll { ['core', 'examples'].contains(it.name) }) {
tasks.register('violations', ViolationsTask) {
minSeverity = 'INFO'
detailLevel = 'VERBOSE' // PER_FILE_COMPACT, COMPACT or VERBOSE
maxViolations = 1070
maxViolations = 1071
printViolations = true
violations = [
["FINDBUGS", ".", ".*/reports/spotbugsReports/.*\\.xml", "Spotbugs"],
Expand All @@ -71,8 +71,8 @@ configure(subprojects.findAll { ['core', 'examples'].contains(it.name) }) {
}
check.finalizedBy violations

sourceCompatibility = 1.11
targetCompatibility = 1.11
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

compileJava.options.compilerArgs = ['-Xlint:deprecation', '-Xlint:unchecked']

Expand Down
1 change: 0 additions & 1 deletion core/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ RUN --mount=type=cache,target=/var/cache,sharing=locked \
fonts-liberation fonts-dejavu fontconfig

COPY --from=builder /src/core/build/webapp "${CATALINA_HOME}/webapps/ROOT/"
COPY --from=builder /src/examples/build/classes/java/test/org/mapfish/print/HumanAlphaSerie.class "${CATALINA_HOME}/webapps/ROOT/WEB-INF/classes/org/mapfish/print/"
COPY docker /

RUN mkdir -p "${CATALINA_HOME}/extlib/classes/org/mapfish/print" \
Expand Down
9 changes: 5 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -24,7 +24,8 @@ services:
user: ${USER_ID}
command: tail --follow /dev/null
volumes:
- ./examples/src/test/resources/examples:/src/examples/src/test/resources/examples
- ./examples/src/test/resources/examples:/src/examples/src/test/resources/examples:ro
- ./examples/build/reports:/src/examples/build/reports
environment:
PRINT_YAML_MAX_ALIASES: 200
PRINT_YAML_MAX_ALIASES: '200'
GRADLE_USER_HOME: /home/gradle/.gradle
10 changes: 5 additions & 5 deletions examples/src/test/resources/examples/paging/simpleReport.jrxml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
<field name="left" class="java.lang.Integer"/>
<field name="right" class="java.lang.Integer"/>
<variable name="name" class="java.lang.String">
<variableExpression><![CDATA[org.mapfish.print.HumanAlphaSerie.toString($F{name})]]></variableExpression>
<variableExpression><![CDATA[org.mapfish.print.jasperreports.HumanAlphaSerie.toString($F{name})]]></variableExpression>
</variable>
<variable name="top" class="java.lang.String">
<variableExpression><![CDATA[org.mapfish.print.HumanAlphaSerie.toString($F{top})]]></variableExpression>
<variableExpression><![CDATA[org.mapfish.print.jasperreports.HumanAlphaSerie.toString($F{top})]]></variableExpression>
</variable>
<variable name="bottom" class="java.lang.String">
<variableExpression><![CDATA[org.mapfish.print.HumanAlphaSerie.toString($F{bottom})]]></variableExpression>
<variableExpression><![CDATA[org.mapfish.print.jasperreports.HumanAlphaSerie.toString($F{bottom})]]></variableExpression>
</variable>
<variable name="left" class="java.lang.String">
<variableExpression><![CDATA[org.mapfish.print.HumanAlphaSerie.toString($F{left})]]></variableExpression>
<variableExpression><![CDATA[org.mapfish.print.jasperreports.HumanAlphaSerie.toString($F{left})]]></variableExpression>
</variable>
<variable name="right" class="java.lang.String">
<variableExpression><![CDATA[org.mapfish.print.HumanAlphaSerie.toString($F{right})]]></variableExpression>
<variableExpression><![CDATA[org.mapfish.print.jasperreports.HumanAlphaSerie.toString($F{right})]]></variableExpression>
</variable>
<title>
<band height="390" splitType="Stretch">
Expand Down

0 comments on commit ccda98d

Please sign in to comment.