Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: migratemgr8/mgr8
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.1.5
Choose a base ref
...
head repository: migratemgr8/mgr8
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 6,918 additions and 221 deletions.
  1. +13 −0 .github/codecov.yml
  2. +17 −10 .github/workflows/pr.yml
  3. +92 −10 .github/workflows/release.yml
  4. +0 −71 .github/workflows/tag.yml
  5. +8 −1 .gitignore
  6. +47 −0 .goreleaser.yaml
  7. +23 −0 Dockerfile
  8. +69 −1 Makefile
  9. +111 −14 README.md
  10. +16 −0 applications/application_suite_test.go
  11. +41 −0 applications/check.go
  12. +46 −0 applications/check_test.go
  13. +197 −0 applications/config.go
  14. +32 −0 applications/empty.go
  15. +49 −0 applications/empty_test.go
  16. +71 −0 applications/generate.go
  17. +66 −0 applications/generate_test.go
  18. +30 −0 applications/hashing.go
  19. +48 −0 applications/hashing_test.go
  20. +31 −0 applications/init.go
  21. +74 −0 applications/init_test.go
  22. +51 −0 applications/migration_helpers.go
  23. +105 −0 applications/migration_helpers_test.go
  24. +78 −0 applications/migrationscripts.go
  25. +167 −0 applications/migrationscripts_test.go
  26. +240 −58 cmd/apply.go
  27. +111 −0 cmd/apply_test.go
  28. +32 −0 cmd/check.go
  29. +71 −0 cmd/command.go
  30. +89 −0 cmd/command_suite_test.go
  31. +39 −0 cmd/diff.go
  32. +33 −0 cmd/empty.go
  33. +0 −1 cmd/generate.go
  34. +29 −0 cmd/init.go
  35. +66 −9 cmd/root.go
  36. +68 −0 cmd/validate.go
  37. +9 −1 docker-compose.yml
  38. +92 −0 domain/column_diff.go
  39. +128 −0 domain/column_diff_test.go
  40. +6 −0 domain/constants.go
  41. +69 −0 domain/diff.go
  42. +31 −0 domain/diff_deque.go
  43. +100 −0 domain/diff_test.go
  44. +16 −0 domain/domain_suite_test.go
  45. +44 −0 domain/driver.go
  46. +22 −0 domain/schema.go
  47. +33 −0 domain/table_diff.go
  48. +76 −0 domain/table_diff_test.go
  49. +10 −15 drivers/drivers.go
  50. +80 −0 drivers/mysql/deparser.go
  51. +16 −0 drivers/mysql/mysql_suite_test.go
  52. +135 −0 drivers/mysql/mysql_test.go
  53. +304 −0 drivers/mysql/parser.go
  54. +115 −0 drivers/postgres/deparser.go
  55. +233 −25 drivers/postgres/parser.go
  56. +16 −0 drivers/postgres/postgres_suite_test.go
  57. +200 −0 drivers/postgres/postgres_test.go
  58. +6 −0 global/constants.go
  59. +35 −0 global/database.go
  60. +39 −0 global/database_test.go
  61. +84 −1 go.mod
  62. +1,229 −2 go.sum
  63. +17 −0 infrastructure/clock.go
  64. +84 −0 infrastructure/file.go
  65. +96 −0 infrastructure/logger.go
  66. +1 −1 main.go
  67. +1 −0 migrations/0001_test_migration.down.sql
  68. 0 migrations/{0001_test_migration.sql → 0001_test_migration.up.sql}
  69. +2 −0 migrations/0002_test_migration.down.sql
  70. +0 −1 migrations/0002_test_migration.sql
  71. +4 −0 migrations/0002_test_migration.up.sql
  72. +1 −0 migrations/0003_test_migration.down.sql
  73. +1 −0 migrations/0003_test_migration.up.sql
  74. +82 −0 mock/applications/log_mock.go
  75. +116 −0 mock/applications/migrationscripts_mock.go
  76. +428 −0 mock/domain/driver_mock.go
  77. +49 −0 mock/infrastructure/clock_mock.go
  78. +93 −0 mock/infrastructure/file_mock.go
  79. +8 −0 testing/databaseconfig.go
  80. +42 −0 testing/databaseconfigs/mysql.go
  81. +45 −0 testing/databaseconfigs/postgres.go
  82. +88 −0 testing/dockermanager.go
  83. +63 −0 testing/dockermanager_test.go
  84. +41 −0 testing/fixtures/fixtures.go
  85. +112 −0 testing/fixtures/migrations_fixture.go
  86. 0 testing/testdata/0000_schema.sql
  87. +12 −0 testing/testdata/0001_schema.sql
  88. +6 −0 testing/testdata/0002_schema.sql
  89. +1 −0 testing/testdata/output/0001_1656197671.down.sql
  90. +6 −0 testing/testdata/output/0001_1656197671.up.sql
  91. +6 −0 testing/testdata/output/0002_1656197676.down.sql
  92. +9 −0 testing/testdata/output/0002_1656197676.up.sql
  93. +116 −0 testing/testdriver.go
