Skip to content

Commit 47a52dd

Browse files
feat: Added unit test CI for Go SDK changes (#965)
Co-authored-by: Dr. Strangelove <[email protected]>
1 parent 1e0cdfa commit 47a52dd

File tree

2 files changed

+108
-2
lines changed

2 files changed

+108
-2
lines changed

.github/workflows/go-ci.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Go SDK CI
2+
on:
3+
pull_request:
4+
paths:
5+
- go/**
6+
7+
push:
8+
branches:
9+
- main
10+
paths:
11+
- go/**
12+
13+
workflow_dispatch:
14+
15+
env:
16+
JUNIT_OUTPUT_DIR: results
17+
JUNIT_ARTIFACT_DIR: gosdk-test-results
18+
19+
jobs:
20+
unit:
21+
name: Unit - ${{ matrix.os }} / Go ${{ matrix.go-version }}
22+
env:
23+
GO_JUNIT_OUTPUT_NAME: ${{ matrix.os }}.gosdkunitresult${{ matrix.go-version }}.xml
24+
runs-on: ${{ matrix.os }}-latest
25+
26+
strategy:
27+
matrix:
28+
os:
29+
- ubuntu
30+
go-version: [1.17.6, 1.16.13]
31+
32+
steps:
33+
- name: Cancel Previous Runs
34+
uses: styfle/[email protected]
35+
with:
36+
access_token: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Repo Checkout
39+
uses: actions/checkout@v2
40+
41+
- name: Install Go ${{ matrix.go-version }}
42+
uses: actions/setup-go@v2
43+
with:
44+
go-version: ${{ matrix.go-version }}
45+
46+
- name: Install dependencies
47+
run: go get -u github.com/jstemmer/go-junit-report
48+
49+
- name: Run unit tests
50+
run: |
51+
mkdir ${{ env.JUNIT_OUTPUT_DIR }}
52+
cd go/rtl
53+
go test -v 2>&1 | go-junit-report > ../../${{ env.JUNIT_OUTPUT_DIR }}/${{ env.GO_JUNIT_OUTPUT_NAME }}
54+
55+
- name: Upload Go unit test results
56+
if: ${{ always() }}
57+
uses: actions/upload-artifact@v2
58+
with:
59+
name: ${{ env.JUNIT_ARTIFACT_DIR }}
60+
path: ${{ env.JUNIT_OUTPUT_DIR }}
61+
62+
publish-test-results:
63+
needs: unit
64+
if: success() || failure()
65+
runs-on: ubuntu-latest
66+
67+
steps:
68+
- name: Download Artifacts
69+
uses: actions/download-artifact@v2
70+
with:
71+
path: artifacts
72+
73+
- name: Publish All Test Results
74+
uses: EnricoMi/[email protected]
75+
with:
76+
# Cosmetic issue with `check_name` being associated to the wrong
77+
# workflow: https://github.com/EnricoMi/publish-unit-test-result-action/issues/12
78+
check_name: Go Tests
79+
github_token: ${{ secrets.GITHUB_TOKEN }}
80+
report_individual_runs: true
81+
hide_comments: orphaned commits
82+
check_run_annotations_branch: '*'
83+
files: 'artifacts/${{ env.JUNIT_ARTIFACT_DIR }}/*.xml'

.github/workflows/required-checks-hack-ci.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
# definition in a different workflow file:
1414
#
1515
# codegen-ci.yml: Codegen Tests
16-
# tssdk-ci.yml: Typescript Tests
17-
# python-ci.yml: Python Tests
16+
# tssdk-ci.yml: Typescript SDK Tests
17+
# python-ci.yml: Python SDK Tests
1818
# apix-ci.yml: APIX Tests
19+
# go-ci.yml: Go SDK Tests
1920
#
2021

2122
name: Required Checks Hack
@@ -64,6 +65,8 @@ jobs:
6465
- packages/extension-sdk/**/*
6566
- packages/extension-sdk-react/**/*
6667
- packages/extension-utils/**/*
68+
gosdk:
69+
- packages/go/**/*
6770
6871
- name: Debug info
6972
run: |
@@ -74,6 +77,7 @@ jobs:
7477
echo "python: ${{ steps.filter.outputs.python }}"
7578
echo "resources: ${{ steps.filter.outputs.resources }}"
7679
echo "tssdk: ${{ steps.filter.outputs.tssdk }}"
80+
echo "gosdk: ${{ steps.filter.outputs.gosdk }}"
7781
7882
- name: Create Codegen check
7983
if: steps.filter.outputs.codegen == 'false'
@@ -150,3 +154,22 @@ jobs:
150154
"conclusion": "success"
151155
}' \
152156
--fail
157+
158+
- name: Create Go check
159+
if: steps.filter.outputs.gosdk == 'false'
160+
run: |
161+
curl --request POST \
162+
--url https://api.github.com/repos/looker-open-source/sdk-codegen/check-runs \
163+
--header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
164+
--header "content-type: application/json" \
165+
--header "Accept: application/vnd.github.v3+json" \
166+
--data '{
167+
"name": "Go Tests",
168+
"head_sha": "${{ github.event.pull_request.head.sha || github.sha }}",
169+
"output": {
170+
"title": "Required Checks Hack / Go Tests",
171+
"summary": "Associated files have not been changed so this can be skipped"
172+
},
173+
"conclusion": "success"
174+
}' \
175+
--fail

0 commit comments

Comments
 (0)