-
Notifications
You must be signed in to change notification settings - Fork 20
152 lines (149 loc) · 5.28 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
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: 'CI'
on:
push:
branches:
- master
pull_request_target: {}
jobs:
test-v2:
name: Test v2
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
go_version:
- ~1.16
- ~1.18
defaults:
run:
working-directory: v2
permissions:
contents: read
services:
# 本当はservicesで動かしたいけどオプションを指定して実行ができないっぽいので諦めるしかない…
# datastore_emulator:
# image: gcr.io/google.com/cloudsdktool/cloud-sdk:392.0.0
# ports:
# - "8081:8081"
# options: |-
# --entrypoint "gcloud --project=datastore-wrapper beta emulators datastore start --host-port=0.0.0.0:8081 --no-store-on-disk --use-firestore-in-datastore-mode"
# --health-cmd "curl http://localhost:8081 --silent --retry-connrefused"
# --health-interval 1s
# --health-retries 30
redis:
image: redis:6-alpine
ports:
- "6379:6379"
memcached:
image: memcached:1.6-alpine
ports:
- "11211:11211"
env:
GCLOUD_VERSION: "392.0.0"
GO111MODULE: "on"
DATASTORE_EMULATOR_HOST: "localhost:8081"
DATASTORE_PROJECT_ID: "unittest"
MEMCACHED_HOST: "localhost:11211"
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-r3-v2-${{ matrix.go_version }}-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**/go.sum') }}
path: |-
~/go/pkg/mod
v2/build-cmd
- name: Prepare dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |-
./setup.sh
ls -la build-cmd
- 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 --use-firestore-in-datastore-mode &
curl http://localhost:8081 --silent --retry 30 --retry-connrefused --retry-delay 1
- name: Run tests
run: |-
./test.sh -v -timeout 4m
test-v1:
name: Test v1
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
go_version:
- ~1.11
permissions:
contents: read
services:
# 本当はservicesで動かしたいけどオプションを指定して実行ができないっぽいので諦めるしかない…
# datastore_emulator:
# image: gcr.io/google.com/cloudsdktool/cloud-sdk:392.0.0
# ports:
# - "8081:8081"
# options: |-
# --entrypoint "gcloud --project=datastore-wrapper beta emulators datastore start --host-port=0.0.0.0:8081 --no-store-on-disk --use-firestore-in-datastore-mode"
# --health-cmd "curl http://localhost:8081 --silent --retry-connrefused"
# --health-interval 1s
# --health-retries 30
redis:
image: redis:6-alpine
ports:
- "6379:6379"
memcached:
image: memcached:1.6-alpine
ports:
- "11211:11211"
env:
GCLOUD_VERSION: "392.0.0"
GO111MODULE: "on"
DATASTORE_EMULATOR_HOST: "localhost:8081"
DATASTORE_PROJECT_ID: "unittest"
MEMCACHED_HOST: "localhost:11211"
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-r1-v1-${{ matrix.go_version }}-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**/go.sum') }}
path: |-
~/go/pkg/mod
build-cmd
- name: Prepare dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |-
./setup.sh
ls -la build-cmd
- 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 --use-firestore-in-datastore-mode &
curl http://localhost:8081 --silent --retry 30 --retry-connrefused --retry-delay 1
- name: Run tests
run: |-
./test.sh -v -timeout 4m