-
Notifications
You must be signed in to change notification settings - Fork 9
117 lines (113 loc) · 3.61 KB
/
cicd.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
name: 'CI'
on:
push:
branches:
- master
pull_request_target: {}
env:
GCLOUD_VERSION: "392.0.0"
jobs:
test-v3:
name: Test v3
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
go_version:
- ~1.11
- ~1.12
- ~1.16
defaults:
run:
shell: bash
working-directory: v3
permissions:
contents: read
env:
GO111MODULE: "on"
DATASTORE_EMULATOR_HOST: "localhost:8081"
DATASTORE_PROJECT_ID: "unittest"
GOOGLE_CLOUD_PROJECT: "unittest"
steps:
- uses: actions/checkout@v3
with:
# pull_request_target の場合PRのhead(場合によってはvulnerable)、そうじゃなければcontextのsha
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go_version }}
- name: Cache go dependencies
uses: actions/cache@v3
id: cache
with:
key: ${{ runner.os }}-go-cache-v2-r1-${{ matrix.go_version }}-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**/go.sum') }}
path: |-
~/go/pkg/mod
- name: Prepare dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |-
go mod download
- uses: google-github-actions/setup-gcloud@v0
with:
version: ${{ env.GCLOUD_VERSION }}
project_id: ${{ env.DATASTORE_PROJECT_ID }}
install_components: "beta,cloud-datastore-emulator,app-engine-go"
- name: Spinup Datastore Emulator
run: |-
gcloud beta emulators datastore start --host-port=0.0.0.0:8081 --no-store-on-disk --consistency=1.0 &
curl http://localhost:8081 --silent --retry 30 --retry-connrefused --retry-delay 1
- name: Run tests
run: |-
go test -v ./...
test-v2:
name: Test v2
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
go_version:
- ~1.11
- ~1.12
- ~1.16
defaults:
run:
shell: bash
working-directory: v2
permissions:
contents: read
env:
GO111MODULE: "on"
DATASTORE_EMULATOR_HOST: "localhost:8081"
DATASTORE_PROJECT_ID: "unittest"
GOOGLE_CLOUD_PROJECT: "unittest"
steps:
- uses: actions/checkout@v3
with:
# pull_request_target の場合PRのhead(場合によってはvulnerable)、そうじゃなければcontextのsha
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go_version }}
- name: Cache go dependencies
uses: actions/cache@v3
id: cache
with:
key: ${{ runner.os }}-go-cache-v2-r1-${{ matrix.go_version }}-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**/go.sum') }}
path: |-
~/go/pkg/mod
- name: Prepare dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |-
go mod download
- uses: google-github-actions/setup-gcloud@v0
with:
version: ${{ env.GCLOUD_VERSION }}
project_id: ${{ env.DATASTORE_PROJECT_ID }}
install_components: "beta,cloud-datastore-emulator,app-engine-go"
- name: Spinup Datastore Emulator
run: |-
gcloud beta emulators datastore start --host-port=0.0.0.0:8081 --no-store-on-disk --consistency=1.0 &
curl http://localhost:8081 --silent --retry 30 --retry-connrefused --retry-delay 1
- name: Run tests
run: |-
go test -v ./...