-
Notifications
You must be signed in to change notification settings - Fork 36
261 lines (227 loc) · 8.36 KB
/
ruby-ci.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
name: Ruby-CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
LOOKERSDK_BASE_URL: https://localhost:20000
LOOKERSDK_VERIFY_SSL: false
LOOKERSDK_CLIENT_ID: ${{ secrets.LOOKERSDK_CLIENT_ID }}
LOOKERSDK_CLIENT_SECRET: ${{ secrets.LOOKERSDK_CLIENT_SECRET }}
jobs:
setup:
uses: looker-open-source/reusable-actions/.github/workflows/supported-versions.yml@main
test:
name: Test - Looker.${{ matrix.looker }} / Ruby.${{ matrix.ruby-version }}
runs-on:
group: large-ubuntu
needs: setup
strategy:
matrix:
looker: ${{ fromJson(needs.setup.outputs.matrix_json) }}
ruby-version: [2.7.7]
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v3
- name: Authenticate to Google Cloud
uses: google-github-actions/[email protected]
with:
credentials_json: ${{ secrets.GCP_AR_READER_SA_KEY }}
project_id: ${{ secrets.GCP_PROJECT_ID }}
create_credentials_file: true
export_environment_variables: true
- name: Set up Cloud SDK
uses: google-github-actions/[email protected]
- name: Authenticate Artifact Repository
run: gcloud auth configure-docker us-west1-docker.pkg.dev --quiet
- name: Pull and run Looker docker image
run: |
docker pull --quiet us-west1-docker.pkg.dev/cloud-looker-sdk-codegen-cicd/looker/${{ matrix.looker }}
# set $LOOKER_OPTS to --no-ssl if we want to turn off ssl
docker run --name looker-sdk-codegen-ci -d -p 10000:9999 -p 20000:19999 us-west1-docker.pkg.dev/cloud-looker-sdk-codegen-cicd/looker/${{ matrix.looker }}
docker logs -f looker-sdk-codegen-ci --until=30s &
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: false
- name: Install dependencies
run: bin/setup
- name: Check that Looker is ready
run: |
${{ github.workspace }}/.github/scripts/wait_for_looker.sh
- name: Report Failure
run: |
curl --request POST \
--url https://api.github.com/repos/looker-open-source/sdk-codegen/check-runs \
--header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
--header "content-type: application/json" \
--header "Accept: application/vnd.github.v3+json" \
--data '{
"name": "Ruby-CI Tests",
"head_sha": "${{ github.event.pull_request.head.sha || github.sha }}",
"conclusion": "failure"
}' \
--fail
if: failure()
- name: Login persistently
run: |
exe/gzr session login
- name: Create Connection
run: |
cat > Connection_faa_mysql.json <<HERE
{
"name": "faa",
"host": "${{ secrets.FAA_MYSQL_HOSTNAME }}",
"port": "3306",
"database": "flightstats",
"db_timezone": "UTC",
"query_timezone": "UTC",
"schema": null,
"max_connections": 30,
"ssl": false,
"verify_ssl": false,
"tmp_db_name": "tmp",
"pool_timeout": 120,
"sql_runner_precache_tables": true,
"sql_writing_with_info_schema": true,
"uses_tns": false,
"pdt_concurrency": 1,
"dialect_name": "mysql",
"username": "${{ secrets.FAA_MYSQL_USERNAME }}",
"password": "${{ secrets.FAA_MYSQL_PASSWORD }}"
}
HERE
exe/gzr connection import Connection_faa_mysql.json --token_file
- name: Test Connection
run: |
exe/gzr connection test faa --token_file
- name: Change the session to dev mode
run: |
exe/gzr session get --token_file
exe/gzr session update dev --token_file
- name: Import the project
run: |
cat > Project_faa.json <<HERE
{
"name": "faa",
"uses_git": true
}
HERE
exe/gzr project import Project_faa.json --token-file
- name: Create a deploy key and set it on the github repo for the project
run: |
DEPLOY_KEY=$(exe/gzr project deploy_key faa --token_file)
echo $DEPLOY_KEY
SET_KEY_RESPONSE=$(
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.LOS_AUTO_BOT_MANAGE_FAA_DEPLOY_KEY }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/looker-open-source/faa/keys \
-d "{\"title\":\"test_key $(uuidgen)\",\"key\":\"$DEPLOY_KEY\",\"read_only\":false}"
)
echo $SET_KEY_RESPONSE
echo "KEY_ID=$(jq .id <<<$SET_KEY_RESPONSE)" >> $GITHUB_ENV
- name: Set the project github connection
run: |
cat > github_repo.json <<HERE
{
"git_remote_url": "[email protected]:looker-open-source/faa.git",
"git_service_name": "github"
}
HERE
exe/gzr project update faa github_repo.json --token-file
- name: Check the project config
run: |
exe/gzr project cat faa --trim --token-file
- name: Check available branches for faa project
run: |
exe/gzr project branch faa --all --token-file
- name: Checkout a shared branch
run: |
exe/gzr project checkout faa main --token_file
- name: Deploy to production
run: |
exe/gzr project deploy faa --token_file
- name: Configure lookml model
run: |
cat > Model_faa.json <<HERE
{
"name": "aviation",
"project_name": "faa",
"unlimited_db_connections": false,
"allowed_db_connection_names": [
"faa"
]
}
HERE
exe/gzr model import Model_faa.json --token_file
- name: run a query against the model
run: |
cat > query.json <<HERE
{
"model": "aviation",
"view": "aircraft_types",
"fields": ["aircraft_types.description","aircraft_types.count"],
"pivots": null,
"fill_fields": null,
"filters": null,
"filter_expression": null,
"sorts": [
"aircraft_types.description"
],
"limit": "500"
}
HERE
exe/gzr query runquery "$(cat query.json)"
- name: Load a dashboard
run: |
me=$(exe/gzr user me --csv --plain)
echo $me
dest_folder=$(cut -d, -f5 <<< $me | sed 's/"//g')
exe/gzr dashboard import examples/Dashboard_17_FAA_KPIs.json $dest_folder
- name: Remove the deploy key from the github repo
if: ${{ always() }}
run: |
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.LOS_AUTO_BOT_MANAGE_FAA_DEPLOY_KEY }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/looker-open-source/faa/keys/$KEY_ID
- name: Run tests
run: bundle exec rake
- name: Upload ts unit test results
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: ruby-ci-test-results-${{ matrix.looker }}
path: rspec.xml
publish-test-results:
needs: [test]
if: success() || failure()
runs-on: ubuntu-latest
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Publish Test Results
uses: EnricoMi/[email protected]
with:
# Cosmetic issue with `check_name` being associated to the wrong
# workflow: https://github.com/EnricoMi/publish-unit-test-result-action/issues/12
check_name: Ruby-CI Tests
github_token: ${{ secrets.GITHUB_TOKEN }}
report_individual_runs: true
hide_comments: orphaned commits
check_run_annotations: 'none'
compare_to_earlier_commit: false
files: 'artifacts/**/*.xml'