-
Notifications
You must be signed in to change notification settings - Fork 7
/
.travis.yml
200 lines (184 loc) · 8.46 KB
/
.travis.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
language: generic
os: linux
dist: jammy
addons:
apt:
update: true
packages:
- nodejs
stages:
- name: after_success
if: type != pull_request
env:
global:
- PROTOBUF_VERSION=3.17.3
- PROTO_FILES=`find koinos -name '*.proto' && find google -name '*.proto' && find openapiv3 -name '*.proto'`
- COMMIT_SHORT=`git rev-parse --short HEAD`
- BRANCH=`if ! [ -z ${TRAVIS_TAG} ]; then echo -n master; else echo -n ${TRAVIS_BRANCH}; fi`
# This build matrix mixes global and build specific build stages to abstract common tasks.
# There are several conventions in place to facilitate this.
#
# 1. The destination repo (e.g. koinos-proto-cpp) is set in the env var DEST_REPO.
# 2. The destination repo will be checked out with the correct branch at $TRAVIS_BUILD_DIR/$DEST_REPO prior to the script stage.
# 3. After script, all changed files must be staged in the destination repo at the end of the script stage.
# 4. At the beginning and end of each build stage the current directory must be $TRAVIS_BUILD_DIR
#
# The build stages are:
# - install: (Local) Install any language specific dependencies
# - before_script: (Global) Clone the destination repo and correct branch
# - script: (Local) Generate files and stage them in destination directory
# - after_success: (Global) Commit staged changes (if any)
jobs:
include:
- name: "C++"
env:
- DEST_REPO=koinos-proto-cpp
install:
- sudo apt install protobuf-compiler-grpc
script:
- mkdir -p build
- protoc --experimental_allow_proto3_optional --cpp_out=build --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` --grpc_out=build $PROTO_FILES
- pushd ${DEST_REPO}
- mkdir -p src include
- rsync -rvm --include "*.pb.cc" --include "*/" --exclude "*" --delete ${TRAVIS_BUILD_DIR}/build/ src/
- rsync -rvm --include "*.pb.h" --include "*/" --exclude "*" --delete ${TRAVIS_BUILD_DIR}/build/ include/
- git add src include
- |
if ! [ -z "${TRAVIS_TAG}" ]; then
VERSION=${TRAVIS_TAG:1}
sed -i -e "s| VERSION .*| VERSION $VERSION|g" CMakeLists.txt
git add CMakeLists.txt
fi
- popd
- name: "Embedded C++"
env:
- DEST_REPO=koinos-proto-embedded-cpp
- PB_EMBEDDED_CPP_VERSION=negative-enums
install:
- sudo apt install python3.10-venv
- git clone --recursive https://github.com/koinos/EmbeddedProto
- pushd EmbeddedProto
- git checkout $PB_EMBEDDED_CPP_VERSION
- ./setup.sh -e
- popd
script:
- mkdir -p build
- pushd EmbeddedProto
- PROTO_FILES=`find ../koinos -type d -name rpc -prune -o -type f -name "*.proto" -print`
- protoc --experimental_allow_proto3_optional --plugin=protoc-gen-eams --eams_out=../build -I.. $PROTO_FILES
- popd
- pushd ${DEST_REPO}
- mkdir -p libraries/koinos/generated libraries/koinos/src
- rsync -rvm --include "*.h" --include "*/" --exclude "*" --exclude ".*/" --delete ${TRAVIS_BUILD_DIR}/build/ ./libraries/proto_embedded/generated/
- rsync -rvm --include "*.h" --include "*.cpp" --include "*/" --exclude "*" --exclude ".*/" --delete ${TRAVIS_BUILD_DIR}/EmbeddedProto/src/ ./libraries/proto_embedded/src/
- git add libraries/koinos
- popd
- name: "Golang"
env:
- DEST_REPO=koinos-proto-golang
- PROTOC_GEN_GO_VERSION=v1.30.0
- PROTOC_GEN_GO_GRPC_VERSION=v1.3.0
install:
- go install google.golang.org/protobuf/cmd/protoc-gen-go@$PROTOC_GEN_GO_VERSION
- go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@$PROTOC_GEN_GO_GRPC_VERSION
script:
- mkdir -p build
- protoc --experimental_allow_proto3_optional --go_out=build/ --plugin=protoc-gen-go-rpc=`go env GOPATH`/bin/protoc-gen-go-rpc --go-grpc_out=build $PROTO_FILES
- pushd ${DEST_REPO}
- mkdir -p koinos
- rsync -rvm --include "*.pb.go" --include "*/" --exclude "*" --exclude ".*/" --delete ${TRAVIS_BUILD_DIR}/build/github.com/koinos/koinos-proto-golang/v2/ ./
- go mod tidy
- git add .
- popd
- name: "AssemblyScript"
env:
- DEST_REPO=koinos-proto-as
- AS_PROTO_VERSION=1.0.1
install:
- yarn add --dev @koinos/as-proto-gen@$AS_PROTO_VERSION
- sudo yarn global add @jsdevtools/version-bump-prompt
script:
- mkdir -p build
- protoc --experimental_allow_proto3_optional --plugin=protoc-gen-as=./node_modules/.bin/as-proto-gen --as_out=build $PROTO_FILES
- pushd ${DEST_REPO}
- mkdir -p assembly/koinos
- rsync -rvm --include "*.ts" --include "*/" --exclude "*" --exclude ".*/" --delete ${TRAVIS_BUILD_DIR}/build/koinos/ ./assembly/koinos
- ./generate_index.sh
- |
if ! [ -z "${TRAVIS_TAG}" ]; then
npm version ${TRAVIS_TAG} --git-tag-version false
fi
- git add .
- popd
- name: "JavaScript"
env:
- DEST_REPO=koinos-proto-js
- PROTOBUFJS_VERSION=^6.11.3
install:
- yarn add --dev protobufjs@$PROTOBUFJS_VERSION
- sudo yarn global add @jsdevtools/version-bump-prompt
script:
- mkdir -p build
- yarn pbjs --keep-case --target static-module -o build/index.js `find ./koinos -name '*.proto'` `find ./google -name '*.proto'`
- yarn pbts -o build/index.d.ts build/index.js
- yarn pbjs --keep-case --target json -o build/index.json `find ./koinos -name '*.proto'` `find ./google -name '*.proto'`
- pushd ${DEST_REPO}
- cp ${TRAVIS_BUILD_DIR}/build/index.js index.js
- cp ${TRAVIS_BUILD_DIR}/build/index.d.ts index.d.ts
- cp ${TRAVIS_BUILD_DIR}/build/index.json index.json
- |
if ! [ -z "${TRAVIS_TAG}" ]; then
npm version ${TRAVIS_TAG} --git-tag-version false
fi
- git add .
- popd
- name: "Python"
env:
- DEST_REPO=koinos-proto-python
script:
- mkdir -p build
- protoc --experimental_allow_proto3_optional --python_out=build $PROTO_FILES
- pushd ${DEST_REPO}
- mkdir -p koinos
- rsync -rvm --include "*_pb2.py" --include "*/" --exclude "*" --exclude ".*/" --delete ${TRAVIS_BUILD_DIR}/build/ ./
- git add .
- popd
- name: "Protobuf Descriptors"
env:
- DEST_REPO=koinos-proto-descriptors
script:
- mkdir -p build
- protoc --experimental_allow_proto3_optional --descriptor_set_out=build/koinos_descriptors.pb $PROTO_FILES
- pushd ${DEST_REPO}
- cp ${TRAVIS_BUILD_DIR}/build/koinos_descriptors.pb ./koinos_descriptors.pb
- git add koinos_descriptors.pb
- popd
before_install:
- wget https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip
- sudo unzip protoc-${PROTOBUF_VERSION}-linux-x86_64.zip -d /usr/local
- sudo chmod +x /usr/local/bin/protoc
- git config --global user.email ${GITHUB_USER_EMAIL}
- git config --global user.name ${GITHUB_USER_NAME}
- git clone https://${GITHUB_USER_TOKEN}@github.com/koinos/${DEST_REPO}.git
- pushd $DEST_REPO
- |
if [ "${BRANCH}" != "master" ]; then
git checkout -b ${BRANCH}
fi
- popd
after_success:
- pushd $DEST_REPO
- |
if ! git diff --cached --quiet --exit-code; then
git commit -m "Update for koinos-proto commit ${COMMIT_SHORT}"
git push --force https://${GITHUB_USER_TOKEN}@github.com/koinos/${DEST_REPO}.git ${BRANCH}
fi
- |
if ! [ -z "${TRAVIS_TAG}" ]; then
git tag -a ${TRAVIS_TAG} -m "proto tag ${TRAVIS_TAG}"
git push --force https://${GITHUB_USER_TOKEN}@github.com/koinos/${DEST_REPO}.git ${TRAVIS_TAG}
fi
notifications:
slack:
secure: KUBygLJ3P9z9dYvoWr3Kg+82b5Oq7/gtHmwlv3D+kbzQPJzN/CtwRH9fpJCfa1jjr375tSAb9nbOVqerOHH448aQ50x436Co68Ic2GwQLpfiGjC7apALs2hSxM68nR2+tOPgBk6OCb4rm4G/mnO/2BQqNkGHpk5QoBf5Mv61njyflc5aR5LmlujA2t/5KkXw90te+WDJlwwA08psyhyLjFr/KH7LwDRVc4ggOwDPPPzjwQlABQFyO4avE43SjtSCScMx56y7PdPeIZcvLUo/+lJsCGovS7MTCQ+FPpnHMzYa4QZA7RXTsfys9ZI/SYmrhPdgkBxWOjQCUsO93t8jhikh384li2VqTDTvz0fGh+Cw9LkM80fA+nvaoLAHiUGgI325GmWDnqbEdP9eeFKtRM5U/gTZyEMpDmx/qGr1zmbus31FA+YHPSHsaUYZnzWaCRHOXP7ORm0eiWbczs7jNM0L722EcrocACpZTYFQgy91xr3BAgXOohbN5y+4Uix/BdS4wIHaxNh2N4zzW8v40q0G8lV1Dd2CJKUSbJ27Ze1ziYSQLo4gV9qRULuxiGDdtvlp9Btlz4Rc7NlOrl+oJpl0A0HJFUkalgM5PehmvlPkjJCwdeiCXQdiTe5tO9vPYqifwF+l1kcwIDxc4FBFMbVj2K5C1MAOH+ZjxBNSt1A=
on_success: never