Skip to content

H2 tests may end up with an incorrect list of the standard DatabaseObject types, so we need to reset the factory #2199

H2 tests may end up with an incorrect list of the standard DatabaseObject types, so we need to reset the factory

H2 tests may end up with an incorrect list of the standard DatabaseObject types, so we need to reset the factory #2199

Workflow file for this run

name: Run Tests
on:
workflow_call:
workflow_dispatch:
inputs:
archive_test_results:
description: 'If set to true, the unit and integration test results will be archived to the build artifacts page.'
required: false
default: 'false'
push:
branches:
- master
pull_request_target:
types:
- opened
- reopened
- synchronize
paths-ignore:
- '**.md'
jobs:
authorize:
#concurrent runs for pull requests from forked repositories will be canceled, while runs for pull requests from the master repository won't be affected.
#for a pull_request against master: the concurrency check will cancel commit A so that commit B check can run.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref == 'master' && (github.event_name == 'push' && 'push-to-master' || github.event_name == 'pull_request' && 'merge-to-master') || github.event_name == 'pull_request_target' && github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' && github.base_ref == 'master' }}
environment: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && 'external' || 'internal' }}
runs-on: ubuntu-latest
steps:
- run: true
setup:
name: setup
needs: authorize
runs-on: ubuntu-20.04
outputs:
timestamp: ${{ steps.get-date.outputs.date }}
latestMergeSha: ${{ steps.get-sha.outputs.latestMergeSha }}
thisBranchName: ${{ steps.get-branch-name.outputs.thisBranchName }}
setupSuccessful: "true"
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Get current date
id: get-date
run: |
echo "date=$(date +'%Y-%m-%d %H:%M:%S %Z')" >> $GITHUB_OUTPUT
- name: Get Latest Merge Commit SHA
id: get-sha
run: |
latest_merge_sha=`(git rev-parse HEAD)`
echo "latestMergeSha=${latest_merge_sha}" >> $GITHUB_OUTPUT
- name: Get Current BranchName
id: get-branch-name
run: |
# this logic checks if the branch is from a forked repository PR or not. Where -n is the inverse of -z (not empty)
if [ -n "${GITHUB_HEAD_REF}" ];
then
branch_name=${GITHUB_HEAD_REF}
else
branch_name=${{ github.ref_name }}
fi
modified_branch_name=`(echo $branch_name | tr '/_' '-')`
echo "thisBranchName=$modified_branch_name" >> $GITHUB_OUTPUT
echo $modified_branch_name
build_tests:
name: Run Test for (Java ${{ matrix.java }} ${{ matrix.os }})
needs: setup
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, macos-13, windows-2019 ]
java: [ 8, 11, 17, 21 ]
exclude:
# exclude non-java 8 on macos and windows builds
- os: macos-13
java: 11
- os: windows-2019
java: 11
- os: macos-13
java: 17
- os: windows-2019
java: 17
- os: macos-13
java: 21
- os: windows-2019
java: 21
runs-on: ${{ matrix.os }}
env:
OS_TYPE: ${{ matrix.os }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.event.after}}
- name: Built Code Cache
if: ${{ matrix.java == 17}}
uses: actions/cache@v4.0.2
with:
key: built-code-${{ github.run_number }}-${{ github.run_attempt }}
path: ./**/target
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'maven'
# look for dependencies in maven
- name: maven-settings-xml-action
uses: whelk-io/maven-settings-xml-action@v22
with:
repositories: |
[
{
"id": "liquibase",
"url": "https://maven.pkg.github.com/liquibase/liquibase",
"releases": {
"enabled": "false"
},
"snapshots": {
"enabled": "true",
"updatePolicy": "always"
}
},
{
"id": "liquibase-pro",
"url": "https://maven.pkg.github.com/liquibase/liquibase-pro",
"releases": {
"enabled": "false"
},
"snapshots": {
"enabled": "true",
"updatePolicy": "always"
}
}
]
servers: |
[
{
"id": "liquibase-pro",
"username": "liquibot",
"password": "${{ secrets.LIQUIBOT_PAT }}"
},
{
"id": "liquibase",
"username": "liquibot",
"password": "${{ secrets.LIQUIBOT_PAT }}"
}
]
# getting from build results page. If we remove 0-snapshot then we will need settings.xml
- name: Build & Test Java 8
if: ${{ matrix.java == 8}}
run: |
./mvnw -B "-Dbuild.repository.owner=liquibase" "-Dbuild.repository.name=liquibase" "-Dbuild.branch=${{ needs.setup.outputs.thisBranchName }}" "-Dbuild.number=${{ github.run_number }}" "-Dbuild.commit=${{ needs.setup.outputs.latestMergeSha }}" "-DtrimStackTrace=false" -P 'skip-integration-tests' -pl '!liquibase-cdi-jakarta' clean test package surefire-report:report
- name: Build & Test Java non-jdk-8
if: ${{ matrix.java != 8}}
run: |
./mvnw -B "-Dbuild.repository.owner=liquibase" "-Dbuild.repository.name=liquibase" "-Dbuild.branch=${{ needs.setup.outputs.thisBranchName }}" "-Dbuild.number=${{ github.run_number }}" "-Dbuild.commit=${{ needs.setup.outputs.latestMergeSha }}" "-DtrimStackTrace=false" -P 'skip-integration-tests' clean test package surefire-report:report
- name: Remove Original Jars for *nix
if: env.OS_TYPE != 'windows-2019'
run: |
find . -name original-*.jar -exec rm {} \;
- name: Upload Artifacts for build.yml
if: ${{ matrix.java == 17 && matrix.os == 'ubuntu-20.04'}}
uses: actions/upload-artifact@v3
with:
name: temp-artifact
path: |
./**/target/*.jar
- name: Archive Test Results
if: ${{ inputs.archive_test_results == 'true' }}
uses: actions/upload-artifact@v3
with:
name: liquibase-test-results-jdk${{ matrix.java }}
path: |
./**/target/surefire-reports
./**/target/site
- name: Save Jacoco Report for Sonar
if: ${{ matrix.java == 17 && matrix.os == 'ubuntu-20.04'}}
uses: actions/upload-artifact@v3
with:
name: liquibase-jacoco-test-results
path: |
./liquibase-standard/target/jacoco.exec
- name: Archive Modules
if: ${{ matrix.java == 17 && matrix.os == 'ubuntu-20.04'}}
uses: actions/upload-artifact@v3
with:
name: liquibase-modules
path: |
*/target/*-0-SNAPSHOT.jar
integration-test:
name: Integration Test
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
testSystem:
- db2
- h2
#- h2:1.4
- hsqldb
- mariadb
- mssql
- mysql
- oracle
- postgresql
- sqlite
- firebird
needs: build_tests
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.event.after}}
- name: Prepare
id: prepare
uses: actions/github-script@v7
with:
script: |
core.setOutput("testResultsArtifact", "liquibase-test-results-integration-${{ matrix.testSystem }}".replace(/[^a-zA-Z0-9\-_]/g, "_"));
- name: Set up JDK 17
if: ${{ matrix.testSystem != 'snowflake' }}
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Set up JDK 11 # get rid of this after https://github.com/snowflakedb/snowflake-jdbc/issues/589 is fixed
if: ${{ matrix.testSystem == 'snowflake' }}
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
cache: 'maven'
# getting from build results page. If we remove 0-snapshot then we will need settings.xml
- name: Restore Built Code Cache
uses: actions/cache@v4.0.2
with:
key: built-code-${{ github.run_number }}-${{ github.run_attempt }}
path: ./**/target
- name: Setup Python
if: ${{ matrix.testSystem == 'snowflake' }}
uses: actions/setup-python@v5.1.0
with:
python-version: '3.12.1'
- name: Start & Configure LocalStack
if: ${{ matrix.testSystem == 'snowflake' }}
env:
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
pip install localstack awscli-local
DEBUG=1 DOCKER_FLAGS='-e SF_LOG=trace' IMAGE_NAME=localstack/snowflake localstack start -d
echo "Waiting for LocalStack startup..."
localstack wait -t 30
echo "Startup complete"
echo "TH_DB_ADMIN=test" >> $GITHUB_ENV
echo "TH_DB_PASSWD=test" >> $GITHUB_ENV
echo "TH_DB=snowflake" >> $GITHUB_ENV
echo "TH_SNOW_URL=jdbc:snowflake://http://snowflake.localhost.localstack.cloud:4566" >> $GITHUB_ENV
- name: Run Tests
run: ./mvnw -B clean verify -DtrimStackTrace=false -Dliquibase.sdk.testSystem.test=${{ matrix.testSystem }} -Dliquibase.sdk.testSystem.acceptLicenses=${{ matrix.testSystem }} -Dliquibase.sdk.testSystem.snowflake.url=${{ env.TH_SNOW_URL }} -Dliquibase.sdk.testSystem.snowflake.username=${{ env.TH_DB_ADMIN }} -Dliquibase.sdk.testSystem.snowflake.password=${{ env.TH_DB_PASSWD }} -Dtest=*IntegrationTest,*ExecutorTest -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false
- name: Archive Test Results
if: ${{ inputs.archive_test_results == 'true' }}
uses: actions/upload-artifact@v3
with:
name: ${{ steps.prepare.outputs.testResultsArtifact }}
path: |
./**/target/surefire-reports
- name: Save Jacoco Report for Sonar
uses: actions/upload-artifact@v3
with:
name: liquibase-integration-jacoco-test-results-${{ matrix.testSystem }}
path: |
./liquibase-integration-tests/target/jacoco.exec
sonar:
needs: [ build_tests, integration-test ]
uses: liquibase/build-logic/.github/workflows/sonar-test-scan.yml@v0.7.7
with:
thisBranchName: ${{ needs.setup.outputs.thisBranchName }}
thisSha: ${{ needs.setup.outputs.thisSha }}
liquibaseBranchName: ${{ needs.setup.outputs.liquibaseBranchName }}
pullRequestNumber: ${{ github.event.pull_request.number }}
pullRequestBranchName: ${{ github.event.pull_request.head.ref }}
pullRequestBaseBranchName: ${{ github.event.pull_request.base.ref }}
testedClassesModuleName: liquibase-standard
dbPlatforms: h2,hsqldb,mariadb,mssql,mysql,oracle,postgresql,sqlite,firebird,db2
secrets: inherit
run-build-publish-file:
needs: [ build_tests,integration-test ]
uses: liquibase/liquibase/.github/workflows/build.yml@master
secrets: inherit