Skip to content

Commit

Permalink
Merge pull request #837 from crazy-max/update-workflows
Browse files Browse the repository at this point in the history
ci: split validate and test workflow
  • Loading branch information
CrazyMax authored and GitHub committed Apr 11, 2023
2 parents f2a1d5e + a3646c0 commit 817ed59
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 238 deletions.
68 changes: 66 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ on:
description: 'BuildKit image'
default: 'moby/buildkit:buildx-stable-1'
required: false
schedule:
- cron: '0 10 * * *'
push:
branches:
- 'master'
- 'releases/v*'
pull_request:
branches:
- 'master'

env:
BUILDX_VERSION: latest
Expand Down Expand Up @@ -199,6 +200,69 @@ jobs:
exit 1
fi
example:
runs-on: ubuntu-latest
env:
DOCKER_IMAGE: localhost:5000/name/app
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKER_IMAGE }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
driver-opts: |
network=host
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
-
name: Build and export to Docker client
uses: ./
with:
context: ./test
file: ./test/Dockerfile
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
-
name: Build and push to local registry
uses: ./
with:
context: ./test
file: ./test/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
-
name: Inspect image
run: |
docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}
-
name: Check manifest
if: github.event_name != 'pull_request'
run: |
docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} --format '{{json .}}'
error:
runs-on: ubuntu-latest
steps:
Expand Down
74 changes: 0 additions & 74 deletions .github/workflows/example.yml

This file was deleted.

8 changes: 1 addition & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ on:
push:
branches:
- 'master'
- 'releases/v*'
pull_request:
branches:
- 'master'

jobs:
test:
Expand All @@ -15,11 +14,6 @@ jobs:
-
name: Checkout
uses: actions/checkout@v3
-
name: Validate
uses: docker/bake-action@v2
with:
targets: validate
-
name: Test
uses: docker/bake-action@v2
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: validate

on:
push:
branches:
- 'master'
- 'releases/v*'
pull_request:

jobs:
prepare:
runs-on: ubuntu-latest
outputs:
targets: ${{ steps.targets.outputs.matrix }}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Targets matrix
id: targets
run: |
echo "matrix=$(docker buildx bake validate --print | jq -cr '.group.validate.targets')" >> $GITHUB_OUTPUT
validate:
runs-on: ubuntu-latest
needs:
- prepare
strategy:
fail-fast: false
matrix:
target: ${{ fromJson(needs.prepare.outputs.targets) }}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Validate
uses: docker/bake-action@v2
with:
targets: ${{ matrix.target }}
72 changes: 0 additions & 72 deletions .github/workflows/virtual-env.yml

This file was deleted.

17 changes: 10 additions & 7 deletions test/go/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
FROM golang:1.19-alpine AS base
# syntax=docker/dockerfile:1

FROM golang:alpine AS base
ENV CGO_ENABLED=0
RUN apk add --no-cache file git
WORKDIR /src

FROM base as build
COPY go.mod go.sum ./
RUN go mod download -x
COPY . .
RUN go build -ldflags "-s -w" -o /usr/bin/app .
FROM base AS build
RUN --mount=type=bind,target=/src \
--mount=type=cache,target=/root/.cache/go-build \
go build -ldflags "-s -w" -o /usr/bin/app .

FROM scratch AS binary
COPY --from=build /usr/bin/app /bin/app

FROM alpine:3.17 AS image
FROM alpine AS image
COPY --from=build /usr/bin/app /bin/app
EXPOSE 8080
ENTRYPOINT ["/bin/app"]
16 changes: 0 additions & 16 deletions test/go/go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
module github.com/docker/build-push-action/test/go

go 1.18

require github.com/labstack/echo/v4 v4.9.1

require (
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/labstack/gommon v0.4.0 // indirect
github.com/mattn/go-colorable v0.1.11 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.1 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f // indirect
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect
)
38 changes: 0 additions & 38 deletions test/go/go.sum

This file was deleted.

Loading

0 comments on commit 817ed59

Please sign in to comment.