lbryio/chainquery

View on GitHub
.travis.yml

Summary

Maintainability
Test Coverage
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