jet/.circleci/config.yml

170 lines
5.6 KiB
YAML
Raw Normal View History

2019-06-21 14:54:23 +02:00
# Golang CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-go/ for more details
version: 2
jobs:
2019-08-16 13:04:20 +02:00
build-postgres-and-mysql:
2019-06-21 14:54:23 +02:00
docker:
# specify the version
2021-01-24 16:47:06 +01:00
- image: circleci/golang:1.13
2019-08-08 12:02:32 +02:00
- image: circleci/postgres:10.8-alpine
environment: # environment variables for primary container
POSTGRES_USER: jet
POSTGRES_PASSWORD: jet
POSTGRES_DB: jetdb
2021-01-24 16:47:06 +01:00
- image: circleci/mysql:8.0.16
2019-08-08 12:02:32 +02:00
command: [--default-authentication-plugin=mysql_native_password]
2019-08-08 10:51:59 +02:00
environment:
2019-08-08 11:58:47 +02:00
MYSQL_ROOT_PASSWORD: jet
MYSQL_DATABASE: dvds
MYSQL_USER: jet
MYSQL_PASSWORD: jet
2019-08-08 10:51:59 +02:00
working_directory: /go/src/github.com/go-jet/jet
environment: # environment variables for the build itself
TEST_RESULTS: /tmp/test-results # path to where test results will be saved
2019-06-21 14:54:23 +02:00
steps:
- checkout
2019-08-16 12:18:02 +02:00
- run:
2019-08-16 12:16:12 +02:00
name: Submodule init
command: |
git submodule init
git submodule update
2019-08-16 12:52:02 +02:00
cd ./tests/testdata && git fetch && git checkout master
2019-08-16 12:16:12 +02:00
- run:
name: Install dependencies
command: |
2021-01-24 16:47:06 +01:00
cd /go/src/github.com/go-jet/jet
go get github.com/jstemmer/go-junit-report
2021-01-24 16:47:06 +01:00
go build -o /home/circleci/.local/bin/jet ./cmd/jet/
- run:
name: Waiting for Postgres to be ready
command: |
for i in `seq 1 10`;
do
nc -z localhost 5432 && echo Success && exit 0
echo -n .
sleep 1
done
echo Failed waiting for Postgres && exit 1
- run:
2019-08-08 10:51:59 +02:00
name: Waiting for MySQL to be ready
command: |
for i in `seq 1 10`;
do
nc -z 127.0.0.1 3306 && echo Success && exit 0
echo -n .
sleep 1
done
echo Failed waiting for MySQL && exit 1
- run:
name: Install MySQL CLI;
command: |
2021-08-30 12:32:48 +02:00
sudo apt-get --allow-releaseinfo-change update && sudo apt-get install default-mysql-client
2019-08-08 10:51:59 +02:00
2019-08-08 12:02:32 +02:00
- run:
2019-08-15 12:28:59 +02:00
name: Create MySQL user and databases
2019-08-08 12:02:32 +02:00
command: |
mysql -h 127.0.0.1 -u root -pjet -e "grant all privileges on *.* to 'jet'@'%';"
2019-08-15 16:40:47 +02:00
mysql -h 127.0.0.1 -u root -pjet -e "set global sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';"
2019-08-08 12:02:32 +02:00
mysql -h 127.0.0.1 -u jet -pjet -e "create database test_sample"
mysql -h 127.0.0.1 -u jet -pjet -e "create database dvds2"
2019-08-08 11:58:47 +02:00
2019-08-08 10:51:59 +02:00
- run:
2019-08-08 12:02:32 +02:00
name: Init Postgres database
2019-08-08 10:51:59 +02:00
command: |
cd tests
2019-08-08 12:02:32 +02:00
go run ./init/init.go -testsuite all
2019-08-08 10:51:59 +02:00
cd ..
2019-08-08 12:02:32 +02:00
2019-07-19 14:33:54 +02:00
- run: mkdir -p $TEST_RESULTS
2021-10-21 17:30:57 +02:00
# this will run all tests and exclude test files from code coverage report
- run: MY_SQL_SOURCE=MySQL go test -v ./... -coverpkg=github.com/go-jet/jet/postgres/...,github.com/go-jet/jet/mysql/...,github.com/go-jet/jet/sqlite/...,github.com/go-jet/jet/qrm/...,github.com/go-jet/jet/generator/...,github.com/go-jet/jet/internal/... -coverprofile=cover.out 2>&1 | go-junit-report > $TEST_RESULTS/results.xml
2019-07-19 14:33:54 +02:00
- run:
name: Upload code coverage
command: bash <(curl -s https://codecov.io/bash)
- store_artifacts: # Upload test summary for display in Artifacts: https://circleci.com/docs/2.0/artifacts/
path: /tmp/test-results
destination: raw-test-output
- store_test_results: # Upload test results for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/
path: /tmp/test-results
2019-08-15 12:28:59 +02:00
build-mariadb:
docker:
# specify the version
2021-01-24 16:47:06 +01:00
- image: circleci/golang:1.13
2019-08-15 12:28:59 +02:00
2019-08-15 14:10:25 +02:00
- image: circleci/mariadb:10.3
2019-08-15 12:28:59 +02:00
command: [--default-authentication-plugin=mysql_native_password]
environment:
MYSQL_ROOT_PASSWORD: jet
MYSQL_DATABASE: dvds
MYSQL_USER: jet
MYSQL_PASSWORD: jet
working_directory: /go/src/github.com/go-jet/jet
environment: # environment variables for the build itself
TEST_RESULTS: /tmp/test-results # path to where test results will be saved
steps:
- checkout
2019-08-16 12:17:04 +02:00
- run:
2019-08-16 12:18:02 +02:00
name: Submodule init
command: |
git submodule init
git submodule update
2019-08-16 12:52:02 +02:00
cd ./tests/testdata && git fetch && git checkout master
2019-08-16 12:16:12 +02:00
2019-08-15 12:28:59 +02:00
- run:
name: Install dependencies
command: |
2021-01-24 16:47:06 +01:00
cd /go/src/github.com/go-jet/jet
2019-08-15 12:28:59 +02:00
go get github.com/jstemmer/go-junit-report
2021-01-24 16:47:06 +01:00
go build -o /home/circleci/.local/bin/jet ./cmd/jet/
2019-08-15 12:28:59 +02:00
2019-08-15 12:37:05 +02:00
- run:
name: Install MySQL CLI;
command: |
2021-08-30 12:32:48 +02:00
sudo apt-get --allow-releaseinfo-change update && sudo apt-get install default-mysql-client
2019-08-15 12:28:59 +02:00
- run:
name: Init MariaDB database
command: |
mysql -h 127.0.0.1 -u root -pjet -e "grant all privileges on *.* to 'jet'@'%';"
2019-08-15 16:40:47 +02:00
mysql -h 127.0.0.1 -u root -pjet -e "set global sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';"
2019-08-15 12:28:59 +02:00
mysql -h 127.0.0.1 -u jet -pjet -e "create database test_sample"
mysql -h 127.0.0.1 -u jet -pjet -e "create database dvds2"
2019-08-15 12:28:59 +02:00
- run:
name: Init MariaDB database
command: |
cd tests
go run ./init/init.go -testsuite MariaDB
cd ..
- run:
name: Run MariaDB tests
command: |
2021-01-24 16:47:06 +01:00
MY_SQL_SOURCE=MariaDB go test -v ./tests/mysql/
2019-08-15 12:34:56 +02:00
workflows:
version: 2
build_and_test:
jobs:
2019-08-16 13:08:13 +02:00
- build-postgres-and-mysql
2019-08-15 12:34:56 +02:00
- build-mariadb