fix-doi-issues #41
Workflow file for this run
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 uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
name: test | |
on: | |
push: | |
branches: [ "main", "master" ] | |
pull_request: | |
# The branches below must be a subset of the branches above | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
test: | |
env: | |
CONTAINER_NAME: "liquibase" | |
strategy: | |
fail-fast: false | |
matrix: | |
dockerfile: [Dockerfile, Dockerfile.alpine] | |
permissions: | |
contents: read | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Build an image from ${{ matrix.dockerfile }} | |
run: | | |
docker build -f ${{ matrix.dockerfile }} -t liquibase/liquibase:${{ github.sha }} . | |
- name: Test init start-h2 | |
run: | | |
docker run --name $CONTAINER_NAME -d -v $(pwd)/.github/test:/liquibase/changelog liquibase/liquibase:${{ github.sha }} init start-h2 | |
sleep 5 | |
docker logs $CONTAINER_NAME | |
LOG_STRING="jdbc:h2:tcp://localhost:9090/mem:dev" | |
# Check if the container is running | |
if docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME" 2>/dev/null | grep -q "true"; then | |
# Get the logs and check if the desired string is present | |
if docker logs "$CONTAINER_NAME" 2>&1 | grep -q "$LOG_STRING"; then | |
echo "The log contains the string: $LOG_STRING" | |
else | |
echo "The log does not contain the string: $LOG_STRING" | |
exit 1 | |
fi | |
else | |
echo "Error: Container $CONTAINER_NAME is not running." | |
exit 2 | |
fi | |
- name: Test Liquibase version | |
run: | | |
docker exec $CONTAINER_NAME liquibase --version | |
docker logs $CONTAINER_NAME | |
LOG_STRING="Liquibase Version:" | |
# Check if the container is running | |
if docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME" 2>/dev/null | grep -q "true"; then | |
# Get the logs and check if the desired string is present | |
if docker logs "$CONTAINER_NAME" 2>&1 | grep -q "$LOG_STRING"; then | |
echo "The log contains the string: $LOG_STRING" | |
else | |
echo "The log does not contain the string: $LOG_STRING" | |
exit 1 | |
fi | |
else | |
echo "Error: Container $CONTAINER_NAME is not running." | |
exit 2 | |
fi | |
- name: Test Liquibase update | |
run: | | |
LOG_STRING="Update has been successful" | |
# Check if the container is running | |
if docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME" 2>/dev/null | grep -q "true"; then | |
# Get the logs and check if the desired string is present | |
if docker exec $CONTAINER_NAME liquibase update --defaultsFile=/liquibase/changelog/liquibase.properties --changelog-file=/changelog/example-changelog.xml 2>&1 | grep -q "$LOG_STRING"; then | |
echo "The log contains the string: $LOG_STRING" | |
else | |
echo "The log does not contain the string: $LOG_STRING" | |
exit 1 | |
fi | |
else | |
echo "Error: Container $CONTAINER_NAME is not running." | |
exit 2 | |
fi |