forked from mailgun/kafka-pixy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'mailgun:master' into master
- Loading branch information
Showing
17 changed files
with
600 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# syntax=docker/dockerfile:1.3 | ||
|
||
# This is a buildx compatible Dockerfile. Documentation can be found | ||
# https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/syntax.md | ||
|
||
# This Dockerfile uses a base golang image with our pinned golang version | ||
# See https://github.com/mailgun/dockerworld/images for current pinned version | ||
|
||
# This creates an cached layer of our dependencies for subsequent builds to use | ||
FROM golang:1.18.3 AS deps | ||
WORKDIR /go/src | ||
RUN --mount=type=bind,target=/go/src,rw go mod download | ||
|
||
# ========================================================================== | ||
# NOTE: Since tests are run in travis, we just build the container image | ||
# ========================================================================== | ||
# Run tests | ||
#FROM deps as test | ||
#RUN --mount=type=bind,target=/go/src,rw \ | ||
#go fmt ./... && \ | ||
#go vet ./... && \ | ||
#go test -v -p 1 -race -parallel=1 -tags holster_test_mode ./... | ||
|
||
# Build cmds | ||
FROM deps as build | ||
RUN --mount=type=bind,target=/go/src,rw \ | ||
go version && \ | ||
CGO_ENABLED=0 go install -a -v ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
|
||
set -ex | ||
|
||
# wait for kafka server to load | ||
sleep 5 | ||
docker exec -e JMX_PORT=5557 -i kafka-pixy_kafka_1 bin/kafka-topics.sh --create --zookeeper=zookeeper:2181 --topic test.1 --partitions 1 --replication-factor 1 | ||
docker exec -e JMX_PORT=5557 -i kafka-pixy_kafka_1 bin/kafka-topics.sh --create --zookeeper=zookeeper:2181 --topic test.4 --partitions 4 --replication-factor 1 | ||
docker exec -e JMX_PORT=5557 -i kafka-pixy_kafka_1 bin/kafka-topics.sh --create --zookeeper=zookeeper:2181 --topic test.64 --partitions 64 --replication-factor 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# ============================================================== | ||
# NOTE: This workflow only builds a deployable container, | ||
# See travis config for running tests. | ||
# ============================================================== | ||
|
||
name: Build Deployable Container | ||
|
||
on: | ||
pull_request: | ||
branches: [ master, main ] | ||
|
||
jobs: | ||
build-and-publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repo | ||
uses: actions/checkout@v3 | ||
# Create a build container which buildx will use as a driver when building the container. | ||
# See https://github.com/docker/buildx/blob/master/docs/reference/buildx_create.md#driver | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
# Enables host networking which allows tests run by buildx to access | ||
# the containers started by docker compose on localhost | ||
driver-opts: network=host | ||
# Login to the registry | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.PKG_WRITER_PAT }} | ||
# This creates a cache for the current PR, if none exists then | ||
# the cache from the most recent PR will be used. | ||
- name: Setup Docker layer Cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-docker-${{ github.event.number }} | ||
restore-keys: ${{ runner.os }}-docker- | ||
# Automagically extract useful information from the current github context and creates | ||
# a set of labels for use by build-push-action to be attached to the final image. | ||
- name: Extract Metadata for Docker | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ github.repository }} | ||
id: meta | ||
# This action runs Buildx, which allows for a more complex Dockerfile. | ||
# We use a buildx Dockerfile to run tests as well as build the final image. | ||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
# We change the path context here since the github context does not include | ||
# changes to local files, like when we download `Dockerfile`. | ||
# See https://github.com/docker/build-push-action#git-context | ||
context: . | ||
file: .github/Dockerfile | ||
tags: ghcr.io/${{ github.repository }}:PR${{ github.event.number }} | ||
# We use local cache type, so we can clean up the cache | ||
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#local-cache | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new | ||
labels: ${{ steps.meta.outputs.labels }} | ||
push: true | ||
# This is to avoid the cache sizes from continually growing as new image layers | ||
# are created. See the following issues: | ||
# https://github.com/docker/build-push-action/issues/252 | ||
# https://github.com/moby/buildkit/issues/1896 | ||
- name: Retire old cache | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Run tests | ||
|
||
on: | ||
pull_request: | ||
branches: [ master, main ] | ||
push: | ||
branches: [ master, main ] | ||
|
||
env: | ||
KAFKA_PEERS: 127.0.0.1:9092 | ||
ZOOKEEPER_PEERS: 127.0.0.1:2181 | ||
KAFKA_HOSTNAME: 127.0.0.1 | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@master | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.PKG_WRITER_PAT }} | ||
|
||
- name: Cache deps | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Install deps | ||
run: go mod download | ||
|
||
- name: Add hosts to /etc/hosts | ||
run: | | ||
sudo echo "127.0.0.1 kafka" | sudo tee -a /etc/hosts | ||
sudo echo "127.0.0.1 zookeeper" | sudo tee -a /etc/hosts | ||
- name: Start containers | ||
run: docker-compose up -d | ||
|
||
- name: Create test topics | ||
run: .github/create_topics.sh | ||
|
||
- name: Run tests | ||
run: make test | ||
|
||
- name: Stop containers | ||
if: always() | ||
run: docker-compose down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
language: go | ||
go: | ||
- 1.12 | ||
- 1.18.3 | ||
|
||
env: | ||
global: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.