fix: repair workflows integrationtests docker #539
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build a Java project with Maven | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | |
name: Integration test suite | |
on: | |
push: | |
branches: [ "main", "feat/**" ] | |
pull_request: | |
branches: [ "main", "feat/**" ] | |
jobs: | |
build-default-builder: | |
name: Build default builder image | |
runs-on: ubuntu-latest | |
outputs: | |
builder_image_id: ${{ steps.docker_build.outputs.imageid }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up JDK 17 | |
id: setup-java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Cache local Maven repository | |
uses: actions/cache/restore@v4 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Cache Maven dependencies for the ors maven project | |
run: | | |
echo "Sync the maven dependencies" | |
mvn -pl ors-engine,ors-api,ors-test-scenarios package -Dmaven.test.skip=true -B dependency:go-offline dependency:resolve-plugins dependency:resolve -q | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: inject maven-build-cache into docker | |
uses: reproducible-containers/buildkit-cache-dance@v3.1.2 | |
with: | |
cache-map: | | |
{ | |
"/home/runner/.m2": "/root/.m2" | |
} | |
- name: Prepare Build.Dockerfile for the maven caching | |
run: | | |
# Replace RUN mvn dependency:go-offline -B -q with RUN --mount=type=cache,target=/root/.m2 mvn dependency:go-offline -B -q | |
sed -i 's/RUN mvn dependency:go-offline -B -q/RUN --mount=type=cache,target=\/root\/.m2 mvn dependency:go-offline -B -q/' ors-test-scenarios/src/test/resources/Builder.Dockerfile | |
- name: Build ors-test-scenarios-builder | |
id: docker_build | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: false | |
load: true | |
file: ./ors-test-scenarios/src/test/resources/Builder.Dockerfile | |
tags: ors-test-scenarios-builder:latest | |
target: ors-test-scenarios-builder | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Load ors-test-scenarios-jar-builder image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
load: true | |
file: ./ors-test-scenarios/src/test/resources/Builder.Dockerfile | |
tags: ors-test-scenarios-jar-builder:latest | |
target: ors-test-scenarios-jar-builder | |
cache-from: type=gha | |
cache-to: type=gha,mode=min | |
- name: Cache the graph | |
id: cache_builder_images | |
uses: actions/cache@v4 | |
with: | |
path: | | |
ors-test-scenarios/graphs-integrationtests | |
key: ${{ runner.os }}-ors-test-scenarios-builder-images-${{ steps.docker_build.outputs.imageid }} | |
- name: Build shared graph | |
run: | | |
mvn -pl ors-test-scenarios -q -Dtest=utils.OneShotGraphBuilderTest\#oneShotGraphBuilder test \ | |
-Dcontainer.builder.use_prebuild=true \ | |
-Dcontainer.run.scenario=jar | |
env: | |
ONE_SHOT_GRAPH_BUILDER: true | |
integration-tests: | |
name: Parallel integration tests | |
runs-on: ubuntu-22.04 | |
needs: | |
- build-default-builder | |
strategy: | |
matrix: | |
test-scenario: [ "maven", "jar", "war" ] | |
test-class: | |
- integrationtests.ConfigEnvironmentTest | |
- integrationtests.ConfigFileTest | |
- integrationtests.ConfigLookupTest | |
- integrationtests.GeoToolsTest | |
- integrationtests.GraphRepoTest | |
fail-fast: true | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Cache local Maven repository | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Prepare the setup | |
run: | | |
echo "Sync the maven dependencies and build the project" | |
mvn -pl ors-test-scenarios,ors-api,ors-engine package -Dmaven.test.skip=true -B dependency:go-offline dependency:resolve-plugins dependency:resolve -q | |
# Prepare the Dockerfile for efficient caching with buildx | |
sed -i 's/RUN mvn dependency:go-offline -B -q/RUN --mount=type=cache,target=\/root\/.m2 mvn dependency:go-offline -B -q/' ors-test-scenarios/src/test/resources/Builder.Dockerfile | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: inject maven-build-cache into docker | |
uses: reproducible-containers/buildkit-cache-dance@v3.1.2 | |
with: | |
cache-map: | | |
{ | |
"/home/runner/.m2": "/root/.m2" | |
} | |
- name: Restore cached assets | |
id: restore-cached-image | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
ors-test-scenarios/graphs-integrationtests | |
key: ${{ runner.os }}-ors-test-scenarios-builder-images-${{ needs.build-default-builder.outputs.builder_image_id }} | |
- name: Load ors-test-scenarios-builder image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
load: true | |
file: ./ors-test-scenarios/src/test/resources/Builder.Dockerfile | |
tags: ors-test-scenarios-builder:latest | |
target: ors-test-scenarios-builder | |
cache-from: type=gha | |
- name: Load ors-test-scenarios-maven-builder image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
load: true | |
file: ./ors-test-scenarios/src/test/resources/Builder.Dockerfile | |
tags: ors-test-scenarios-maven-builder:latest | |
target: ors-test-scenarios-maven-builder | |
cache-from: type=gha | |
- name: Load ors-test-scenarios-jar-builder image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
load: true | |
file: ./ors-test-scenarios/src/test/resources/Builder.Dockerfile | |
tags: ors-test-scenarios-jar-builder:latest | |
target: ors-test-scenarios-jar-builder | |
cache-from: type=gha | |
- name: Load ors-test-scenarios-war-builder image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
load: true | |
file: ./ors-test-scenarios/src/test/resources/Builder.Dockerfile | |
tags: ors-test-scenarios-war-builder:latest | |
target: ors-test-scenarios-war-builder | |
cache-from: type=gha | |
- name: Run integration tests | |
run: | | |
# List the cached images | |
docker image ls -a | |
# Run only a subset for now | |
mvn -pl ors-test-scenarios -Dtest=${{ matrix.test-class }} test \ | |
-Dcontainer.run.scenario=${{ matrix.test-scenario }} \ | |
-Dcontainer.builder.use_prebuild=true -q | |
# mvn -pl ors-test-scenarios test -P integrationTests \ | |
# -Dcontainer.run.scenario=${{ matrix.test-scenario }} \ | |
# -Dcontainer.builder.use_prebuild=true |