Skip to content

test: Add war deployment integration test #56

test: Add war deployment integration test

test: Add war deployment integration test #56

# 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" ]
pull_request:
branches: [ "main" ]
env:
TEST_IMAGE_NAME_WAR: 'local/integration-build-war:latest'
TEST_IMAGE_NAME_WAR_CACHE: '/tmp/integration-build-war.tar'
TEST_IMAGE_NAME_JAR: 'local/integration-build-jar:latest'
TEST_IMAGE_NAME_MVN: 'local/integration-build-mvn:latest'
BUILD_PLATFORMS: 'linux/amd64'
jobs:
# This way the env variables are accessible in the individual jobs
prepare_environment:
name: Prepare the environment variables
runs-on: ubuntu-latest
outputs:
test_image_name_war: ${{ env.TEST_IMAGE_NAME_WAR }}
test_image_name_war_cache: ${{ env.TEST_IMAGE_NAME_WAR_CACHE }}
test_image_name_jar: ${{ env.TEST_IMAGE_NAME_JAR }}
test_image_name_mvn: ${{ env.TEST_IMAGE_NAME_MVN }}
build_platforms: ${{ env.BUILD_PLATFORMS }}
steps:
- run: |
echo "Publish environment variables"
container-build-cache:
name: Docker Buildx cache
runs-on: ubuntu-latest
needs: prepare_environment
strategy:
matrix:
scenario:
# - 'debian-12-jar'
# - 'debian-12-mvn'
- 'debian-12-tomcat-war-systemd'
image: [ ubuntu-latest ]
include:
# - scenario: debian-12-jar
# build_command: -bjm ${{ needs.prepare_environment.outputs.test_image_name }}-jar
# - scenario: debian-12-mvn
# build_command: -bjm ${{ needs.prepare_environment.outputs.test_image_name }}-mvn
- scenario: debian-12-tomcat-war-systemd
cache: ${{ needs.prepare_environment.outputs.test_image_name_war_cache }}
image: ${{ needs.prepare_environment.outputs.test_image_name_war }}
build_command: ./.integration-scenarios/debian-12-tomcat-war-systemd/run.sh -b ${{ needs.prepare_environment.outputs.test_image_name_war }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
- name: Cache the docker image
uses: actions/cache@v4
with:
path: ${{ matrix.cache }}
key: ${{ runner.os }}-tomcat-test-${{ matrix.image }}
restore-keys: |
${{ runner.os }}-tomcat-test-
- name: Load the docker image from cache if available
run: |
if [ -f ${{ matrix.cache }} ]; then
podman load -i ${{ matrix.cache }} || echo "Could not load the image from cache. Building it."
fi
- name: Build the podman image for changes
run: |
bash ${{ matrix.build_command }}
- name: Export the podman image again
run: |
podman save -o ${{ matrix.cache }} ${{ matrix.image }}
debian-12-tomcat-war-systemd:
name: Run Debian 12 Tomcat WAR systemd integration tests
runs-on: ubuntu-latest
needs:
- prepare_environment
- container-build-cache
strategy:
matrix:
test_case: [ '0_*.sh', '1_*.sh', '2_*.sh' ]
image: [ ubuntu-latest ]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
- name: Cache the docker image
uses: actions/cache@v4
with:
path: ${{ needs.prepare_environment.outputs.test_image_name_war_cache }}
key: ${{ runner.os }}-tomcat-test-${{ matrix.image }}
restore-keys: |
${{ runner.os }}-tomcat-test-
- name: Load the docker image from cache if available
run: |
if [ -f ${{ needs.prepare_environment.outputs.test_image_name_war_cache }} ]; then
podman load -i ${{ needs.prepare_environment.outputs.test_image_name_war_cache }} || { echo "Could not load the image from cache. Building it."; exit 1; }
fi
- name: Run integration tests
run: ./.integration-scenarios/debian-12-tomcat-war-systemd/run.sh -t -g '${{ matrix.test_case }}'
# debian-12-jar-mvn-run-tests:
# needs:
# - prepare_environment
# - container-build-cache
# name: Run Debian 12 Maven JAR integration tests
# runs-on: ubuntu-latest
# strategy:
# matrix:
# runtype: [ '-m' , '-j' ]
# testgroup: [ build*car*, build*public*, arg-overrides*, check*, lookup-yml*, missing-config*, specify-yml* ]
# steps:
# - uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
# id: buildx
# with:
# install: true
# - name: Cache Maven packages
# uses: actions/cache@v4
# with:
# path: ~/.m2
# key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
# restore-keys: ${{ runner.os }}-m2
# - name: Run test group with run type
# run: |
# echo "Scenario: ${{ matrix.scenario }}"
# echo "Parameters: ${{ matrix.parameters }}"
# .integration-scenarios/debian-12-jar-mvn/run.sh -b ${{ matrix.runtype }} -t ${{ matrix.testgroup }}