Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sahilm committed Jun 24, 2024
1 parent 788655a commit 60cc512
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/buildandrun-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: MySQL 8.0 Build and Run /w docker-compose
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build and Run Spirit
run: docker compose -f compose.yml -f app.yml up --abort-on-container-exit
15 changes: 15 additions & 0 deletions .github/workflows/mysql8.0.28-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: MySQL 8.0.28 (Aurora version) /w docker-compose
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Test
run: docker compose -f compose.yml -f 8.0.28.yml -f test.yml up --abort-on-container-exit
15 changes: 15 additions & 0 deletions .github/workflows/mysql8_rbr_minimal_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: MySQL 8.0.33 (RBR minimal) /w docker-compose
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Test
run: docker compose -f compose.yml -f 8.0.33-rbr-minimal.yml -f test.yml up --abort-on-container-exit
5 changes: 5 additions & 0 deletions 8.0.28.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
mysql:
image: mysql:8.0.28
platform: linux/amd64
ports: [ '8028:3306' ]
4 changes: 4 additions & 0 deletions 8.0.33-rbr-minimal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
services:
mysql:
ports: [ '8333:3306' ]
command: --binlog-row-image=MINIMAL
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM golang:1.22

WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .

RUN CGO_ENABLED=0 go build ./cmd/spirit

CMD ./spirit --host "mysql:3306" --database=test --table=t1
8 changes: 8 additions & 0 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM golang:1.22

WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .

CMD go test -race -v ./...
8 changes: 8 additions & 0 deletions app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
app:
build:
context: .
dockerfile: Dockerfile
depends_on:
mysql:
condition: service_healthy
18 changes: 18 additions & 0 deletions bootstrap.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use mysql;
set password='msandbox';

create role if not exists R_DO_IT_ALL;
grant all on *.* to R_DO_IT_ALL;
create user if not exists msandbox@'%' identified by 'msandbox';

grant R_DO_IT_ALL to msandbox@'%' ;
set default role R_DO_IT_ALL to msandbox@'%';

create schema if not exists test;

create table if not exists test.t1
(
id int not null primary key auto_increment,
b int not null,
c int not null
)
18 changes: 18 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
services:
mysql:
image: mysql:8.0.33
ports: [ '8033:3306' ]
# to supress mbind: Operation not permitted in CI
# https://stackoverflow.com/a/55706057
cap_add:
- SYS_NICE
environment:
MYSQL_ROOT_PASSWORD: msandbox
healthcheck:
test: mysqladmin ping -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD
start_period: 1s
interval: 1s
timeout: 2s
retries: 60
volumes:
- ./bootstrap.sql:/docker-entrypoint-initdb.d/bootstrap.sql
10 changes: 10 additions & 0 deletions test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
test:
build:
context: .
dockerfile: Dockerfile.test
depends_on:
mysql:
condition: service_healthy
environment:
MYSQL_DSN: msandbox:msandbox@tcp(mysql)/test

0 comments on commit 60cc512

Please sign in to comment.