forked from berty/berty
-
Notifications
You must be signed in to change notification settings - Fork 0
205 lines (179 loc) · 5.59 KB
/
protobuf.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: Protobuf
on:
push:
tags:
- v*
branches:
- master
paths:
- "api/**"
- "Makefile"
- "js/Makefile"
- "go/Makefile"
- "config/**"
- "docs/Makefile"
- ".github/workflows/protobuf.yml"
- "js/packages/i18n/locale/en/messages.json"
- "**/gen.sum"
- "**.pb.go"
- "**.gen.go"
- "**.gen.graphql"
- "**.gen.js"
- "**.gen.ts"
- "**.gen.tsx"
- "**.gen.yml"
- "**.pb.d.ts"
- "**.pb.go"
- "**.pb.js"
- "**/pb_test.go"
- "**/docs/*/api.md"
- "**/gen.sum"
- "**/go.mod"
- "**/go.sum"
- "**/yarn.lock"
- "**/package.json"
- "**/Podfile.lock"
pull_request:
paths:
- "api/**"
- "Makefile"
- "js/Makefile"
- "go/Makefile"
- "config/**"
- "docs/Makefile"
- ".github/workflows/protobuf.yml"
- "js/packages/i18n/locale/en/messages.json"
- "**/gen.sum"
- "**.pb.go"
- "**.gen.go"
- "**.gen.graphql"
- "**.gen.js"
- "**.gen.ts"
- "**.gen.tsx"
- "**.gen.yml"
- "**.pb.d.ts"
- "**.pb.go"
- "**.pb.js"
- "**/pb_test.go"
- "**/docs/*/api.md"
- "**/gen.sum"
- "**/go.mod"
- "**/go.sum"
- "**/yarn.lock"
- "**/package.json"
- "**/Podfile.lock"
jobs:
gen-go-and-docs:
name: Generate go protobuf and docs
runs-on: ubuntu-latest
container: bertytech/protoc:31
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Unshallow
run: git fetch --prune --unshallow
- name: Remove lock files
run: find . -name gen.sum ! -path './js/*' -delete
- name: Load variables from file
uses: antifree/[email protected]
with:
filename: .github/workflows/utils/variables.json
- name: Setup asdf
uses: asdf-vm/actions/setup@v1
- name: Setup go
run: |
asdf plugin add golang
asdf install golang
echo "go_version=$(asdf current golang | xargs | cut -d ' ' -f 2)" >> $GITHUB_ENV
- name: Setup jq
run: |
asdf plugin add jq
asdf install jq
- name: Cache go modules
uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ env.go_version }}-${{ env.json_cache-versions_go }}-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-${{ env.go_version }}-${{ env.json_cache-versions_go }}-
- name: Fetch go modules
run: go mod download
- name: Generate docs
working-directory: docs
run: make generate_local
- name: Generate go protobuf
working-directory: go
run: |
make generate_local
git checkout ../go.mod ../go.sum
- name: Check diff
run: |
git status | cat
git diff -w | cat
git diff-index -w --quiet HEAD --
- name: Prepare openapi documentation
working-directory: docs
run: make openapi.prepare
- name: Setup apiary
run: apk --no-cache add ruby-dev g++ && gem install apiaryio
- name: Upload API docs to apiary.io
env:
APIARY_API_KEY: "${{ secrets.APIARY_API_KEY }}"
if: ${{ env.APIARY_API_KEY != 0 }}
run: |
apiary publish --api-name=bertymessenger --path="docs/.tmp/openapi/bertymessenger.swagger.json" || true
gen-js:
name: Generate js protobuf
runs-on: ubuntu-latest
container: bertytech/protoc:31
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Load variables from file
uses: antifree/[email protected]
with:
filename: .github/workflows/utils/variables.json
- name: Setup asdf
uses: asdf-vm/actions/setup@v1
- name: Setup node
run: |
asdf plugin add nodejs
asdf install nodejs
echo "node_version=$(asdf current nodejs | xargs | cut -d ' ' -f 2)" >> $GITHUB_ENV
- name: Setup go
run: |
asdf plugin add golang
asdf install golang
echo "go_version=$(asdf current golang | xargs | cut -d ' ' -f 2)" >> $GITHUB_ENV
- name: Cleanup js gen
- run: make gen.clean
working-directory: js
- name: Cache node modules
uses: actions/[email protected]
with:
path: js/node_modules
key: ${{ runner.OS }}-node-${{ env.node_version }}-${{ env.json_cache-versions_node }}-${{ hashFiles('js/yarn.lock') }}
restore-keys: ${{ runner.OS }}-node-${{ env.node_version }}-${{ env.json_cache-versions_node }}-
- name: Cache go modules
uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ env.go_version }}-${{ env.json_cache-versions_go }}-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-${{ env.go_version }}-${{ env.json_cache-versions_go }}-
- name: Fetch node modules
# FIXME: find a way of only downloading the required packages or install them directly in the bertytech/protoc image
working-directory: js
run: make node_modules
- name: Fetch go modules
run: go mod download
- name: Generate js protobuf
working-directory: js
run: |
make _gen.pbjs
make _write_gen_sum
rm -f gen.sum && make generate
- name: Check diff
run: |
go mod tidy
git status | cat
git diff -w | cat
git diff-index -w --quiet HEAD --