Skip to content

Commit

Permalink
Refactor cross for GitHub Actions
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Nov 23, 2020
1 parent cdef71b commit 6b32ab4
Show file tree
Hide file tree
Showing 9 changed files with 328 additions and 191 deletions.
251 changes: 251 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
name: build

on:
workflow_dispatch:
push:
branches:
- 'master'
tags:
- 'v*'
- 'dockerfile/*'
pull_request:
branches:
- 'master'

env:
REPO_SLUG_ORIGIN: "moby/buildkit:latest"
PLATFORMS: "linux/amd64,linux/arm/v7,linux/arm64,linux/s390x,linux/ppc64le"
CACHEKEY_INTEGRATION_TESTS: "integration-tests"
CACHEKEY_BINARIES: "binaries"

jobs:
base:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Cache ${{ env.CACHEKEY_INTEGRATION_TESTS }}
uses: actions/cache@v2
with:
path: /tmp/.buildkit-cache/${{ env.CACHEKEY_INTEGRATION_TESTS }}
key: ${{ runner.os }}-buildkit-${{ env.CACHEKEY_INTEGRATION_TESTS }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildkit-${{ env.CACHEKEY_INTEGRATION_TESTS }}-
-
name: Cache ${{ env.CACHEKEY_BINARIES }}
uses: actions/cache@v2
with:
path: /tmp/.buildkit-cache/${{ env.CACHEKEY_BINARIES }}
key: ${{ runner.os }}-buildkit-${{ env.CACHEKEY_BINARIES }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildkit-${{ env.CACHEKEY_BINARIES }}-
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: image=${{ env.REPO_SLUG_ORIGIN }}
-
name: Build ${{ env.CACHEKEY_BINARIES }}
run: |
./hack/build_ci_first_pass binaries
env:
CACHE_DIR: /tmp/.buildkit-cache/${{ env.CACHEKEY_BINARIES }}
-
name: Build ${{ env.CACHEKEY_INTEGRATION_TESTS }}
run: |
./hack/build_ci_first_pass integration-tests
env:
CACHE_DIR: /tmp/.buildkit-cache/${{ env.CACHEKEY_INTEGRATION_TESTS }}
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v1

test:
runs-on: ubuntu-latest
needs: [base]
strategy:
fail-fast: false
matrix:
include:
-
pkg: ./client
typ: integration
-
pkg: ./cmd/buildctl ./worker/containerd
typ: integration
-
pkg: ''
skip-integration-tests: 1
typ: integration gateway
-
pkg: ./frontend
typ: ''
-
pkg: ./frontend/dockerfile
typ: ''
-
pkg: ./frontend/dockerfile
typ: dockerfile
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Cache ${{ env.CACHEKEY_INTEGRATION_TESTS }}
uses: actions/cache@v2
with:
path: /tmp/.buildkit-cache/${{ env.CACHEKEY_INTEGRATION_TESTS }}
key: ${{ runner.os }}-buildkit-${{ env.CACHEKEY_INTEGRATION_TESTS }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildkit-${{ env.CACHEKEY_INTEGRATION_TESTS }}-
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: image=${{ env.REPO_SLUG_ORIGIN }}
-
name: Test ${{ matrix.pkg }} ${{ matrix.typ }}
run: |
./hack/test ${{ matrix.typ }}
env:
TEST_COVERAGE: 1
TESTPKGS: ${{ matrix.pkg }}
TESTFLAGS: -v --parallel=6 --timeout=20m
SKIP_INTEGRATION_TESTS: ${{ matrix.skip-integration-tests }}
CACHE_DIR: /tmp/.buildkit-cache/${{ env.CACHEKEY_INTEGRATION_TESTS }}
-
name: Upload coverage
uses: codecov/codecov-action@v1
with:
file: ./coverage/coverage.txt
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v1

test-os:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
# - ubuntu-latest
# - macOS-latest
- windows-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.13
-
name: Cache Go modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
-
name: Go mod
run: |
go mod download
-
name: Test
env:
TMPDIR: ${{ runner.temp }}
SKIP_INTEGRATION_TESTS: 1
run: |
go test -coverprofile=coverage.txt -covermode=atomic ./...
shell: bash
-
name: Upload coverage
uses: codecov/codecov-action@v1
with:
file: coverage.txt
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v1

cross:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Cache cross
uses: actions/cache@v2
with:
path: /tmp/.buildkit-cache/cross
key: ${{ runner.os }}-buildkit-cross-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildkit-cross-
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: image=${{ env.REPO_SLUG_ORIGIN }}
-
name: Cross
run: |
./hack/cross
env:
PLATFORMS: ${{ env.PLATFORMS }},darwin/amd64,windows/amd64
RUNC_PLATFORMS: ${{ env.PLATFORMS }}
CACHE_DIR: /tmp/.buildkit-cache/cross
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v1

buildkit-buildkitd:
runs-on: ubuntu-latest
needs: [base]
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Cache ${{ env.CACHEKEY_BINARIES }}
uses: actions/cache@v2
with:
path: /tmp/.buildkit-cache/${{ env.CACHEKEY_BINARIES }}
key: ${{ runner.os }}-buildkit-${{ env.CACHEKEY_BINARIES }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildkit-${{ env.CACHEKEY_BINARIES }}-
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: image=${{ env.REPO_SLUG_ORIGIN }}
-
name: Build
run: |
./hack/buildkit-buildkitd
env:
PLATFORMS: windows/amd64
CACHE_DIR: /tmp/.buildkit-cache/${{ env.CACHEKEY_BINARIES }}
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v1
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: release

on:
workflow_dispatch:
workflow_run:
workflows:
- 'build'
branches:
- 'master'
types:
- 'completed'

env:
REPO_SLUG_ORIGIN: "moby/buildkit:latest"
PLATFORMS: "linux/amd64,linux/arm/v7,linux/arm64,linux/s390x,linux/ppc64le"

jobs:
image:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v1
Loading

0 comments on commit 6b32ab4

Please sign in to comment.