This repository has been archived by the owner on Aug 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
205 lines (169 loc) · 5.04 KB
/
function-build.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: function-build
on:
push:
branches:
- master
paths-ignore:
# Ignore files that are not used in production
- "**.md"
- "LICENSE"
- ".github/workflows/dependabot-auto-merge.yml"
- "function/_img/**"
- "function/_script/**"
- ".github/dependabot.yml"
- ".github/dependabot-auto-merge.yml"
# Ignore files used only by the frontend
- "frontend/**"
- ".github/workflows/frontend-*.yml"
pull_request:
types:
- opened
- synchronize
- reopened
paths-ignore:
# Ignore files that are not used in production
- "**.md"
- "LICENSE"
- ".github/workflows/dependabot-auto-merge.yml"
- ".github/dependabot-auto-merge.yml"
- "function/_img/**"
# Ignore files used only by the frontend
- "frontend/**"
- ".github/workflows/frontend-*.yml"
env:
TEST_ARGS: -coverprofile coverage.out -covermode atomic
defaults:
run:
working-directory: function
jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "function/go.mod"
cache-dependency-path: "function/go.sum"
id: go
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Install firebase emulator
run: |
set -xe
npm install -g firebase-tools
firebase setup:emulators:firestore
firebase setup:emulators:pubsub
- name: Run test
run: |
set -xe
firebase --project $GCP_PROJECT emulators:exec --only firestore,pubsub "make test"
firebase --project $GCP_PROJECT emulators:exec --only firestore,pubsub "make testrace"
env:
GCP_PROJECT: test
PUBSUB_PROJECT_ID: test
PUBSUB_EMULATOR_HOST: localhost:8085
# FIXME: gcov2lcov-action doesn't support mono repo...
# - name: Convert coverage to lcov
# uses: jandelgado/gcov2lcov-action@v1.0.0
# with:
# infile: coverage.out
# outfile: coverage.lcov
- name: Install gcov2lcov
run: |
set -xe
wget https://github.com/jandelgado/gcov2lcov/releases/download/${VERSION}/gcov2lcov-linux-amd64.tar.gz -q -O - | tar xvzf - --strip 1
chmod 755 gcov2lcov-linux-amd64
env:
VERSION: v1.0.4
working-directory: /tmp
- name: Run gcov2lcov
run: |
set -xe
exec /tmp/gcov2lcov-linux-amd64 -infile "coverage.out" -outfile "coverage.lcov"
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: function/coverage.lcov
continue-on-error: true
- name: Slack Notification (not success)
uses: act10ns/slack@v2
if: "! success()"
continue-on-error: true
with:
status: ${{ job.status }}
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "function/go.mod"
cache-dependency-path: "function/go.sum"
id: go
- name: Run lint
run: |
set -xe
go install golang.org/x/lint/golint@latest
make fmtci
make vet
make lint
- name: Slack Notification (not success)
uses: act10ns/slack@v2
if: "! success()"
continue-on-error: true
with:
status: ${{ job.status }}
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
go2ts:
name: go2ts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "function/go.mod"
cache-dependency-path: "function/go.sum"
id: go
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "npm"
cache-dependency-path: "frontend/package-lock.json"
- run: npm install
working-directory: frontend
- name: "[NOTE] Run `make go2ts` if this is failed"
run: |
set -xe
make go2ts_ci
git checkout HEAD -- go.mod go.sum
git --no-pager diff
git status | grep "nothing to commit, working tree clean"
- name: Slack Notification (not success)
uses: act10ns/slack@v2
if: "! success()"
continue-on-error: true
with:
status: ${{ job.status }}
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
notify:
needs:
- test
- lint
- go2ts
runs-on: ubuntu-latest
steps:
- name: Slack Notification (success)
uses: act10ns/slack@v2
if: always()
continue-on-error: true
with:
status: ${{ job.status }}
webhook-url: ${{ secrets.SLACK_WEBHOOK }}