Skip to content

Commit 3e802f8

Browse files
authored
Merge pull request go-jet#116 from go-jet/develop
Release 2.7.0
2 parents 23aeb02 + 4f29960 commit 3e802f8

File tree

106 files changed

+4368
-865
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+4368
-865
lines changed

.circleci/config.yml

Lines changed: 73 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,37 @@
11
# Golang CircleCI 2.0 configuration file
22
#
33
# 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
57
jobs:
6-
build-postgres-and-mysql:
8+
build_and_tests:
79
docker:
810
# 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:
1314
POSTGRES_USER: jet
1415
POSTGRES_PASSWORD: jet
1516
POSTGRES_DB: jetdb
17+
PGPORT: 50901
1618

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 ]
1921
environment:
2022
MYSQL_ROOT_PASSWORD: jet
2123
MYSQL_DATABASE: dvds
2224
MYSQL_USER: jet
2325
MYSQL_PASSWORD: jet
26+
MYSQL_TCP_PORT: 50902
2427

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
2635

2736
environment: # environment variables for the build itself
2837
TEST_RESULTS: /tmp/test-results # path to where test results will be saved
@@ -32,25 +41,22 @@ jobs:
3241

3342
- run:
3443
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
3945

46+
- restore_cache: # restores saved cache if no changes are detected since last run
47+
keys:
48+
- go-mod-v4-{{ checksum "go.sum" }}
4049

4150
- 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
4753

4854
- run:
4955
name: Waiting for Postgres to be ready
5056
command: |
5157
for i in `seq 1 10`;
5258
do
53-
nc -z localhost 5432 && echo Success && exit 0
59+
nc -z localhost 50901 && echo Success && exit 0
5460
echo -n .
5561
sleep 1
5662
done
@@ -61,109 +67,81 @@ jobs:
6167
command: |
6268
for i in `seq 1 10`;
6369
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
6571
echo -n .
6672
sleep 1
6773
done
6874
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+
6987
- run:
7088
name: Install MySQL CLI;
7189
command: |
7290
sudo apt-get --allow-releaseinfo-change update && sudo apt-get install default-mysql-client
7391
7492
- run:
75-
name: Create MySQL user and databases
93+
name: Create MySQL/MariaDB user and test databases
7694
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"
81104
82105
- 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
88110
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
89115

90116
- run: mkdir -p $TEST_RESULTS
117+
91118
# 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
93124
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
97135

98136
- store_artifacts: # Upload test summary for display in Artifacts: https://circleci.com/docs/2.0/artifacts/
99137
path: /tmp/test-results
100138
destination: raw-test-output
101139

102140
- store_test_results: # Upload test results for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/
103141
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/
163142

164143
workflows:
165144
version: 2
166145
build_and_test:
167146
jobs:
168-
- build-postgres-and-mysql
169-
- build-mariadb
147+
- build_and_tests

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@
1919
gen
2020
.gentestdata
2121
.tests/testdata/
22-
.gen
22+
.gen
23+
.docker
24+
.env

README.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,28 +60,26 @@ Use the command bellow to add jet as a dependency into `go.mod` project:
6060
$ go get -u github.com/go-jet/jet/v2
6161
```
6262

63-
Jet generator can be installed in the following ways:
63+
Jet generator can be installed in one of the following ways:
6464

65-
1) Install jet generator to GOPATH/bin folder:
65+
1) (Go1.16+) Install jet generator using go install:
6666
```sh
67-
cd $GOPATH/src/ && GO111MODULE=off go get -u github.com/go-jet/jet/cmd/jet
67+
go install github.com/go-jet/jet/v2/cmd/jet@latest
6868
```
69-
*Make sure GOPATH/bin folder is added to the PATH environment variable.*
7069

71-
2) Install jet generator into specific folder:
72-
70+
2) Install jet generator to GOPATH/bin folder:
71+
```sh
72+
cd $GOPATH/src/ && GO111MODULE=off go get -u github.com/go-jet/jet/cmd/jet
73+
```
74+
75+
3) Install jet generator into specific folder:
7376
```sh
7477
git clone https://github.com/go-jet/jet.git
7578
cd jet && go build -o dir_path ./cmd/jet
7679
```
77-
*Make sure `dir_path` folder is added to the PATH environment variable.*
80+
*Make sure that the destination folder is added to the PATH environment variable.*
81+
7882

79-
3) (Go1.16+) Install jet generator using go install:
80-
```sh
81-
go install github.com/go-jet/jet/v2/cmd/jet@latest
82-
```
83-
*Jet generator is installed to the directory named by the GOBIN environment variable,
84-
which defaults to $GOPATH/bin or $HOME/go/bin if the GOPATH environment variable is not set.*
8583

8684
### Quick Start
8785
For this quick start example we will use PostgreSQL sample _'dvd rental'_ database. Full database dump can be found in

0 commit comments

Comments
 (0)