-
Notifications
You must be signed in to change notification settings - Fork 13
190 lines (145 loc) · 5.53 KB
/
integration-sql.yaml
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: Integration (SQL)
on:
workflow_call:
inputs:
matrix:
required: true
type: string
dialect:
required: true
type: string
db_image:
required: true
type: string
db_port:
required: true
type: number
db_options:
required: false
type: string
# Use latest supported language versions for integration testing
env:
JAVA_VERSION: "21"
JAVA_DISTRIBUTION: "zulu"
PYTHON_VERSION: "3.12"
NODE_VERSION: "22"
jobs:
int-metadb:
name: int-metadb-java-${{ inputs.dialect }}
env:
BUILD_sql_${{ inputs.dialect }}: true
TRAC_CONFIG_FILE: ".github/config/int-metadb-${{ inputs.dialect }}.yaml"
TRAC_SECRET_KEY: "testing_secret"
runs-on: ubuntu-latest
timeout-minutes: 20
container:
image: ubuntu:latest
services:
metadb:
image: ${{ inputs.db_image }}
ports:
- ${{ inputs.db_port }}:${{ inputs.db_port }}
options: ${{ inputs.db_options }}
# DB container needs various env vars defined in the matrix
env: ${{ fromJson( inputs.matrix ) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
- name: Build
run: ./gradlew trac-svc-meta:testClasses
# Auth tool will also create the secrets file if it doesn't exist
- name: Prepare secrets
env: ${{ fromJson( inputs.matrix ) }}
run: |
./gradlew secret-tool:run --args="--config ${{ env.TRAC_CONFIG_FILE }} --task init_secrets"
./gradlew secret-tool:run --args="--config ${{ env.TRAC_CONFIG_FILE }} --task create_root_auth_key EC 256"
echo "${DB_SECRET}" | ./gradlew secret-tool:run --args="--config ${{ env.TRAC_CONFIG_FILE }} --task add_secret metadb_secret"
# The name and description of the test tenant are verified in one of the test cases so they need to match
# MetadataReapApiTest listTenants()
- name: Prepare database
run: |
./gradlew deploy-metadb:run --args="\
--config ${{ env.TRAC_CONFIG_FILE }} \
--secret-key ${{ env.TRAC_SECRET_KEY }} \
--task deploy_schema \
--task add_tenant ACME_CORP 'Test tenant [ACME_CORP]'"
- name: Integration tests
run: ./gradlew trac-svc-meta:integration -DintegrationTags="int-metadb"
# If the tests fail, make the output available for download
- name: Store failed test results
uses: actions/upload-artifact@v4
if: failure()
with:
name: junit-test-results
path: build/modules/*/reports/**
retention-days: 7
int-storage--python:
name: int-storage-python-${{ inputs.dialect }}
env:
BUILD_sql_${{ inputs.dialect }}: true
TRAC_RT_SYS_CONFIG: ".github/config/rt-storage-ext-${{ inputs.dialect }}.yaml"
runs-on: ubuntu-latest
timeout-minutes: 20
container:
image: ubuntu:latest
services:
metadb:
image: ${{ inputs.db_image }}
ports:
- ${{ inputs.db_port }}:${{ inputs.db_port }}
options: ${{ inputs.db_options }}
# DB container needs various env vars defined in the matrix
env: ${{ fromJson( inputs.matrix ) }}
steps:
# https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server
- name: Install ODBC (if required)
if: ${{ inputs.dialect == 'sqlserver' }}
run: |
apt-get update
apt-get install -y curl gpg lsb-release
LSB_RELEASE=`lsb_release -rs`
curl "https://packages.microsoft.com/keys/microsoft.asc" | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg
curl "https://packages.microsoft.com/config/ubuntu/${LSB_RELEASE}/prod.list" | tee /etc/apt/sources.list.d/mssql-release.list
apt-get update
ACCEPT_EULA=Y apt-get install -y msodbcsql18
ACCEPT_EULA=Y apt-get install -y mssql-tools18
- name: Checkout
uses: actions/checkout@v4
- name: Pre-process config
env: ${{ fromJson( inputs.matrix ) }}
run: |
sed -i "s#DB_SECRET#${DB_SECRET}#" ${TRAC_RT_SYS_CONFIG}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Upgrade PIP
run: |
python -m venv ./venv
. ./venv/bin/activate
python -m pip install --upgrade pip
# Filter plugin dependencies, only install for the plugin being tested
# This prevents dependency issues in one plugin affecting all the others
- name: Select plugin dependencies
run: |
cd tracdap-runtime/python
sed -n '/BEGIN_PLUGIN sql/, /END_PLUGIN sql/p' requirements_plugins.txt > requirements_selected.txt
- name: Install dependencies
run: |
. ./venv/bin/activate
cd tracdap-runtime/python
pip install -r requirements.txt
pip install -r requirements_selected.txt
- name: Protoc code generation
run: |
. ./venv/bin/activate
python tracdap-runtime/python/build_runtime.py --target codegen
- name: Integration tests
run: |
. ./venv/bin/activate
python tracdap-runtime/python/build_runtime.py --target integration --pattern int_storage_sql*.py