-
Notifications
You must be signed in to change notification settings - Fork 18
166 lines (148 loc) · 7.16 KB
/
gcp.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Terraform Action to test Cloud Databases with test-harness
name: Google Cloud Database Test Execution
concurrency: gcp-run
on:
# Triggers the workflow on a schedule for the main branch. Also allows for manual triggers
schedule:
- cron: '0 6 * * *' # Execute every day at 6AM UTC
workflow_dispatch:
inputs:
testClasses:
type: choice
description: Test Suite or test class to run
options:
- AdvancedHarnessSuiteTest
- LiquibaseHarnessSuiteTest
- FoundationalHarnessSuiteTest
- ChangeObjectTests
- ChangeDataTests
- SnapshotObjectTests
- GenerateChangelogTest
- FoundationalTest
databases:
description: Databases to start up. Comma separated list of "name:version"
required: true
default: "[\"postgresql:12\",\"postgresql:13\",\"postgresql:14\",\"mysql:gcp\",\"mssql:gcp\"]"
jobs:
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
databases: ${{ github.event.inputs.databases || '["postgresql:12","postgresql:13","postgresql:14","mysql:gcp","mssql:gcp"]' }}
testClasses: ${{ inputs.testClasses || 'LiquibaseHarnessSuiteTest' }}
steps:
- name: Checkout
uses: actions/checkout@v4
init-mysql:
runs-on: ubuntu-latest
container:
image: liquibase/liquibase:latest
env:
LIQUIBASE_PRO_LICENSE_KEY: ${{ secrets.LICENSE_KEY }}
strategy:
fail-fast: false
matrix:
include:
- database: mysql
version: gcp
steps:
- name: Checkout
uses: actions/checkout@v4
# This additional init step is required because of mysql driver issue on GH actions
- name: Install Dependencies
run: lpm update && lpm add mysql
- name: Clean GCP MySQL Database
uses: liquibase-github-actions/[email protected]
if: ${{ matrix.version == 'gcp' }}
with:
url: "${{ secrets.TH_GCP_MYSQL_8_0_URL }}"
username: "${{secrets.TH_DB_ADMIN}}"
password: "${{secrets.TH_DB_PASSWD}}"
licenseKey: "${{secrets.LICENSE_KEY}}"
force: true
requireForce: true
- name: Init Database
if: ${{ matrix.version == 'gcp' }}
run: liquibase --classpath="src/test/resources/init-changelogs/gcp" --changeLogFile="${{ matrix.database }}.sql" --username="${{ secrets.TH_DB_ADMIN }}" --password="${{ secrets.TH_DB_PASSWD }}" --url="${{ secrets.TH_GCP_MYSQL_8_0_URL }}" update
test:
needs: [init-mysql, setup]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
database: ${{ fromJson(needs.setup.outputs.databases) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure Test
id: setup
uses: actions/[email protected]
with:
script: |
let splitValues = "${{ matrix.database }}".split(":")
core.setOutput("databasePlatform", splitValues[0]);
core.setOutput("databaseVersion", splitValues[1]);
- uses: liquibase-github-actions/[email protected]
if: ${{ steps.setup.outputs.databasePlatform == 'postgresql' }}
with:
url: "${{ secrets[format('TH_GCP_POSTGRESQL_{0}_URL', steps.setup.outputs.databaseVersion)] }}"
username: "${{secrets.TH_DB_ADMIN}}"
password: "${{secrets.TH_DB_PASSWD}}"
licenseKey: "${{secrets.LICENSE_KEY}}"
force: true
requireForce: true
- uses: liquibase/liquibase-github-action@v7
if: ${{ steps.setup.outputs.databasePlatform == 'postgresql' }}
with:
operation: "update"
classpath: "src/test/resources/init-changelogs/aws"
changeLogFile: "postgresql.sql"
username: "${{secrets.TH_DB_ADMIN}}"
password: "${{secrets.TH_DB_PASSWD}}"
url: "${{ secrets[format('TH_GCP_POSTGRESQL_{0}_URL', steps.setup.outputs.databaseVersion)] }}"
- uses: liquibase-github-actions/[email protected]
if: ${{ steps.setup.outputs.databasePlatform == 'mssql' }}
with:
url: "${{ secrets.TH_GCP_MSSQL_2019_URL }}"
username: "${{secrets.TH_DB_ADMIN}}"
password: "${{secrets.TH_DB_PASSWD}}"
licenseKey: "${{secrets.LICENSE_KEY}}"
force: true
requireForce: true
- uses: liquibase/liquibase-github-action@v7
if: ${{ steps.setup.outputs.databasePlatform == 'mssql' }}
with:
operation: "update"
classpath: "src/test/resources/init-changelogs/gcp"
changeLogFile: "mssql.sql"
username: "${{secrets.TH_DB_ADMIN}}"
password: "${{secrets.TH_DB_PASSWD}}"
url: "${{ secrets.TH_GCP_MSSQL_2019_URL }}"
- name: Cache local Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: GCP ${{ steps.setup.outputs.databasePlatform }}-${{ steps.setup.outputs.databaseVersion }} Test Run
if: ${{ steps.setup.outputs.databasePlatform == 'postgresql' }}
env:
LIQUIBASE_PRO_LICENSE_KEY: ${{ secrets.LICENSE_KEY }}
run: mvn -Dtest=${{ needs.setup.outputs.testClasses }} -DconfigFile=/harness-config-cloud.yml -DdbName=${{ steps.setup.outputs.databasePlatform }} -DdbVersion=${{ steps.setup.outputs.databaseVersion }} -Dprefix=gcp -DdbUsername=${{secrets.TH_DB_ADMIN}} -DdbPassword=${{secrets.TH_DB_PASSWD}} -DdbUrl='${{ secrets[format('TH_GCP_POSTGRESQL_{0}_URL', steps.setup.outputs.databaseVersion)] }}' test
- name: GCP ${{ steps.setup.outputs.databasePlatform }}-${{ steps.setup.outputs.databaseVersion }} Test Run
if: ${{ steps.setup.outputs.databasePlatform == 'mysql' }}
env:
LIQUIBASE_PRO_LICENSE_KEY: ${{ secrets.LICENSE_KEY }}
run: mvn -Dtest=${{ needs.setup.outputs.testClasses }} -DconfigFile=/harness-config-cloud.yml -DdbName=${{ steps.setup.outputs.databasePlatform }} -DdbVersion=${{ steps.setup.outputs.databaseVersion }} -DdbUsername=${{secrets.TH_DB_ADMIN}} -DdbPassword=${{secrets.TH_DB_PASSWD}} -DdbUrl='${{ secrets.TH_GCP_MYSQL_8_0_URL }}' test
- name: GCP ${{ steps.setup.outputs.databasePlatform }}-${{ steps.setup.outputs.databaseVersion }} Test Run
if: ${{ steps.setup.outputs.databasePlatform == 'mssql' }}
env:
LIQUIBASE_PRO_LICENSE_KEY: ${{ secrets.LICENSE_KEY }}
LIQUIBASE_LIQUIBASE_SCHEMA_NAME: lbuser
run: mvn -Dtest=${{ needs.setup.outputs.testClasses }} -DconfigFile=/harness-config-cloud.yml -DdbName=${{ steps.setup.outputs.databasePlatform }} -DdbVersion=${{ steps.setup.outputs.databaseVersion }} -Dprefix=gcp -DdbUsername=${{secrets.TH_DB_ADMIN}} -DdbPassword=${{secrets.TH_DB_PASSWD}} -DdbUrl='${{ secrets.TH_GCP_MSSQL_2019_URL }}' test
- name: Archive GCP ${{ steps.setup.outputs.databasePlatform }}-${{ steps.setup.outputs.databaseVersion }} Test Results
uses: actions/upload-artifact@v4
with:
name: gcp-${{ steps.setup.outputs.databasePlatform }}-${{ steps.setup.outputs.databaseVersion }}-test-results
path: build/spock-reports