1
1
# Golang CircleCI 2.0 configuration file
2
2
#
3
3
# Check https://circleci.com/docs/2.0/language-go/ for more details
4
- version : 2
4
+ version : 2.1
5
+ orbs :
6
+ codecov : codecov/codecov@3.1.1
5
7
jobs :
6
- build-postgres-and-mysql :
8
+ build_and_tests :
7
9
docker :
8
10
# specify the version
9
- - image : circleci/golang:1.13
10
-
11
- - image : circleci/postgres:10.8-alpine
12
- environment : # environment variables for primary container
11
+ - image : circleci/golang:1.16
12
+ - image : circleci/postgres:12
13
+ environment :
13
14
POSTGRES_USER : jet
14
15
POSTGRES_PASSWORD : jet
15
16
POSTGRES_DB : jetdb
17
+ PGPORT : 50901
16
18
17
- - image : circleci/mysql:8.0.16
18
- command : [--default-authentication-plugin=mysql_native_password]
19
+ - image : circleci/mysql:8.0.27
20
+ command : [ --default-authentication-plugin=mysql_native_password ]
19
21
environment :
20
22
MYSQL_ROOT_PASSWORD : jet
21
23
MYSQL_DATABASE : dvds
22
24
MYSQL_USER : jet
23
25
MYSQL_PASSWORD : jet
26
+ MYSQL_TCP_PORT : 50902
24
27
25
- working_directory : /go/src/github.com/go-jet/jet
28
+ - image : circleci/mariadb:10.3
29
+ command : [ '--default-authentication-plugin=mysql_native_password', '--port=50903' ]
30
+ environment :
31
+ MYSQL_ROOT_PASSWORD : jet
32
+ MYSQL_DATABASE : dvds
33
+ MYSQL_USER : jet
34
+ MYSQL_PASSWORD : jet
26
35
27
36
environment : # environment variables for the build itself
28
37
TEST_RESULTS : /tmp/test-results # path to where test results will be saved
@@ -32,25 +41,22 @@ jobs:
32
41
33
42
- run :
34
43
name : Submodule init
35
- command : |
36
- git submodule init
37
- git submodule update
38
- cd ./tests/testdata && git fetch && git checkout master
44
+ command : cd tests && make checkout-testdata
39
45
46
+ - restore_cache : # restores saved cache if no changes are detected since last run
47
+ keys :
48
+ - go-mod-v4-{{ checksum "go.sum" }}
40
49
41
50
- run :
42
- name : Install dependencies
43
- command : |
44
- cd /go/src/github.com/go-jet/jet
45
- go get github.com/jstemmer/go-junit-report
46
- go build -o /home/circleci/.local/bin/jet ./cmd/jet/
51
+ name : Install jet generator
52
+ command : cd tests && make install-jet-gen
47
53
48
54
- run :
49
55
name : Waiting for Postgres to be ready
50
56
command : |
51
57
for i in `seq 1 10`;
52
58
do
53
- nc -z localhost 5432 && echo Success && exit 0
59
+ nc -z localhost 50901 && echo Success && exit 0
54
60
echo -n .
55
61
sleep 1
56
62
done
@@ -61,109 +67,81 @@ jobs:
61
67
command : |
62
68
for i in `seq 1 10`;
63
69
do
64
- nc -z 127.0.0.1 3306 && echo Success && exit 0
70
+ nc -z 127.0.0.1 50902 && echo Success && exit 0
65
71
echo -n .
66
72
sleep 1
67
73
done
68
74
echo Failed waiting for MySQL && exit 1
75
+
76
+ - run :
77
+ name : Waiting for MariaDB to be ready
78
+ command : |
79
+ for i in `seq 1 10`;
80
+ do
81
+ nc -z 127.0.0.1 50903 && echo Success && exit 0
82
+ echo -n .
83
+ sleep 1
84
+ done
85
+ echo Failed waiting for MySQL && exit 1
86
+
69
87
- run :
70
88
name : Install MySQL CLI;
71
89
command : |
72
90
sudo apt-get --allow-releaseinfo-change update && sudo apt-get install default-mysql-client
73
91
74
92
- run :
75
- name : Create MySQL user and databases
93
+ name : Create MySQL/MariaDB user and test databases
76
94
command : |
77
- mysql -h 127.0.0.1 -u root -pjet -e "grant all privileges on *.* to 'jet'@'%';"
78
- 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';"
79
- mysql -h 127.0.0.1 -u jet -pjet -e "create database test_sample"
80
- mysql -h 127.0.0.1 -u jet -pjet -e "create database dvds2"
95
+ mysql -h 127.0.0.1 -P 50902 -u root -pjet -e "grant all privileges on *.* to 'jet'@'%';"
96
+ 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';"
97
+ mysql -h 127.0.0.1 -P 50902 -u jet -pjet -e "create database test_sample"
98
+ mysql -h 127.0.0.1 -P 50902 -u jet -pjet -e "create database dvds2"
99
+
100
+ mysql -h 127.0.0.1 -P 50903 -u root -pjet -e "grant all privileges on *.* to 'jet'@'%';"
101
+ 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';"
102
+ mysql -h 127.0.0.1 -P 50903 -u jet -pjet -e "create database test_sample"
103
+ mysql -h 127.0.0.1 -P 50903 -u jet -pjet -e "create database dvds2"
81
104
82
105
- run :
83
- name : Init Postgres database
84
- command : |
85
- cd tests
86
- go run ./init/init.go -testsuite all
87
- cd ..
106
+ name : Init databases
107
+ command : |
108
+ cd tests
109
+ go run ./init/init.go -testsuite all
88
110
111
+ # to create test results report
112
+ - run :
113
+ name : Install go-junit-report
114
+ command : go install github.com/jstemmer/go-junit-report@latest
89
115
90
116
- run : mkdir -p $TEST_RESULTS
117
+
91
118
# this will run all tests and exclude test files from code coverage report
92
- - run : MY_SQL_SOURCE=MySQL go test -v ./... -covermode=atomic -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
119
+ - run : |
120
+ go test -v ./... \
121
+ -covermode=atomic \
122
+ -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/... \
123
+ -coverprofile=cover.out 2>&1 | go-junit-report > $TEST_RESULTS/results.xml
93
124
94
- - run :
95
- name : Upload code coverage
96
- command : bash <(curl -s https://codecov.io/bash)
125
+ # run mariaDB tests. No need to collect coverage, because coverage is already included with mysql tests
126
+ - run : MY_SQL_SOURCE=MariaDB go test -v ./tests/mysql/
127
+
128
+ - save_cache :
129
+ key : go-mod-v4-{{ checksum "go.sum" }}
130
+ paths :
131
+ - " /go/pkg/mod"
132
+
133
+ - codecov/upload :
134
+ file : cover.out
97
135
98
136
- store_artifacts : # Upload test summary for display in Artifacts: https://circleci.com/docs/2.0/artifacts/
99
137
path : /tmp/test-results
100
138
destination : raw-test-output
101
139
102
140
- store_test_results : # Upload test results for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/
103
141
path : /tmp/test-results
104
- build-mariadb :
105
- docker :
106
- # specify the version
107
- - image : circleci/golang:1.13
108
-
109
- - image : circleci/mariadb:10.3
110
- command : [--default-authentication-plugin=mysql_native_password]
111
- environment :
112
- MYSQL_ROOT_PASSWORD : jet
113
- MYSQL_DATABASE : dvds
114
- MYSQL_USER : jet
115
- MYSQL_PASSWORD : jet
116
-
117
- working_directory : /go/src/github.com/go-jet/jet
118
-
119
- environment : # environment variables for the build itself
120
- TEST_RESULTS : /tmp/test-results # path to where test results will be saved
121
-
122
- steps :
123
- - checkout
124
-
125
- - run :
126
- name : Submodule init
127
- command : |
128
- git submodule init
129
- git submodule update
130
- cd ./tests/testdata && git fetch && git checkout master
131
-
132
- - run :
133
- name : Install dependencies
134
- command : |
135
- cd /go/src/github.com/go-jet/jet
136
- go get github.com/jstemmer/go-junit-report
137
- go build -o /home/circleci/.local/bin/jet ./cmd/jet/
138
-
139
- - run :
140
- name : Install MySQL CLI;
141
- command : |
142
- sudo apt-get --allow-releaseinfo-change update && sudo apt-get install default-mysql-client
143
-
144
- - run :
145
- name : Init MariaDB database
146
- command : |
147
- mysql -h 127.0.0.1 -u root -pjet -e "grant all privileges on *.* to 'jet'@'%';"
148
- 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';"
149
- mysql -h 127.0.0.1 -u jet -pjet -e "create database test_sample"
150
- mysql -h 127.0.0.1 -u jet -pjet -e "create database dvds2"
151
-
152
- - run :
153
- name : Init MariaDB database
154
- command : |
155
- cd tests
156
- go run ./init/init.go -testsuite MariaDB
157
- cd ..
158
-
159
- - run :
160
- name : Run MariaDB tests
161
- command : |
162
- MY_SQL_SOURCE=MariaDB go test -v ./tests/mysql/
163
142
164
143
workflows :
165
144
version : 2
166
145
build_and_test :
167
146
jobs :
168
- - build-postgres-and-mysql
169
- - build-mariadb
147
+ - build_and_tests
0 commit comments