Skip to content

Default Test Execution #13098

Default Test Execution

Default Test Execution #13098

Workflow file for this run

# Basic workflow with Actions
name: Default Test Execution
on:
# Triggers the workflow on push & pull request events for the main branch. Also allows for manual triggers
push:
branches: [ main, develop ]
pull_request:
types:
- opened
- reopened
- synchronize
schedule:
- cron: '0 6 * * *' # Execute every day at noon
workflow_dispatch:
inputs:
distinct_id:
description: 'distinct id for the triggered run from OSS'
required: false
runDescription:
description: 'Description of run'
required: false
runDetails:
description: 'JSON details of run. Provided by automation'
required: false
liquibaseBranch:
description: Liquibase branch to pull artifacts from. Leave empty to use latest commit on current branch. For forks, use the `owner:branch` format. Can support a comma separated list of branches to search for
required: false
liquibaseCommit:
description: Liquibase commit to pull artifacts from. Leave empty to use "liquibaseBranch" setting.
required: false
testClasses:
type: choice
description: Test Suite or test class to run
options:
- LiquibaseHarnessSuiteTest
- FoundationalHarnessSuiteTest
- AdvancedHarnessSuiteTest
- ChangeObjectTests
- ChangeDataTests
- SnapshotObjectTests
- GenerateChangelogTest
- FoundationalTest
ignoreLiquibaseSnapshot:
type: boolean
description: Don't autoconfigure Liquibase Snapshot
liquibaseRepo:
description: Repo pull artifacts from. Defaults to liquibase/liquibase but also supports liquibase/liquibase-pro
required: true
default: "liquibase/liquibase"
databases:
description: Databases to start up. Comma separated list of "name"
required: true
default: |
[
"mysql-5.6",
"mysql-5.7",
"mysql-8",
"percona-xtradb-cluster-5.7",
"percona-xtradb-cluster-8.0",
"postgres-12",
"postgres-13",
"postgres-14",
"postgres-15",
"postgres-16",
"mariadb-10.2",
"mariadb-10.3",
"mariadb-10.4",
"mariadb-10.5",
"mariadb-10.6",
"mariadb-10.7",
"mssql-2017",
"mssql-2019",
"mssql-2022",
"H2Database-2.2",
"crdb-20.2",
"crdb-21.1",
"crdb-21.2",
"crdb-22.1",
"edb-postgres-9.5",
"edb-postgres-9.6",
"edb-postgres-10",
"edb-postgres-11",
"edb-postgres-12",
"edb-postgres-13",
"edb-postgres-14",
"edb-edb-9.5",
"edb-edb-9.6",
"edb-edb-10",
"edb-edb-11",
"edb-edb-12",
"edb-edb-13",
"edb-edb-14",
"derby",
"sqlite",
"hsqldb-2.4",
"hsqldb-2.5",
"firebird-3",
"firebird-4",
"db2-luw"
]
jobs:
authorize:
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-22.04
env:
GITHUB_TOKEN: ${{ secrets.INSTALL_SNAPSHOT_LIQUIBASE }}
outputs:
liquibaseOwner: ${{ steps.configure-build.outputs.liquibaseOwner }}
liquibaseBranch: ${{ steps.configure-build.outputs.liquibaseBranch }}
liquibaseRepo: ${{ steps.configure-build.outputs.liquibaseRepo }}
liquibaseSha: ${{ steps.configure-build.outputs.liquibaseSha }}
databases: ${{ github.event.inputs.databases || '["mysql-5.6","mysql-5.7","mysql-8","percona-xtradb-cluster-5.7","percona-xtradb-cluster-8.0",
"postgres-12","postgres-13","postgres-14","postgres-15","postgres-16","mariadb-10.2","mariadb-10.3","mariadb-10.4","mariadb-10.5","mariadb-10.6",
"mariadb-10.7","mssql-2017","mssql-2019","mssql-2022","H2Database-2.2","crdb-20.2","crdb-21.1","crdb-21.2","crdb-22.1","edb-postgres-9.5","edb-postgres-9.6",
"edb-postgres-10","edb-postgres-11","edb-postgres-12","edb-postgres-13","edb-postgres-14","edb-edb-9.5","edb-edb-9.6","edb-edb-10","edb-edb-11",
"edb-edb-12","edb-edb-13","edb-edb-14","derby","sqlite","hsqldb-2.4","hsqldb-2.5","firebird-3","firebird-4","db2-luw"]' }}
testClasses: ${{ inputs.testClasses || 'LiquibaseHarnessSuiteTest' }}
steps:
- uses: actions/checkout@v4
#https://github.com/Codex-/return-dispatch
- name: echo distinct ID ${{ github.event.inputs.distinct_id }}
run: echo ${{ github.event.inputs.distinct_id }}
- name: Configure Build
id: configure-build
uses: actions/github-script@v7.0.1
with:
github-token: ${{ secrets.INSTALL_SNAPSHOT_LIQUIBASE }}
script: |
const helper = require('./.github/util/workflow-helper.js')({github, context});
let testBranchName = helper.getCurrentBranch();
console.log("Running in liquibase-test-harness branch " + testBranchName);
core.notice("Running in liquibase-test-harness branch " + testBranchName);
console.log("liquibaseBranch == " + "${{ github.event.inputs.liquibaseBranch }}");
core.setOutput("liquibaseBranch", "${{ github.event.inputs.liquibaseBranch }}" || testBranchName+", master");
console.log("liquibaseRepo == " + "${{ github.event.inputs.liquibaseRepo }}");
core.setOutput("liquibaseRepo", "${{ github.event.inputs.liquibaseRepo }}" || "liquibase/liquibase");
let liquibaseRepo = "${{ github.event.inputs.liquibaseRepo || 'liquibase/liquibase' }}";
let repoOwnerName = liquibaseRepo.split("/")[0]
let repoName = liquibaseRepo.split("/")[1]
let liquibaseBranchName = "${{ github.event.inputs.liquibaseBranch }}";
let liquibaseSha = "${{ github.event.inputs.liquibaseCommit }}";
if (!liquibaseSha) {
if (!liquibaseBranchName) {
liquibaseBranchName = testBranchName;
}
console.log("No liquibaseSha passed. Looking for branch "+liquibaseBranchName);
let liquibaseBranchResponse = await helper.findMatchingBranch(repoOwnerName, repoName, [liquibaseBranchName, "master", "main"]);
liquibaseSha = liquibaseBranchResponse.sha;
}
core.setOutput("liquibaseSha", liquibaseSha);
core.setOutput("liquibaseOwner", repoOwnerName);
let runDescription = "${{ github.event.inputs.runDescription }}";
if (!runDescription) {
runDescription = "None given";
}
core.notice("Triggered by this OSS PR: " + runDescription);
let runDetails = null;
if (context.payload && context.payload.inputs && context.payload.inputs.runDetails) {
runDetails = JSON.parse(context.payload.inputs.runDetails);
}
if (!runDetails) {
runDetails = {};
}
if (runDetails.notices) {
for (let notice of runDetails.notices) {
core.notice(notice);
}
}
- 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": "true"
},
"snapshots": {
"enabled": "true",
"updatePolicy": "always"
}
},
{
"id": "liquibase-pro",
"url": "https://maven.pkg.github.com/liquibase/liquibase-pro",
"releases": {
"enabled": "true"
},
"snapshots": {
"enabled": "true",
"updatePolicy": "always"
}
}
]
servers: |
[
{
"id": "liquibase-pro",
"username": "liquibot",
"password": "${{ secrets.LIQUIBOT_PAT }}"
},
{
"id": "liquibase",
"username": "liquibot",
"password": "${{ secrets.LIQUIBOT_PAT }}"
}
]
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Install Snapshot Liquibase
env:
GITHUB_TOKEN: ${{ secrets.INSTALL_SNAPSHOT_LIQUIBASE }}
run: |
mvn -B versions:set-property -Dproperty=liquibase-core.version -DnewVersion=0-SNAPSHOT
mvn -B liquibase-sdk:install-snapshot \
"-Dliquibase.sdk.branchSearch=${{ steps.configure-build.outputs.liquibaseBranch }},master,main,develop" \
"-Dliquibase.sdk.repo=liquibase/liquibase,liquibase/liquibase-pro" \
"-Dliquibase.sdk.proWorkflowId=build.yml"\
"-Dliquibase.sdk.workflowId=run-tests.yml"
mvn -B versions:set-property -Dproperty=liquibase-core.version -DnewVersion=0-SNAPSHOT
mvn liquibase-sdk:install-snapshot-cli \
"-Dliquibase.sdk.branchSearch=${{ steps.configure-build.outputs.liquibaseBranch }},master,main,develop" \
"-Dliquibase.sdk.repo=liquibase/liquibase,liquibase/liquibase-pro" \
"-Dliquibase.sdk.proWorkflowId=build.yml" \
"-Dliquibase.sdk.workflowId=run-tests.yml"
chmod -R 777 bin
ls -l ./bin
bin/liquibase --version
buildOverview="$(mvn -B -q liquibase-sdk:get-build-info '-Dliquibase.sdk.buildInfo.outputKey=overview' '-Dliquibase.sdk.repo=liquibase/liquibase')"
echo "::notice :: Installed Snapshot Liquibase $buildOverview"
buildOverview="$(mvn -B -q liquibase-sdk:get-build-info '-Dliquibase.sdk.buildInfo.outputKey=overview' '-Dliquibase.sdk.repo=liquibase/liquibase-pro')"
echo "::notice :: Installed Snapshot Liquibase-pro $buildOverview"
- name: Cache installed Liquibase
uses: actions/cache@v4
with:
path: ~/.m2/repository/org/liquibase/
key: mvn-liquibase-${{ github.run_id }}-${{ github.run_attempt }}
test:
runs-on: ubuntu-20.04
needs: [ setup, authorize ]
strategy:
fail-fast: false
matrix:
database: ${{ fromJson(needs.setup.outputs.databases) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Cache installed Liquibase
uses: actions/cache@v4
with:
path: ~/.m2/repository/org/liquibase/
key: mvn-liquibase-${{ github.run_id }}-${{ github.run_attempt }}
- name: Build ${{ matrix.database }} test infra
working-directory: src/test/resources/docker
run: ./create-infra.sh ${{ matrix.database }}
env:
REPO_URL: ${{ secrets.REPO_URL }}
REPO_USER: ${{ secrets.REPO_USER }}
REPO_PASSWORD: ${{ secrets.REPO_PASSWORD }}
- name: Configure Liquibase Version
env:
GITHUB_TOKEN: ${{ secrets.INSTALL_SNAPSHOT_LIQUIBASE }}
run: |
mvn -B versions:set-property -Dproperty=liquibase-core.version -DnewVersion=0-SNAPSHOT
- name: ${{ matrix.database }} Test Run
run: ./src/test/resources/automation-runner.sh ${{ matrix.database }} ${{ needs.setup.outputs.testClasses }}
env:
LIQUIBASE_PRO_LICENSE_KEY: ${{ secrets.LICENSE_KEY }}
- name: Archive ${{ matrix.database }} test results
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: ${{ matrix.database }}-test-results
path: build/spock-reports
# GitHub Actions has its own cleanup and this might be redundant
- name: Tear down ${{ matrix.database }} test infra
working-directory: src/test/resources/docker
run: ./teardown-infra.sh ${{ matrix.database }}
finish:
name: Finish
runs-on: ubuntu-22.04
needs: [ setup, test, authorize ]
if: ${{ always() }}
steps:
- uses: actions/checkout@v4
- name: Coordinate Liquibase-Test-Harness
uses: actions/github-script@v6.4.1
with:
github-token: ${{ secrets.BOT_TOKEN }}
script: |
const helper = require('./.github/util/workflow-helper.js')({github, context});
console.log("result is ${{ needs.test.result }}");
let result = "success"
if ("${{ needs.test.result }}" != "success") {
result = "failure";
}
console.log("Mark tests as "+result);
await github.rest.repos.createCommitStatus({
"owner": "${{ needs.setup.outputs.liquibaseOwner }}",
"repo": "liquibase",
"sha": "${{ needs.setup.outputs.liquibaseSha }}",
"state": result,
"context": "Run Test-Harness Tests",
"description": "Test-Harness tests complete",
"target_url": "https://github.com/liquibase/liquibase-test-harness/actions/runs/${{ github.run_id }}"
});