Build using native OS workers (#231)

This commit is contained in:
Adrian Macneil 2021-12-19 21:08:22 -08:00 committed by GitHub
parent 06d8bb7567
commit f69f1dea03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 123 additions and 96 deletions

View file

@ -3,44 +3,94 @@ name: CI
on:
push:
branches: [main]
tags: "v*"
tags: "*"
pull_request:
branches: [main]
jobs:
build:
name: Build
strategy:
fail-fast: false
matrix:
include:
- os: linux
image: ubuntu-latest
arch: amd64
env: {}
- os: linux
image: ubuntu-latest
arch: arm64
setup: sudo apt-get update && sudo apt-get install -qq gcc-aarch64-linux-gnu
env:
CC: aarch64-linux-gnu-gcc
CXX: aarch64-linux-gnu-g++
- os: macos
image: macos-latest
arch: amd64
env: {}
- os: macos
image: macos-latest
arch: arm64
env: {}
- os: windows
image: windows-latest
arch: amd64
env: {}
name: Build (${{ matrix.os }}/${{ matrix.arch }})
runs-on: ${{ matrix.image }}
env: ${{ matrix.env }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.17"
- name: Setup environment
run: ${{ matrix.setup }}
- run: go mod download
- run: make build ls
env:
GOARCH: ${{ matrix.arch }}
OUTPUT: dbmate-${{ matrix.os }}-${{ matrix.arch }}
- run: dist/dbmate-${{ matrix.os }}-${{ matrix.arch }} --help
if: ${{ matrix.arch == 'amd64' }}
- name: Publish binaries
uses: softprops/action-gh-release@v1
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
with:
files: dist/dbmate-*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker:
name: Docker Test (linux/amd64)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v2
- name: Environment
- name: Check docker environment
run: |
set -x
docker version
docker-compose version
- name: Cache
uses: actions/cache@v2
with:
key: cache
path: .cache
- name: Build docker image
run: |
set -x
docker-compose build
docker-compose run --rm --no-deps dbmate --version
- name: Build binaries
run: |
set -x
docker-compose run --rm --no-deps dev make build-all
dist/dbmate-linux-amd64 --version
- name: Run make build
run: docker-compose run --rm --no-deps dev make build ls
- name: Lint
- name: Run make lint
run: docker-compose run --rm --no-deps dev make lint
- name: Start test dependencies
@ -48,12 +98,10 @@ jobs:
set -x
docker-compose pull --quiet
docker-compose up --detach
- name: Run tests
run: |
set -x
docker-compose run --rm dev make wait
docker-compose run --rm dev make test
- name: Run make test
run: docker-compose run --rm dev make test
- name: Publish docker image
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
@ -65,12 +113,4 @@ jobs:
GHCR_IMAGE: ghcr.io/${{ github.repository }}
GHCR_USERNAME: ${{ github.actor }}
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: .github/workflows/publish-docker.sh
- name: Publish release binaries
uses: softprops/action-gh-release@v1
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
with:
files: dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ci/publish-docker.sh