jet/.circleci/config.yml

166 lines
5.7 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
2021-12-18 13:55:40 +01:00
version: 2.1
orbs:
codecov: codecov/codecov@3.1.1
2019-06-21 14:54:23 +02:00
jobs:
2021-12-18 13:55:40 +01:00
build_and_tests:
2019-06-21 14:54:23 +02:00
docker:
# specify the version
2021-12-18 13:55:40 +01:00
- image: circleci/golang:1.16
- image: circleci/postgres:12
environment:
POSTGRES_USER: jet
POSTGRES_PASSWORD: jet
POSTGRES_DB: jetdb
2021-12-18 13:55:40 +01:00
PGPORT: 50901
2021-12-18 13:55:40 +01:00
- image: circleci/mysql:8.0.27
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
2021-12-18 13:55:40 +01:00
MYSQL_TCP_PORT: 50902
2019-08-08 10:51:59 +02:00
2021-12-18 13:55:40 +01:00
- image: circleci/mariadb:10.3
command: [ '--default-authentication-plugin=mysql_native_password', '--port=50903' ]
environment:
MYSQL_ROOT_PASSWORD: jet
MYSQL_DATABASE: dvds
MYSQL_USER: jet
MYSQL_PASSWORD: jet
2022-05-05 13:01:42 +02:00
- image: cockroachdb/cockroach-unstable:v22.1.0-beta.4
command: ['start-single-node', '--insecure']
environment:
COCKROACH_USER: jet
COCKROACH_PASSWORD: jet
COCKROACH_DATABASE: jetdb
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
2021-12-18 13:55:40 +01:00
command: cd tests && make checkout-testdata
2019-08-16 12:16:12 +02:00
2021-12-18 13:55:40 +01:00
- restore_cache: # restores saved cache if no changes are detected since last run
keys:
- go-mod-v4-{{ checksum "go.sum" }}
2019-08-16 12:16:12 +02:00
- run:
2021-12-18 13:55:40 +01:00
name: Install jet generator
command: cd tests && make install-jet-gen
- run:
name: Waiting for Postgres to be ready
command: |
for i in `seq 1 10`;
do
2021-12-18 13:55:40 +01:00
nc -z localhost 50901 && 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
2021-12-18 13:55:40 +01:00
nc -z 127.0.0.1 50902 && echo Success && exit 0
2019-08-08 10:51:59 +02:00
echo -n .
sleep 1
done
echo Failed waiting for MySQL && exit 1
2021-12-18 13:55:40 +01:00
- run:
name: Waiting for MariaDB to be ready
command: |
for i in `seq 1 10`;
do
nc -z 127.0.0.1 50903 && echo Success && exit 0
echo -n .
sleep 1
done
2022-05-05 13:01:42 +02:00
echo Failed waiting for MySQL && exit 1
- run:
name: Waiting for Cockroach to be ready
command: |
for i in `seq 1 10`;
do
nc -z localhost 26257 && echo Success && exit 0
echo -n .
sleep 1
done
echo Failed waiting for Cockroach && exit 1
2021-12-18 13:55:40 +01:00
2019-08-08 10:51:59 +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-08 10:51:59 +02:00
2019-08-08 12:02:32 +02:00
- run:
2021-12-18 13:55:40 +01:00
name: Create MySQL/MariaDB user and test databases
2019-08-08 12:02:32 +02:00
command: |
2021-12-18 13:55:40 +01:00
mysql -h 127.0.0.1 -P 50902 -u root -pjet -e "grant all privileges on *.* to 'jet'@'%';"
mysql -h 127.0.0.1 -P 50902 -u root -pjet -e "set global sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';"
mysql -h 127.0.0.1 -P 50902 -u jet -pjet -e "create database test_sample"
mysql -h 127.0.0.1 -P 50902 -u jet -pjet -e "create database dvds2"
mysql -h 127.0.0.1 -P 50903 -u root -pjet -e "grant all privileges on *.* to 'jet'@'%';"
mysql -h 127.0.0.1 -P 50903 -u root -pjet -e "set global sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';"
mysql -h 127.0.0.1 -P 50903 -u jet -pjet -e "create database test_sample"
mysql -h 127.0.0.1 -P 50903 -u jet -pjet -e "create database dvds2"
2019-08-08 11:58:47 +02:00
2019-08-08 10:51:59 +02:00
- run:
2021-12-18 13:55:40 +01:00
name: Init databases
command: |
cd tests
go run ./init/init.go -testsuite all
2021-12-18 13:55:40 +01:00
# to create test results report
- run:
name: Install go-junit-report
command: go install github.com/jstemmer/go-junit-report@latest
2019-08-08 12:02:32 +02:00
2019-07-19 14:33:54 +02:00
- run: mkdir -p $TEST_RESULTS
2021-12-18 13:55:40 +01:00
2021-10-21 17:30:57 +02:00
# this will run all tests and exclude test files from code coverage report
2021-12-18 13:55:40 +01:00
- run: |
go test -v ./... \
-covermode=atomic \
-coverpkg=github.com/go-jet/jet/v2/postgres/...,github.com/go-jet/jet/v2/mysql/...,github.com/go-jet/jet/v2/sqlite/...,github.com/go-jet/jet/v2/qrm/...,github.com/go-jet/jet/v2/generator/...,github.com/go-jet/jet/v2/internal/... \
-coverprofile=cover.out 2>&1 | go-junit-report > $TEST_RESULTS/results.xml
2019-07-19 14:33:54 +02:00
2022-05-05 13:01:42 +02:00
# run mariaDB and cockroachdb tests. No need to collect coverage, because coverage is already included with mysql and postgres tests
2021-12-18 13:55:40 +01:00
- run: MY_SQL_SOURCE=MariaDB go test -v ./tests/mysql/
2022-05-05 13:01:42 +02:00
- run: PG_SOURCE=COCKROACH_DB go test -v ./tests/postgres/
2021-12-18 13:55:40 +01:00
- save_cache:
key: go-mod-v4-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
- codecov/upload:
file: cover.out
2019-07-19 14:33:54 +02:00
- 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:34:56 +02:00
workflows:
version: 2
build_and_test:
jobs:
2021-12-18 13:55:40 +01:00
- build_and_tests