fix: mysql results table commands and add tests (#49) #61
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
name: run tests | |
jobs: | |
test: | |
strategy: | |
matrix: | |
go-version: [1.21.x] | |
platform: [ubuntu-latest] | |
runs-on: ${{ matrix.platform }} | |
services: | |
redis: | |
image: redis | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 6379:6379 | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_PASSWORD: testPass | |
POSTGRES_USER: testUser | |
POSTGRES_DB: testDB | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
db: | |
image: mysql:8.0 | |
env: | |
MYSQL_ROOT_PASSWORD: rootpassword | |
MYSQL_DATABASE: mydb | |
MYSQL_USER: user | |
MYSQL_PASSWORD: userpassword | |
ports: | |
- "3306:3306" | |
# volumes: | |
# - mysql_data:/var/lib/mysql | |
steps: | |
- name: Install Go | |
if: success() | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Install Dependenies | |
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends ca-certificates postgresql-client | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Add postgres tables | |
run: PGPASSWORD=testPass psql -U testUser -h localhost -p 5432 -d testDB -c 'CREATE TABLE entries (id BIGSERIAL PRIMARY KEY, amount REAL, user_id VARCHAR(6), entry_date DATE, timestamp TIMESTAMP)'; | |
- name: Add mysql tables | |
run: mysql -h localhost -P 3306 -u root -p mydb --protocol=TCP --password=rootpassword -e 'CREATE TABLE entries (id BIGINT PRIMARY KEY, amount REAL, user_id VARCHAR(6), entry_date DATE, timestamp TIMESTAMP)' | |
- name: Build binary | |
run: CGO_ENABLED=0 go build -o server.bin -ldflags="-s -w -X 'main.buildString=${BUILDSTR}'" ./cmd/*.go | |
- name: Run binary server | |
run: ./server.bin --config config.test_pg.toml --sql-directory=sql/pg & | |
- name: Run tests | |
run: sleep 5 && go test ./client -v -covermode=count | |
- name: Run binary server | |
run: ./server.bin --config config.test_mysql.toml --sql-directory=sql/mysql & | |
- name: Run tests | |
run: sleep 5 && go test ./client -v -covermode=count |