generated from liquibase/liquibase-extension-example
-
Notifications
You must be signed in to change notification settings - Fork 7
139 lines (126 loc) · 5.36 KB
/
lth.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Liquibase Test Harness
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
# static value to the workflow group to ensure only one run of the workflow can be in progress at a time.
concurrency:
group: liquibase-test-harness
cancel-in-progress: false
jobs:
liquibase-test-harness:
name: Liquibase Test Harness
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
contents: write
env:
TF_VAR_DBX_HOST: ${{ secrets.TH_DATABRICKS_WORKSPACE_HOST }}
TF_VAR_DBX_TOKEN: ${{ secrets.TH_DATABRICKS_WORKSPACE_TOKEN }}
TF_VAR_TEST_CATALOG: main
TF_VAR_TEST_SCHEMA: liquibase_harness_test_ds
WORKSPACE_ID: ${{ secrets.TH_DATABRICKS_WORKSPACE_ID }}
LIQUIBOT_TOKEN: ${{ secrets.LIQUIBOT_PAT }}
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
strategy:
max-parallel: 1
matrix:
liquibase-support-level: [Foundational, Contributed, Advanced] # Define the different test levels to run
fail-fast: false # Set fail-fast to false to run all test levels even if some of them fail
steps:
- name: Checkout code
uses: actions/checkout@v4
- run: terraform init
working-directory: src/test/terraform
- run: terraform plan
working-directory: src/test/terraform
- run: |
terraform import databricks_schema.test_harness main.liquibase_harness_test_ds || true
terraform taint databricks_schema.test_harness || true
terraform apply -auto-approve
working-directory: src/test/terraform
- name: Collect Databricks Config
working-directory: src/test/terraform
run: |
CLUSTER_ID=$(terraform output -raw endpoint_url)
DATABRICKS_HOST=${TF_VAR_DBX_HOST#https://}
echo "DATABRICKS_URL=jdbc:databricks://$DATABRICKS_HOST:443/default;transportMode=http;ssl=1;httpPath=/sql/1.0/warehouses/$CLUSTER_ID;AuthMech=3;ConnCatalog=$TF_VAR_TEST_CATALOG;ConnSchema=$TF_VAR_TEST_SCHEMA;EnableArrow=0" >> "$GITHUB_ENV"
- name: Setup Temurin Java 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
cache: '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 }}"
}
]
- name: Build with Maven # Build the code with Maven (skip tests)
run: mvn -B -ntp -Dmaven.test.skip package -Dliquibase.version=master-SNAPSHOT
- name: Run ${{ matrix.liquibase-support-level }} Liquibase Test Harness # Run the Liquibase test harness at each test level
if: always() # Run the action even if the previous steps fail
run: mvn -B -ntp -DdbPassword=${{env.TF_VAR_DBX_TOKEN}} -DdbUrl='${{env.DATABRICKS_URL}}' -Dtest=liquibase.ext.databricks.${{ matrix.liquibase-support-level }}ExtensionHarnessTestSuite test -Dliquibase.version=master-SNAPSHOT # Run the Liquibase test harness at each test level
- name: Test Reporter # Generate a test report using the Test Reporter action
uses: dorny/[email protected]
if: always() # Run the action even if the previous steps fail
with:
name: Liquibase Test Harness - ${{ matrix.liquibase-support-level }} Reports # Set the name of the test report
path: target/surefire-reports/TEST-*.xml # Set the path to the test report files
reporter: java-junit # Set the reporter to use
fail-on-error: false # Set fail-on-error to false to show report even if it has failed tests
- name: Stop test database
if: always() # Always destroy, even if the previous steps fail
working-directory: src/test/terraform
run: |
set -e
TERRAFORM_OUTPUT=$(terraform show -json)
if [ -z "$TERRAFORM_OUTPUT" ]; then
echo "Terraform output is empty. Skipping removal."
else
SCHEMA_EXISTS=$(echo $TERRAFORM_OUTPUT | jq -r '.values.root_module.resources[] | select(.address == "databricks_schema.test_harness") | .values.name')
if [ "$SCHEMA_EXISTS" == "liquibase_harness_test_ds" ]; then
terraform destroy -auto-approve
else
echo "Schema does not exist. Skipping removal."
fi
fi