13 changes: 13 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
coverage:
status:
patch: off
project:
default:
target: auto # auto will use the coverage from the base commit (pull request base or parent commit) coverage to compare against.
threshold: 0%
comment: # this is a top-level key
layout: "reach, diff, flags, files"
behavior: default
require_changes: false # if true: only post the comment if coverage changes
require_base: no # [yes :: must have a base report to post]
require_head: yes # [yes :: must have a head report to post]
27 changes: 17 additions & 10 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
name: pr
name: Pull Request Tests

on: [pull_request]
on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
build-and-test:
build:
runs-on: ubuntu-latest
name: Build & Test

steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: '1.17.6'

- name: Build
run: go build -v ./...
run: make build

- name: Test
run: go test -v ./...
- name: Run tests
run: make check
- name: Upload coverage reports to Codecov with GitHub Action
run: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov -t ${CODECOV_TOKEN} -f coverage.txt -F unit
./codecov -t ${CODECOV_TOKEN} -f integration_coverage.txt -F integration
102 changes: 92 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,70 @@
name: release
name: Release

on:
push:
tags:
- v*
branches:
- master

jobs:
build-and-test:
runs-on: ubuntu-latest
name: Build & Test

steps:
- uses: actions/checkout@v2
with:
go-version: '1.17.6'

- name: Build
run: make build

- name: Run tests
run: make check

- name: Upload coverage reports to Codecov with GitHub Action
run: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov -t ${CODECOV_TOKEN} -f coverage.txt -F unit
./codecov -t ${CODECOV_TOKEN} -f integration_coverage.txt -F integration
tag:
runs-on: ubuntu-latest
needs: build-and-test
name: Generate & Push Tag

outputs:
tag: ${{ steps.tag_generator.outputs.version_tag }}

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Generate tag
id: tag_generator
uses: paulhatch/semantic-version@v4.0.2
with:
tag_prefix: 'v'
major_pattern: '(MAJOR)'
minor_pattern: '(MINOR)'
format: '${major}.${minor}.${patch}'
short_tags: false
bump_each_commit: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Push tag to github
run: |
git tag ${{ steps.tag_generator.outputs.version_tag }}
git push origin --tags
release:
runs-on: ubuntu-latest
needs: tag
name: Release

steps:
- name: Checkout
uses: actions/checkout@v2
@@ -19,11 +76,36 @@ jobs:
with:
go-version: '^1.17.6'

- name: Set up release environment
run: |-
echo 'GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}' >> .release-env
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make release

deploy-docker:
runs-on: ubuntu-latest
needs: tag
name: Deploy to DockerHub

env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_TAG_LATEST_RELEASE: '${{ secrets.DOCKER_USER }}/mgr8:latest'
DOCKER_TAG_RELEASE: '${{ secrets.DOCKER_USER }}/mgr8:${{ needs.tag.outputs.tag }}'

steps:
- uses: actions/checkout@v2

- name: Docker login
run: |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- name: Build Docker image
run: |
docker build . --file Dockerfile --tag $DOCKER_TAG_LATEST_RELEASE --tag $DOCKER_TAG_RELEASE
- name: Push to DockerHub
run: |
docker push $DOCKER_TAG_RELEASE
docker push $DOCKER_TAG_LATEST_RELEASE
71 changes: 0 additions & 71 deletions .github/workflows/tag.yml

This file was deleted.

9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
bin/
.idea
.vscode
.vscode
coverage.txt
integration_coverage.txt

dist
.release-env
unit_coverage.out
.mgr8
47 changes: 47 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
builds:
- id: darwin-amd64
main: ./
binary: golang-cross
goos:
- darwin
goarch:
- amd64
env:
- PKG_CONFIG_SYSROOT_DIR=/sysroot/macos/amd64
- PKG_CONFIG_PATH=/sysroot/macos/amd64/usr/local/lib/pkgconfig
- CC=o64-clang
- CXX=o64-clang++
flags:
- -mod=readonly
ldflags:
- -s -w -X main.version={{.Version}}
- id: darwin-arm64
main: ./
binary: golang-cross
goos:
- darwin
goarch:
- arm64
env:
- CC=oa64-clang
- CXX=oa64-clang++
- id: linux-amd64
main: ./
binary: golang-cross
goos:
- linux
goarch:
- amd64
env:
- CC=gcc
- CXX=g++
- id: linux-arm64
main: ./
binary: golang-cross
goos:
- linux
goarch:
- arm64
env:
- CC=aarch64-linux-gnu-gcc
- CXX=aarch64-linux-gnu-g++
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM golang:1.17-alpine3.15 AS builder

RUN apk add --no-cache git gcc musl-dev make

WORKDIR /go/src/github.com/migratemgr8/mgr8

ENV GO111MODULE=on

COPY go.mod go.sum ./

RUN go mod download

COPY . ./

RUN make build

FROM alpine:3.15

COPY --from=builder /go/src/github.com/migratemgr8/mgr8/bin/mgr8 /usr/local/bin/mgr8
RUN ln -s /usr/local/bin/mgr8 /mgr8

ENTRYPOINT ["mgr8"]
CMD ["--help"]
Loading