-
Notifications
You must be signed in to change notification settings - Fork 42
/
.travis.yml
91 lines (80 loc) · 2.84 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
os: linux
dist: focal
language: go
# Only the last two Go releases are supported by the Go team with security
# updates. Any versions older than that should be considered deprecated.
# Don't bother testing with them. tip builds your code with the latest
# development version of Go. This can warn you that your code will break
# in the next version of Go. Don't worry! Later we declare that test runs
# are allowed to fail on Go tip.
go: 1.19.x
# Skip the install step. Don't `go get` dependencies. Only build with the
# code in vendor/
install: true
cache:
directories:
- $HOME/.cache/go-build
- $HOME/gopath/pkg/mod
services:
- mysql
- docker
before_install:
- sudo sed -i '/^\[mysqld\]/a log_bin_trust_function_creators = 1' /etc/mysql/mysql.conf.d/mysqld.cnf
- mysql -u root -e 'CREATE DATABASE IF NOT EXISTS chainquery;'
- mysql -u root -e "CREATE USER 'chainquery'@'localhost' IDENTIFIED BY 'chainquery';"
- mysql -u root -e "GRANT ALL ON chainquery.* TO 'chainquery'@'localhost';"
- sudo service mysql restart
# Anything in before_script that returns a nonzero exit code will
# flunk the build and immediately stop. It's sorta like having
# set -e enabled in bash.
before_script:
# All the .go files, excluding vendor/ and model (auto generated)
- GO_FILES=$(find . -iname '*.go' -type f | grep -v /vendor/ | grep -v /model/ | grep -v /swagger/ | grep -v /migration/)
# script always run to completion (set +e). All of these code checks are must haves
# in a modern Go project.
script:
# Build Chainquery successfully
- ./scripts/build.sh
# Fail if a .go file hasn't been formatted with gofmt
- gofmt -s -l -d $GO_FILES #List diff for debugging
- test -z $(gofmt -s -l -d $GO_FILES)
- ./scripts/lint.sh
# Run unit tests
- ./scripts/test.sh
# end to end testing
- ./e2e/e2e.sh
# check model generation...
- ./bin/chainquery serve db && ./scripts/gen_models.sh
# matches what was committed
- go mod tidy
- git diff --exit-code
deploy:
# uploads per commit builds
- provider: s3
bucket: "build.lbry.io"
access_key_id: $AWS_ACCESS_KEY_ID
secret_access_key: $AWS_SECRET_ACCESS_KEY
skip_cleanup: true
local-dir: bin
upload-dir: "chainquery/branch-${TRAVIS_BRANCH}/commit-${TRAVIS_COMMIT:0:7}/build-${TRAVIS_BUILD_NUMBER}"
on:
all_branches: true
# upload latest successful build per branch
- provider: s3
bucket: "build.lbry.io"
access_key_id: $AWS_ACCESS_KEY_ID
secret_access_key: $AWS_SECRET_ACCESS_KEY
skip_cleanup: true
local-dir: bin
upload-dir: "chainquery/branch-${TRAVIS_BRANCH}"
on:
all_branches: true
# Docker images - must be after upload
- provider: script
skip_cleanup: true
script: ./docker/build.sh $TRAVIS_BRANCH
on:
all_branches: true
condition: $TRAVIS_OS_NAME = linux
notifications:
webhooks: https://chainquery.odysee.tv/api/autoupdate