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

Introduce GitHub actions #2

Merged
merged 8 commits into from
Dec 24, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
# This is a basic workflow to help you get started with Actions
name: reviewdog

name: CI
on: pull_request

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
actionlint:
name: golangci-lint
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: reviewdog/action-actionlint@v1
with:
reporter: github-pr-review
level: warning

# Runs a single command using the runners shell
- name: Run golangci-lint with reviewdog
uses: reviewdog/[email protected]
golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: reviewdog/action-golangci-lint@v2
with:
reporter: github-pr-review
level: warning
42 changes: 42 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: test

on:
push:
branches: main
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
mysql: ["5.6", "5.7", "8.0"]
services:
db:
image: mysql:${{ matrix.mysql }}
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: sakila
MYSQL_USER: user
MYSQL_PASSWORD: password
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: setup go 1.19
uses: actions/setup-go@v3
with:
go-version: "1.19"
cache: true
- name: prepare test
run: mysql -uroot -proot -h127.0.0.1 -P3306 sakila < ./testdata/schema/sakila.sql
- name: test with MySQL ${{ matrix.mysql }}
run: go test -v -race ./...
env:
TEST_DSN: "root:root@tcp(127.0.0.1:3306)/sakila?parseTime=true"
47 changes: 0 additions & 47 deletions .travis.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .travis/docker.cnf

This file was deleted.

8 changes: 0 additions & 8 deletions .travis/wait_mysql.sh

This file was deleted.

21 changes: 12 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
version: '3'
services:
mysql5.6:
image: ${MYSQL_IMAGE:-mysql:5.6}
image: mysql:5.6
platform: linux/amd64
ports:
- ${MYSQL_HOST:-127.0.0.1}:${MYSQL_PORT:-3306}:3306
- 3306:3306
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
- MYSQL_ROOT_PASSWORD=root
# MariaDB >= 10.0.12 doesn't enable Performance Schema by default so we need to do it manually
# https://mariadb.com/kb/en/mariadb/performance-schema-overview/#activating-the-performance-schema
command: --performance-schema --secure-file-priv=""
volumes:
- ./testdata/schema/:/docker-entrypoint-initdb.d/:rw
mysql5.7:
image: ${MYSQL_IMAGE:-mysql:5.7}
image: mysql:5.7
platform: linux/amd64
ports:
- ${MYSQL_HOST:-127.0.0.1}:${MYSQL_PORT:-3307}:3306
- 3307:3306
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
- MYSQL_ROOT_PASSWORD=root
# MariaDB >= 10.0.12 doesn't enable Performance Schema by default so we need to do it manually
# https://mariadb.com/kb/en/mariadb/performance-schema-overview/#activating-the-performance-schema
command: --performance-schema --secure-file-priv=""
volumes:
- ./testdata/schema/:/docker-entrypoint-initdb.d/:rw
mysql8.0:
image: ${MYSQL_IMAGE:-mysql:8.0.3}
image: mysql:8.0
platform: linux/amd64
ports:
- ${MYSQL_HOST:-127.0.0.1}:${MYSQL_PORT:-3308}:3306
- 3308:3306
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
- MYSQL_ROOT_PASSWORD=root
# MariaDB >= 10.0.12 doesn't enable Performance Schema by default so we need to do it manually
# https://mariadb.com/kb/en/mariadb/performance-schema-overview/#activating-the-performance-schema
command: --performance-schema --secure-file-priv=""
Expand Down
2 changes: 1 addition & 1 deletion runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ for PORT in 3306 3307 3308; do
echo "### MySQL at port ${PORT}"
echo "##########################"
wait_mysql $PORT
export TEST_DSN="root:@tcp(127.1:${PORT})/sakila?parseTime=true"
export TEST_DSN="root:root@tcp(127.1:${PORT})/sakila?parseTime=true"
go test -v ./...
done

6 changes: 3 additions & 3 deletions tableparser/tableparser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestParse(t *testing.T) {
}
tu.LoadJson(t, sampleFile, &want)

tu.Equals(t, table, want)
tu.Equals(t, want, table)
}

