-
Notifications
You must be signed in to change notification settings - Fork 196
152 lines (129 loc) · 5 KB
/
codegen-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
name: Codegen CI
on:
pull_request:
paths:
- package.json
- packages/sdk-codegen/**
- packages/sdk-codegen-utils/**
- packages/sdk-codegen-scripts/**
- .github/workflows/codegen-ci.yml
- yarn.lock
push:
branches:
- main
paths:
- package.json
- packages/sdk-codegen/**
- packages/sdk-codegen-utils/**
- packages/sdk-codegen-scripts/**
- .github/workflows/codegen-ci.yml
- yarn.lock
workflow_dispatch:
env:
LOOKERSDK_BASE_URL: https://localhost:20000
LOOKERSDK_VERIFY_SSL: false
TS_JUNIT_OUTPUT_DIR: results/sdk-codegen
jobs:
setup:
uses: looker-open-source/reusable-actions/.github/workflows/primary-version.yml@main
unit:
needs: setup
env:
JEST_JUNIT_OUTPUT_DIR: results/sdk-codegen
JEST_JUNIT_OUTPUT_NAME: ubuntu-latest.sdk-codegen15x.xml
LOOKERSDK_CLIENT_ID: ${{ secrets.LOOKERSDK_CLIENT_ID }}
LOOKERSDK_CLIENT_SECRET: ${{ secrets.LOOKERSDK_CLIENT_SECRET }}
runs-on: ubuntu-latest
steps:
- name: Repo Checkout
uses: actions/checkout@v4
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
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/setup-gcloud@v2
- name: Authenticate Artifact Repository
run: gcloud auth configure-docker us-west1-docker.pkg.dev --quiet
- name: Pull and run Looker docker image
# TODO: can we cache some layers of the image for faster download?
# we probably don't want to cache the final image for IP security...
run: |
docker pull --quiet us-west1-docker.pkg.dev/cloud-looker-sdk-codegen-cicd/looker/${{ fromJson(needs.setup.outputs.matrix_json)[0] }}
# 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/${{ fromJson(needs.setup.outputs.matrix_json)[0] }}
docker logs -f looker-sdk-codegen-ci --until=30s &
- uses: actions/setup-node@v4
with:
node-version: 22.x
- name: Install dependencies
run: |
yarn
yarn build
yarn lint:es --quiet
yarn dedupe:ci
- name: Mock looker.ini
run: |
echo "[Looker]" > looker.ini
echo "base_url=https://localhost:20000" >> looker.ini
echo "verify_ssl=false" >> looker.ini
echo "timeout=30" >> looker.ini
echo "[Miner]" >> looker.ini
echo "base_url=." >> looker.ini
- name: Check that Looker is ready
run: |
${{ github.workspace }}/.github/scripts/wait_for_looker.sh
# if this job fails before this point the required state check "Codegen Tests"
# is never set, so we will set it manually.
- 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": "Codegen Tests",
"head_sha": "${{ github.event.pull_request.head.sha || github.sha }}",
"conclusion": "failure"
}' \
--fail
if: failure()
- name: Run unit tests
# TODO can we use yarn test:gen with the reporters option added to it here?
run: yarn jest "packages/sdk-codegen(|-utils|-scripts)/src" --reporters=default --reporters=jest-junit
- name: Delete looker.ini mock
run: rm looker.ini
- name: Upload ts unit test results
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: sdk-codegen-test-results
path: results/sdk-codegen
publish-test-results:
needs: [unit]
if: success() || failure()
runs-on: ubuntu-latest
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
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: Codegen Tests
github_token: ${{ secrets.GITHUB_TOKEN }}
report_individual_runs: true
hide_comments: orphaned commits
check_run_annotations_branch: '*'
files: 'artifacts/sdk-codegen-test-results/*.xml'