Skip to content

Commit

Permalink
Merge remote-tracking branch 'main/main' into filter-migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Weber committed Feb 22, 2024
2 parents 82cc90b + 9e0564d commit 0e66606
Show file tree
Hide file tree
Showing 52 changed files with 11,079 additions and 2,092 deletions.
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
version: 2
updates:
- package-ecosystem: docker
directory: /
schedule:
interval: weekly

- package-ecosystem: github-actions
directory: /
schedule:
Expand Down
58 changes: 38 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CI
on:
push:
branches: [main]
tags: "*"
tags: ["*"]
pull_request:

jobs:
Expand All @@ -26,11 +26,11 @@ jobs:
- os: linux
image: ubuntu-latest
arch: arm
setup: sudo apt-get update && sudo apt-get install -qq gcc-arm-linux-gnueabihf
setup: sudo apt-get update && sudo apt-get install -qq gcc-arm-linux-gnueabi
env:
CC: arm-linux-gnueabihf-gcc
CXX: arm-linux-gnueabihf-g++
GOARM: 7
CC: arm-linux-gnueabi-gcc
CXX: arm-linux-gnueabi-g++
GOARM: 6
- os: linux
image: ubuntu-latest
arch: arm64
Expand All @@ -56,11 +56,11 @@ jobs:
env: ${{ matrix.env }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version-file: go.mod

- name: Setup environment
run: ${{ matrix.setup }}
Expand All @@ -76,7 +76,7 @@ jobs:
if: ${{ matrix.arch == 'amd64' }}

- name: Upload build artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dbmate-${{ matrix.os }}-${{ matrix.arch }}
path: dist/dbmate-*
Expand All @@ -94,13 +94,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Configure QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Configure Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Check Docker environment
run: |
Expand All @@ -124,22 +124,22 @@ jobs:
- name: Start test dependencies
run: |
set -x
docker-compose pull --quiet
docker-compose pull --ignore-buildable --quiet
docker-compose up --detach
docker-compose run --rm dev make wait
- name: Run make test
run: docker-compose run --rm dev make test

- name: Login to Docker Hub
uses: docker/login-action@v2
uses: docker/login-action@v3
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
with:
registry: ghcr.io
Expand All @@ -148,7 +148,7 @@ jobs:

- name: Generate Docker image tags
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
with:
images: |
Expand All @@ -161,7 +161,7 @@ jobs:
type=semver,pattern={{major}}
- name: Publish Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
with:
context: .
Expand All @@ -177,16 +177,16 @@ jobs:
needs: build

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 16
registry-url: https://registry.npmjs.org
cache: npm
cache-dependency-path: typescript/package-lock.json

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
path: dist

Expand All @@ -206,3 +206,21 @@ jobs:
working-directory: typescript
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

dependabot:
name: Dependabot
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: github.event.pull_request.user.login == 'dependabot[bot]'
steps:
- name: Automatically approve dependabot PRs
uses: octokit/request-action@v2.x
with:
route: POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews
owner: ${{ github.event.repository.owner.login }}
repo: ${{ github.event.repository.name }}
pull_number: ${{ github.event.pull_request.number }}
event: APPROVE
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: Release

on:
push:
tags: "v*"
tags: ["v*"]

jobs:
homebrew:
name: Bump Homebrew formula
runs-on: ubuntu-latest
steps:
- uses: mislav/bump-homebrew-formula-action@v2
- uses: mislav/bump-homebrew-formula-action@v3
with:
formula-name: dbmate
env:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
.DS_Store
.env
.idea
*.log
/.cache
/db
/dbmate
/testdata/db/schema.sql
/vendor
dist
docker-compose.override.yml
node_modules

# Devenv
Expand Down
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
linters:
enable:
- bodyclose
- depguard
- errcheck
- goimports
- gosimple
Expand Down
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// -*- jsonc -*-
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.detectIndentation": false,
Expand All @@ -15,7 +15,7 @@
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"prettier.prettierPath": "./typescript/node_modules/prettier",
"prettier.prettierPath": "./typescript/node_modules/prettier/index.cjs",
"go.formatTool": "goimports",
"[go]": {
"editor.defaultFormatter": "golang.go",
Expand Down
35 changes: 19 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
# development image
FROM golang:1.20 as dev
FROM golang:1.22.0 as dev
WORKDIR /src
ENV PATH="/src/typescript/node_modules/.bin:${PATH}"
RUN git config --global --add safe.directory /src

# install database clients
# install development tools
RUN apt-get update \
&& apt-get install -qq --no-install-recommends \
curl \
file \
mariadb-client \
postgresql-client \
sqlite3 \
&& rm -rf /var/lib/apt/lists/*
&& apt-get install -qq --no-install-recommends \
curl \
file \
mariadb-client \
postgresql-client \
sqlite3 \
nodejs \
npm \
&& rm -rf /var/lib/apt/lists/*

# golangci-lint
RUN curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
| sh -s -- -b /usr/local/bin v1.51.2
| sh -s -- -b /usr/local/bin v1.55.2

# download modules
COPY go.* /src/
Expand All @@ -24,12 +27,12 @@ COPY . /src/
RUN make build

# release stage
FROM alpine as release
FROM alpine:3.19.1 as release
RUN apk add --no-cache \
mariadb-client \
mariadb-connector-c \
postgresql-client \
sqlite \
tzdata
mariadb-client \
mariadb-connector-c \
postgresql-client \
sqlite \
tzdata
COPY --from=dev /src/dist/dbmate /usr/local/bin/dbmate
ENTRYPOINT ["/usr/local/bin/dbmate"]
19 changes: 13 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# enable cgo to build sqlite
export CGO_ENABLED = 1

# strip binaries
FLAGS := -tags sqlite_omit_load_extension,sqlite_json -ldflags '-s'

# default output file
OUTPUT ?= dbmate

# platform-specific settings
GOOS := $(shell go env GOOS)
ifeq ($(GOOS),linux)
# statically link binaries to support alpine linux
FLAGS := -tags netgo,osusergo,sqlite_omit_load_extension,sqlite_json -ldflags '-s -extldflags "-static"'
override FLAGS := -tags netgo,osusergo,sqlite_omit_load_extension,sqlite_json -ldflags '-s -extldflags "-static"' $(FLAGS)
else
# strip binaries
override FLAGS := -tags sqlite_omit_load_extension,sqlite_json -ldflags '-s' $(FLAGS)
endif
ifeq ($(GOOS),darwin)
export SDKROOT ?= $(shell xcrun --sdk macosx --show-sdk-path)
Expand Down Expand Up @@ -44,7 +44,7 @@ test:

.PHONY: lint
lint:
golangci-lint run --timeout 2m
golangci-lint run --timeout 5m

.PHONY: fix
fix:
Expand All @@ -56,9 +56,16 @@ wait:
dist/dbmate -e MYSQL_TEST_URL wait
dist/dbmate -e POSTGRES_TEST_URL wait

.PHONY: update-deps
update-deps:
go get -u ./...
go mod tidy
go mod verify
cd typescript && ./node_modules/.bin/npm-check-updates --upgrade && npm install

.PHONY: docker-all
docker-all:
docker-compose pull
docker-compose pull --ignore-buildable
docker-compose build
docker-compose run --rm dev make all

Expand Down
Loading

0 comments on commit 0e66606

Please sign in to comment.