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
|
2024-10-08 10:17:25 -04:00
|
|
|
- image: cimg/go:1.22.2
|
2024-02-07 11:18:29 +01:00
|
|
|
- image: cimg/postgres:14.10
|
2021-12-18 13:55:40 +01:00
|
|
|
environment:
|
2019-06-21 16:16:57 +02:00
|
|
|
POSTGRES_USER: jet
|
|
|
|
|
POSTGRES_PASSWORD: jet
|
|
|
|
|
POSTGRES_DB: jetdb
|
2021-12-18 13:55:40 +01:00
|
|
|
PGPORT: 50901
|
2019-06-21 16:16:57 +02:00
|
|
|
|
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
|
2019-06-21 16:16:57 +02:00
|
|
|
|
2024-02-01 17:36:12 +01:00
|
|
|
- image: cockroachdb/cockroach-unstable:v23.1.0-rc.2
|
|
|
|
|
command: ['start-single-node', '--accept-sql-without-tls']
|
2022-05-05 13:01:42 +02:00
|
|
|
environment:
|
|
|
|
|
COCKROACH_USER: jet
|
|
|
|
|
COCKROACH_PASSWORD: jet
|
|
|
|
|
COCKROACH_DATABASE: jetdb
|
|
|
|
|
|
2019-06-21 16:16:57 +02:00
|
|
|
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
|
|
|
|
2019-06-21 16:16:57 +02:00
|
|
|
- run:
|
2021-12-18 13:55:40 +01:00
|
|
|
name: Install jet generator
|
|
|
|
|
command: cd tests && make install-jet-gen
|
2019-06-21 16:16:57 +02:00
|
|
|
|
|
|
|
|
- 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
|
2019-06-21 16:16:57 +02:00
|
|
|
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;
|
2019-06-21 16:16:57 +02:00
|
|
|
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
|
2019-06-21 16:16:57 +02:00
|
|
|
|
2021-12-18 13:55:40 +01:00
|
|
|
# to create test results report
|
|
|
|
|
- run:
|
2024-10-08 10:17:25 -04:00
|
|
|
name: Install gotestsum
|
|
|
|
|
command: go install gotest.tools/gotestsum@latest
|
2019-07-19 14:33:54 +02:00
|
|
|
- run: mkdir -p $TEST_RESULTS
|
2021-12-18 13:55:40 +01:00
|
|
|
|
2024-10-08 10:17:25 -04:00
|
|
|
- run:
|
|
|
|
|
name: Running tests
|
|
|
|
|
command: gotestsum --junitfile report.xml --format testname -- -coverprofile=cover.out -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/... ./...
|
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
|
|
|
|
2019-06-21 16:16:57 +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:
|
2024-10-08 10:17:25 -04:00
|
|
|
- build_and_tests
|