-
Notifications
You must be signed in to change notification settings - Fork 22
59 lines (51 loc) · 1.58 KB
/
go.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
name: GoBuildAndTest
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Build
run: cd go/tunnels && go build -v ./...
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Test
run: cd go/tunnels && go test -short -v ./...
check-version-update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check Go SDK package version updated
run: |
SDK_DIR=go
FILE_WITH_PKG_VER=go/tunnels/tunnels.go
test -d $SDK_DIR && test -f $FILE_WITH_PKG_VER
BASE_SHA=$(jq -r '.pull_request.base.sha' "$GITHUB_EVENT_PATH")
# If go sdk dir updated, package version file updated and "PackageVersion" line updated, success; else error.
if git diff --name-only $BASE_SHA HEAD | grep -q "^$SDK_DIR"; then
if git diff --name-only $BASE_SHA HEAD | grep -q "^$FILE_WITH_PKG_VER" && git diff $BASE_SHA HEAD -- $FILE_WITH_PKG_VER | grep -q "PackageVersion"; then
echo "Success: Package version was updated."
exit 0
else
echo "Error: An error occurred. Has "PackageVersion" in $FILE_WITH_PKG_VER been updated?" >&2
exit 1
fi
else
echo "No Go SDK changes detected."
fi