Skip to content

Commit

Permalink
Fix validation workflow (#40)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
- Workflow wasn't running on PRs because it had the wrong file name for
the workflow

## Description of the changes
- Fix the name
- Allow pushing to a local registry when running from PR
- Use image from local registry to verify protobuf builds in jaeger and
jaeger-idl repos

## How was this change tested?
- CI

---------

Signed-off-by: Yuri Shkuro <[email protected]>
  • Loading branch information
yurishkuro authored Jun 29, 2024
1 parent c0ecd91 commit 20742e7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
34 changes: 24 additions & 10 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:
branches: [main]
paths:
- .github/workflows/jaeger-dockerimage.yml
- .github/workflows/build-and-publish.yml
- Dockerfile
- protoc-wrapper
release:
Expand All @@ -19,19 +19,27 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: docker/setup-buildx-action@v3
with:
install: true
driver-opts: |
network=host
- name: Start local Docker registry
if: ${{ github.event_name == 'pull_request' }}
run: |
docker inspect registry > /dev/null || docker run --rm -d -p 5000:5000 --name registry registry:2
- name: Extract tags/labels from Git
id: docker_meta
uses: docker/metadata-action@v5
with:
images: jaegertracing/protobuf
# when running on pull request we want to push the image to local registry for further testing
images: |
jaegertracing/protobuf,enable=${{ github.event_name != 'pull_request' }}
localhost:5000/jaegertracing/protobuf,enable=${{ github.event_name == 'pull_request' }}
# The 'tags:' section defines how the Docker image will be tagged:
# - pushes to main branch will be published as 'latest'
# - pushes tagged with semver will be published as that version (without 'v')
Expand All @@ -41,6 +49,7 @@ jobs:
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=semver,pattern={{version}}
type=ref,event=tag
type=sha,enable=${{ github.event_name == 'pull_request' }}
- name: Login to DockerHub
if: github.event_name != 'pull_request'
Expand All @@ -50,11 +59,12 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and maybe push Docker image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
Expand All @@ -64,6 +74,10 @@ jobs:
# We do not check if the generated files would be different there,
# only that the build does not fail.

- name: Pull image for local testing
if: github.event_name == 'pull_request'
run: docker pull ${{ steps.docker_meta.outputs.tags }}

- name: Checkout Jaeger for validation
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
Expand All @@ -75,7 +89,7 @@ jobs:
- name: Build Proto in Jaeger
if: github.event_name == 'pull_request'
working-directory: jaeger
run: make proto JAEGER_DOCKER_PROTOBUF=protobuf
run: make proto DOCKER_PROTOBUF=${{ steps.docker_meta.outputs.tags }}

- name: Checkout jaeger-idl for validation
if: github.event_name == 'pull_request'
Expand All @@ -88,4 +102,4 @@ jobs:
- name: Build Proto in jaeger-idl
if: github.event_name == 'pull_request'
working-directory: jaeger-idl
run: make proto PROTOC_IMAGE=protobuf
run: make proto PROTOC_IMAGE=${{ steps.docker_meta.outputs.tags }}
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ ARG PROTOC_GEN_GOGO_VERSION=b03c65ea87cdc3521ede29f62fe3ce239267c1bc
ARG PROTOC_GEN_LINT_VERSION=0.2.1
ARG UPX_VERSION=3.96

FROM alpine:${ALPINE_VERSION} as protoc_base
FROM alpine:${ALPINE_VERSION} AS protoc_base
RUN apk add --no-cache build-base curl cmake autoconf libtool git zlib-dev linux-headers && \
mkdir -p /out

FROM protoc_base as protoc_builder
FROM protoc_base AS protoc_builder
ARG GRPC_VERSION
RUN apk add --no-cache automake ninja && \
git clone --recursive --depth=1 -b v${GRPC_VERSION} https://github.com/grpc/grpc.git /grpc && \
Expand Down Expand Up @@ -72,7 +72,7 @@ RUN git clone --recursive --depth=1 -b v${GRPC_CSHARP_VERSION} https://github.co
rm -Rf /grpc


FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} as go_builder
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS go_builder
RUN apk add --no-cache build-base curl git
ENV GOBIN=/out/usr/bin

Expand Down Expand Up @@ -114,7 +114,7 @@ RUN mkdir -p ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway && \
install -D $(find ./third_party/googleapis/google/rpc -name '*.proto') -t /out/usr/include/google/rpc


FROM alpine:${ALPINE_VERSION} as packer
FROM alpine:${ALPINE_VERSION} AS packer
RUN apk add --no-cache curl

ARG UPX_VERSION
Expand Down

0 comments on commit 20742e7

Please sign in to comment.