fix: repair workflows integrationtests docker #491
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: Install plzip | |
run: sudo apt-get install -y plzip | |
- 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 resources | |
id: restore-cached-image | |
continue-on-error: true | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
ors-test-scenarios-builder.tar.lz | |
ors-test-scenarios-graphs-integrationtests.tar.lz | |
key: ${{ runner.os }}-ors-test-scenarios-builder | |
- name: Load the docker image | |
id: load-docker-image | |
run: | | |
echo "Loading the docker images" | |
if [ -f ors-test-scenarios-builder.tar.lz ]; then | |
# Extract the docker image | |
plzip -cdvvv ors-test-scenarios-builder.tar.lz | docker load && rm -f ors-test-scenarios-builder.tar.lz | |
docker inspect --format {{.Id}} ors-test-scenarios-builder:latest | awk -F: '{print $2}' > 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 inspect --format {{.Id}} ors-test-scenarios-builder:latest | awk -F: '{print $2}' > docker_id_after_build.log || touch docker_id_after_build.log | |
docker_id_after_build=$(cat docker_id_after_build.log) | |
# if one is empty or both are different, then rebuild the graphs | |
if [ -z "${{ env.last_docker_id }}" ] || [ "$docker_id_after_build" != "${{ env.last_docker_id }}" ]; then | |
echo "Rebuilding the graphs" | |
rm -rf ors-test-scenarios-graphs-integrationtests.tar.lz | |
rm -rf ors-test-scenarios/graphs-integrationtests | |
elif [ -f ors-test-scenarios-graphs-integrationtests.tar.lz ]; then | |
echo "Docker id after build is the same as the last one, no need to rebuild the graphs" | |
plzip -cd ors-test-scenarios-graphs-integrationtests.tar.lz | tar -xf - && rm -f ors-test-scenarios-graphs-integrationtests.tar.lz | |
ls -sahlS ors-test-scenarios/graphs-integrationtests | |
fi | |
# Save the last docker id to output | |
echo "docker_id_after_build=$docker_id_after_build" >> "$GITHUB_ENV" | |
echo "List all docker images" | |
docker image ls -a | |
env: | |
ONE_SHOT_IMAGE_BUILDER: true | |
# - name: Rebuild shared graphs | |
# run: | | |
# echo "Rebuilding the shared graphs, if needed" | |
# mvn -pl ors-test-scenarios -Dtest=utils.OneShotImageBuilderTest#oneShotGraphBuilder test | |
# env: | |
# ONE_SHOT_IMAGE_BUILDER: true | |
# - name: Run integration tests | |
# run: | | |
# echo "Running integration tests" | |
# # mvn -pl ors-test-scenarios test -Dtest=ConfigEnvironmentTest | |
# mvn -pl ors-test-scenarios -Dtest=integrationtests.ConfigEnvironmentTest\$ConfigEnvironmentTests\#testMissingConfigButRequiredParamsAsEnvUpperAndLower test | |
- name: Export the docker image to be cached | |
run: | | |
echo "Preparing the workflow cache assets" | |
# Save and compress image | |
docker save ors-test-scenarios-builder:latest | plzip -cvvv > ors-test-scenarios-builder.tar.lz || echo "Could not save ors-test-scenarios-builder" | |
# Save and compress the graphsg | |
tar -cv ors-test-scenarios/graphs-integrationtests | plzip -cvvv > ors-test-scenarios-graphs-integrationtests.tar.lz || echo "Could not save ors-test-scenarios-graphs-integrationtests" | |
- name: Delete previously cached resources | |
continue-on-error: true | |
run: | | |
gh extension install actions/gh-actions-cache | |
gh actions-cache delete "${{ runner.os }}-ors-test-scenarios-builder" --confirm | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Save the resources to cache | |
uses: actions/cache/save@v4 | |
continue-on-error: true | |
with: | |
path: | | |
ors-test-scenarios-builder.tar.lz | |
ors-test-scenarios-graphs-integrationtests.tar.lz | |
key: ${{ runner.os }}-ors-test-scenarios-builder |