Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup testing stuff #767

Merged
merged 2 commits into from Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 15 additions & 9 deletions .github/workflows/tests.yml
@@ -1,7 +1,8 @@
name: Tests
on:
push:
branches: [ main ]
branches:
- main
pull_request:

jobs:
Expand All @@ -22,7 +23,7 @@ jobs:
ports:
- 3307:3306
# needed because the mysql container does not provide a healthcheck
options: --health-cmd "mysqladmin ping -h localhost" --health-interval 10s --health-timeout 5s --health-retries 5
options: --health-cmd "mysqladmin ping -h localhost" --health-interval 5s --health-timeout 5s --health-retries 10

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -59,15 +60,15 @@ jobs:

services:
postgres:
image: postgres:14
image: postgres:10
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
- 5433:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
options: --health-cmd pg_isready --health-interval 5s --health-timeout 5s --health-retries 10

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -113,8 +114,10 @@ jobs:
run: |
mkdir -p crdb/certs
pushd crdb
wget -qO- https://binaries.cockroachdb.com/cockroach-v20.2.4.linux-amd64.tgz | tar zxv
mv cockroach-v20.2.4.linux-amd64/cockroach .
wget -qO- https://binaries.cockroachdb.com/cockroach-v21.1.19.linux-amd64.tgz | tar -xz
mv cockroach-v21.1.19.linux-amd64/* .
ln -s `pwd`/cockroach /usr/local/bin/
cockroach version
./cockroach cert create-ca --certs-dir certs --ca-key key
./cockroach cert create-client root --certs-dir certs --ca-key key
./cockroach cert create-node localhost 127.0.0.1 `hostname -s` `hostname -f` --certs-dir certs --ca-key key
Expand Down Expand Up @@ -156,14 +159,16 @@ jobs:
run: |
mkdir -p crdb
pushd crdb
wget -qO- https://binaries.cockroachdb.com/cockroach-v20.2.4.linux-amd64.tgz | tar zxv
mv cockroach-v20.2.4.linux-amd64/cockroach .
wget -qO- https://binaries.cockroachdb.com/cockroach-v21.1.19.linux-amd64.tgz | tar -xz
mv cockroach-v21.1.19.linux-amd64/* .
ln -s `pwd`/cockroach /usr/local/bin/
./cockroach start-single-node --insecure --background
popd

- name: Build and run soda
env:
SODA_DIALECT: "cockroach"
COCKROACH_PORT: 26257
run: |
go build -v -tags sqlite -o tsoda ./soda
./tsoda drop -e $SODA_DIALECT -p ./testdata/migrations
Expand All @@ -173,6 +178,7 @@ jobs:
- name: Test
env:
SODA_DIALECT: "cockroach"
COCKROACH_PORT: 26257
run: |
go test -tags sqlite -race -cover ./...

Expand Down
21 changes: 0 additions & 21 deletions Makefile
Expand Up @@ -7,36 +7,15 @@ GO_BIN ?= go
install: deps
$(GO_BIN) install -tags ${TAGS} -v ./soda

deps:
$(GO_BIN) get github.com/gobuffalo/release
$(GO_BIN) get -tags ${TAGS} -t ./...
ifeq ($(GO111MODULE),on)
$(GO_BIN) mod tidy
endif

build:
$(GO_BIN) build -v .

test:
$(GO_BIN) test -tags ${TAGS} ./...

ci-test:
$(GO_BIN) test -tags ${TAGS} -race ./...

lint:
golangci-lint run

update:
$(GO_BIN) get -u -tags ${TAGS}
ifeq ($(GO111MODULE),on)
$(GO_BIN) mod tidy
endif
make test
make install
ifeq ($(GO111MODULE),on)
$(GO_BIN) mod tidy
endif

release-test:
./test.sh

Expand Down
4 changes: 2 additions & 2 deletions database.yml
Expand Up @@ -9,7 +9,7 @@ mysql:
readTimeout: 5s

postgres:
url: {{ envOr "POSTGRESQL_URL" "postgres://postgres:postgres@localhost:5432/pop_test?sslmode=disable" }}
url: {{ envOr "POSTGRESQL_URL" "postgres://postgres:postgres@localhost:5433/pop_test?sslmode=disable" }}
pool: 25

cockroach:
Expand All @@ -29,5 +29,5 @@ cockroach_ssl:

sqlite:
dialect: "sqlite3"
database: "./sql_scripts/sqlite/test.sqlite"
database: "tmp/test.sqlite"

40 changes: 28 additions & 12 deletions docker-compose.yml
Expand Up @@ -8,26 +8,42 @@ services:
- MYSQL_DATABASE=pop_test
- MYSQL_USER=pop
- MYSQL_PASSWORD=pop
volumes:
- ./sql:/docker-entrypoint-initdb.d
ports:
- "3306:3306"
- "3307:3306"
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
interval: 5s
timeout: 5s
retries: 10
start_period: 3s

postgres:
image: postgres:10.21
image: postgres:10
environment:
- POSTGRES_DB=pop_test
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
ports:
- "5432:5432"
volumes:
- ./sqldumps:/docker-entrypoint-initdb.d
- "5433:5432"
healthcheck:
test: ["CMD", "pg_isready"]
interval: 5s
timeout: 5s
retries: 10
start_period: 3s

cockroach:
image: cockroachdb/cockroach:v20.2.4
user: ${CURRENT_UID:?"Please run as follows 'CURRENT_UID=$$(id -u):$$(id -g) docker-compose up'"}
image: cockroachdb/cockroach:latest-v21.1
ports:
- "26257:26257"
volumes:
- "./cockroach-data/roach1:/cockroach/cockroach-data"
- "26258:26257"
- "8081:8080"
#volumes:
#- ./_vol/cockroach:/cockroach/cockroach-data
command: start-single-node --insecure
healthcheck:
test: ["CMD", "curl", "http://localhost:8080/health"]
interval: 5s
timeout: 5s
retries: 10
start_period: 3s
26 changes: 13 additions & 13 deletions go.mod
Expand Up @@ -5,24 +5,24 @@ go 1.16
require (
github.com/fatih/color v1.13.0
github.com/go-sql-driver/mysql v1.6.0
github.com/gobuffalo/attrs v1.0.2
github.com/gobuffalo/envy v1.10.1
github.com/gobuffalo/fizz v1.14.2
github.com/gobuffalo/flect v0.2.5
github.com/gobuffalo/genny/v2 v2.0.12
github.com/gobuffalo/logger v1.0.6
github.com/gobuffalo/nulls v0.4.1
github.com/gobuffalo/plush/v4 v4.1.14
github.com/gobuffalo/validate/v3 v3.3.2
github.com/gofrs/uuid v4.2.0+incompatible
github.com/gobuffalo/attrs v1.0.3
github.com/gobuffalo/envy v1.10.2
github.com/gobuffalo/fizz v1.14.3
github.com/gobuffalo/flect v0.3.0
github.com/gobuffalo/genny/v2 v2.0.13
github.com/gobuffalo/logger v1.0.7
github.com/gobuffalo/nulls v0.4.2
github.com/gobuffalo/plush/v4 v4.1.15
github.com/gobuffalo/validate/v3 v3.3.3
github.com/gofrs/uuid v4.3.0+incompatible
github.com/jackc/pgconn v1.13.0
github.com/jackc/pgx/v4 v4.17.1
github.com/jackc/pgx/v4 v4.17.2
github.com/jmoiron/sqlx v1.3.5
github.com/lib/pq v1.10.6
github.com/lib/pq v1.10.7
github.com/luna-duclos/instrumentedsql v1.1.3
github.com/mattn/go-sqlite3 v1.14.15
github.com/spf13/cobra v1.5.0
github.com/stretchr/testify v1.8.0
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f
golang.org/x/sync v0.0.0-20220907140024-f12130a52804
gopkg.in/yaml.v2 v2.4.0
)