func TestGetIndexes(t *testing.T) {
Expand All @@ -49,7 +49,7 @@ func TestGetIndexes(t *testing.T) {
tu.WriteJson(t, "indexes.json", idx)
}
tu.Ok(t, err)
tu.Equals(t, idx, want)
tu.Equals(t, want, idx)
}

func TestGetTriggers(t *testing.T) {
Expand Down Expand Up @@ -77,5 +77,5 @@ func TestGetTriggers(t *testing.T) {
tu.WriteJson(t, sampleFile, triggers)
}
tu.Ok(t, err)
tu.Equals(t, triggers, want)
tu.Equals(t, want, triggers)
}
32 changes: 16 additions & 16 deletions tableparser/testdata/table003.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"String": "",
"Valid": false
},
"ColumnType": "smallint(5) unsigned",
"ColumnType": "smallint unsigned",
"ColumnKey": "PRI",
"Extra": "auto_increment",
"Privileges": "select,insert,update,references",
Expand Down Expand Up @@ -88,11 +88,11 @@
"Valid": false
},
"CharacterSetName": {
"String": "utf8",
"String": "utf8mb3",
"Valid": true
},
"CollationName": {
"String": "utf8_general_ci",
"String": "utf8mb3_general_ci",
"Valid": true
},
"ColumnType": "varchar(255)",
Expand Down Expand Up @@ -141,11 +141,11 @@
"Valid": false
},
"CharacterSetName": {
"String": "utf8",
"String": "utf8mb3",
"Valid": true
},
"CollationName": {
"String": "utf8_general_ci",
"String": "utf8mb3_general_ci",
"Valid": true
},
"ColumnType": "text",
Expand Down Expand Up @@ -201,7 +201,7 @@
"String": "",
"Valid": false
},
"ColumnType": "year(4)",
"ColumnType": "year",
"ColumnKey": "",
"Extra": "",
"Privileges": "select,insert,update,references",
Expand Down Expand Up @@ -254,7 +254,7 @@
"String": "",
"Valid": false
},
"ColumnType": "tinyint(3) unsigned",
"ColumnType": "tinyint unsigned",
"ColumnKey": "MUL",
"Extra": "",
"Privileges": "select,insert,update,references",
Expand Down Expand Up @@ -313,7 +313,7 @@
"String": "",
"Valid": false
},
"ColumnType": "tinyint(3) unsigned",
"ColumnType": "tinyint unsigned",
"ColumnKey": "MUL",
"Extra": "",
"Privileges": "select,insert,update,references",
Expand Down Expand Up @@ -372,7 +372,7 @@
"String": "",
"Valid": false
},
"ColumnType": "tinyint(3) unsigned",
"ColumnType": "tinyint unsigned",
"ColumnKey": "",
"Extra": "",
"Privileges": "select,insert,update,references",
Expand Down Expand Up @@ -478,7 +478,7 @@
"String": "",
"Valid": false
},
"ColumnType": "smallint(5) unsigned",
"ColumnType": "smallint unsigned",
"ColumnKey": "",
"Extra": "",
"Privileges": "select,insert,update,references",
Expand Down Expand Up @@ -577,11 +577,11 @@
"Valid": false
},
"CharacterSetName": {
"String": "utf8",
"String": "utf8mb3",
"Valid": true
},
"CollationName": {
"String": "utf8_general_ci",
"String": "utf8mb3_general_ci",
"Valid": true
},
"ColumnType": "enum('G','PG','PG-13','R','NC-17')",
Expand Down Expand Up @@ -636,11 +636,11 @@
"Valid": false
},
"CharacterSetName": {
"String": "utf8",
"String": "utf8mb3",
"Valid": true
},
"CollationName": {
"String": "utf8_general_ci",
"String": "utf8mb3_general_ci",
"Valid": true
},
"ColumnType": "set('Trailers','Commentaries','Deleted Scenes','Behind the Scenes')",
Expand Down Expand Up @@ -703,7 +703,7 @@
},
"ColumnType": "timestamp",
"ColumnKey": "",
"Extra": "on update CURRENT_TIMESTAMP",
"Extra": "DEFAULT_GENERATED on update CURRENT_TIMESTAMP",
"Privileges": "select,insert,update,references",
"ColumnComment": "",
"GenerationExpression": "",
Expand Down Expand Up @@ -766,4 +766,4 @@
}
],
"Triggers": []
}
}