fix: repair workflows integrationtests docker #468
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: | |
ors-test-scenarios: | |
name: Build with Maven and Docker caches | |
runs-on: ubuntu-latest | |
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' | |
cache: 'maven' | |
cache-dependency-path: ./pom.xml | |
- name: Restore cached ors test image | |
id: restore-cached-image | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
ors-test-scenario-builder.tar | |
key: ${{ runner.os }}-ors-test-scenario-builder | |
- name: Load the docker image | |
id: load-docker-image | |
run: | | |
echo "Loading the docker images" | |
if [ -f ors-test-scenario-builder.tar ]; then | |
docker load -i ors-test-scenario-builder.tar | |
docker inspect --format {{.Id}} ors-test-scenario-builder:latest > last_image_build_id.log || touch last_image_build_id.log | |
# I get the docker last image id from a file | |
last_docker_id=$(cat last_image_build_id.log) | |
# Add last_docker_id to output | |
echo "last_docker_id=$last_docker_id" >> "$GITHUB_ENV" | |
fi | |
echo "List all docker images" | |
docker image ls -a | |
- name: Cache Maven dependencies for the ors maven project | |
run: | | |
echo "Caching the maven dependencies" | |
mvn -pl ors-test-scenarios package -Dmaven.test.skip=true -B dependency:go-offline -q | |
- name: Test if the graphs need to be rebuilt | |
id: build-one-shot-image | |
run: | | |
echo "Building the docker image with the one shot builder" | |
mvn -pl ors-test-scenarios -Dtest=utils.OneShotImageBuilderTest#oneShotImageBuilder test | |
docker_id_after_build=$(docker inspect --format {{.Id}} ors-test-scenario-builder:latest) | |
if [ "$docker_id_after_build" != ${{ steps.load-docker-image.outputs.last_docker_id }} ]; then | |
echo "rebuild_graphs=true" >> "$GITHUB_ENV" | |
else | |
echo "rebuild_graphs=false" >> "$GITHUB_ENV" | |
fi | |
# Save the last docker id to output | |
echo "last_docker_id=$docker_id_after_build" >> "$GITHUB_ENV" | |
echo "List all docker images" | |
docker image ls -a | |
- name: Restore shared graphs | |
id: restore-cached-graphs | |
if: steps.check-graphs.outputs.rebuild_graphs == 'false' | |
uses: actions/cache/restore@v4 | |
with: | |
path: ors-test-scenarios/graphs-integrationtests | |
key: ${{ runner.os }}-ors-test-scenarios-graphs-integrationtests-${{ steps.load-docker-image.outputs.last_docker_id }} | |
- name: Rebuild shared graphs | |
run: | | |
echo "Rebuilding the shared graphs, if needed" | |
mvn -pl ors-test-scenarios -Dtest=utils.OneShotImageBuilderTest#oneShotGraphBuilder test | |
- name: Export the docker image to be cached | |
run: | | |
echo "Exporting the complete builder image" | |
docker save -o ors-test-scenario-builder.tar ors-test-scenario-builder:latest | |
- name: Save the docker image to the cache | |
uses: actions/cache/save@v4 | |
with: | |
path: | | |
ors-test-scenario-builder.tar | |
key: ${{ runner.os }}-ors-test-scenario-builder | |
- name: Save the shared graphs to the cache | |
uses: actions/cache/save@v4 | |
with: | |
path: ors-test-scenarios/graphs-integrationtests | |
key: ${{ runner.os }}-ors-test-scenarios-graphs-integrationtests-${{ steps.build-one-shot-image.outputs.docker_id_after_build }} | |
- name: Run integration tests | |
run: | | |
echo "Running integration tests" | |
mvn -pl ors-test-scenarios test -Dtest=ConfigEnvironmentTest |