You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by mm...@apache.org on 2022/08/24 05:35:41 UTC
[pulsar-client-go] branch master updated: ci: add makefile (#800)
This is an automated email from the ASF dual-hosted git repository.
mmarshall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-go.git
The following commit(s) were added to refs/heads/master by this push:
new 2d5f6fc ci: add makefile (#800)
2d5f6fc is described below
commit 2d5f6fcfa22af4184793a22ca353731a02b54ca9
Author: Paul Gier <pa...@datastax.com>
AuthorDate: Wed Aug 24 00:35:37 2022 -0500
ci: add makefile (#800)
* ci: add makefile
- add a Makefile with basic build, test, clean, etc.
- simplify the Dockerfile by moving some scripts and conf files to directories
- update README
- allow easy setting of GOLANG version and PULSAR version for testing
Signed-off-by: Paul Gier <pa...@datastax.com>
* dockerfile: copy individual conf files
Copy individual config files instead of directory when building the Dockerfile to catch any missing/incorrect files.
Signed-off-by: Paul Gier <pa...@datastax.com>
* update apache pulsar link in readme
Signed-off-by: Paul Gier <pa...@datastax.com>
Signed-off-by: Paul Gier <pa...@datastax.com>
Makefiles are commonly used for building golang projects.
- add a Makefile with basic build, test, clean, etc.
- simplify the Dockerfile by moving some scripts and conf files to directories
- update README
- Allows easy overriding of pulsar version and golang version used during testing
### Motivation
Add a Makefile to make it easier to remember the commands for building and testing the project. For example:
* `make build` instead of `go build ./pulsar`
* `make test` instead of `./docker-ci.sh`
* `make lint` instead of `golangci-lint run`
---
.github/workflows/project.yml | 5 ++--
Dockerfile | 23 +++++++++-------
docker-ci.sh => Makefile | 31 ++++++++++++++--------
README.md | 18 ++++++++-----
integration-tests/{ => conf}/.htpasswd | 0
integration-tests/{ => conf}/client.conf | 0
integration-tests/{ => conf}/standalone.conf | 0
.../pulsar-test-service-start.sh | 0
.../pulsar-test-service-stop.sh | 0
run-ci.sh => scripts/run-ci.sh | 6 ++---
10 files changed, 49 insertions(+), 34 deletions(-)
diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml
index cd3d373..dc5a755 100644
--- a/.github/workflows/project.yml
+++ b/.github/workflows/project.yml
@@ -7,7 +7,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- name: build
- run: go build ./pulsar
+ run: make build
lint:
runs-on: ubuntu-latest
@@ -34,5 +34,4 @@ jobs:
uses: actions/checkout@v3
- name: Run Tests
- run: |
- ./docker-ci.sh ${{ matrix.go-version }}
+ run: make test GO_VERSION=${{ matrix.go-version }}
diff --git a/Dockerfile b/Dockerfile
index 6dd5817..dcc6a26 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -17,21 +17,24 @@
# under the License.
#
-ARG GO_VERSION=golang:1.15
-FROM apachepulsar/pulsar:2.8.2 as pulsar
-FROM $GO_VERSION as go
+# Explicit version of Pulsar and Golang images should be
+# set via the Makefile or CLI
+ARG PULSAR_IMAGE=apachepulsar/pulsar:latest
+ARG GOLANG_IMAGE=golang:latest
+
+FROM $PULSAR_IMAGE as pulsar
+FROM $GOLANG_IMAGE
RUN apt-get update && apt-get install -y openjdk-11-jre-headless ca-certificates
COPY --from=pulsar /pulsar /pulsar
-### Add test scripts
+### Add pulsar config
COPY integration-tests/certs /pulsar/certs
COPY integration-tests/tokens /pulsar/tokens
-COPY integration-tests/standalone.conf /pulsar/conf
-COPY integration-tests/client.conf /pulsar/conf
-COPY integration-tests/.htpasswd /pulsar/conf
+COPY integration-tests/conf/.htpasswd \
+ integration-tests/conf/client.conf \
+ integration-tests/conf/standalone.conf \
+ /pulsar/conf/
+
ENV PULSAR_EXTRA_OPTS="-Dpulsar.auth.basic.conf=/pulsar/conf/.htpasswd"
-COPY pulsar-test-service-start.sh /pulsar/bin
-COPY pulsar-test-service-stop.sh /pulsar/bin
-COPY run-ci.sh /pulsar/bin
diff --git a/docker-ci.sh b/Makefile
old mode 100755
new mode 100644
similarity index 57%
rename from docker-ci.sh
rename to Makefile
index 37f97e7..130057e
--- a/docker-ci.sh
+++ b/Makefile
@@ -1,4 +1,3 @@
-#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -18,17 +17,27 @@
# under the License.
#
-set -e -x
+IMAGE_NAME = pulsar-client-go-test:latest
+PULSAR_VERSION ?= 2.8.3
+PULSAR_IMAGE = apachepulsar/pulsar:$(PULSAR_VERSION)
+GO_VERSION ?= 1.18
+GOLANG_IMAGE = golang:$(GO_VERSION)
-SRC_DIR=$(git rev-parse --show-toplevel)
-cd ${SRC_DIR}
+build:
+ go build ./pulsar
+ go build -o bin/pulsar-perf ./perf
-IMAGE_NAME=pulsar-client-go-test:latest
+lint:
+ golangci-lint run
-GO_VERSION=${1:-1.16}
-docker rmi --force ${IMAGE_NAME} || true
-docker rmi --force apachepulsar/pulsar:latest || true
-docker build -t ${IMAGE_NAME} --build-arg GO_VERSION="golang:${GO_VERSION}" .
+container:
+ docker build -t ${IMAGE_NAME} --build-arg GOLANG_IMAGE="${GOLANG_IMAGE}" \
+ --build-arg PULSAR_IMAGE="${PULSAR_IMAGE}" .
-docker run -i -v ${PWD}:/pulsar-client-go ${IMAGE_NAME} \
- bash -c "cd /pulsar-client-go && ./run-ci.sh"
+test: container
+ docker run -i -v ${PWD}:/pulsar-client-go ${IMAGE_NAME} \
+ bash -c "cd /pulsar-client-go && ./scripts/run-ci.sh"
+
+clean:
+ docker rmi --force $(IMAGE_NAME) || true
+ rm bin/*
diff --git a/README.md b/README.md
index a2276f5..9dff205 100644
--- a/README.md
+++ b/README.md
@@ -24,11 +24,11 @@
[![LICENSE](https://img.shields.io/hexpm/l/pulsar.svg)](https://github.com/apache/pulsar-client-go/blob/master/LICENSE)
# Apache Pulsar Go Client Library
-A Go client library for the [Apache Pulsar](https://pulsar.incubator.apache.org/) project.
+A Go client library for [Apache Pulsar](https://pulsar.apache.org/).
-## Goal
+## Purpose
-This projects is developing a pure-Go client library for Pulsar that does not
+This project is a pure-Go client library for Pulsar that does not
depend on the C++ Pulsar library.
Once feature parity and stability are reached, this will supersede the current
@@ -138,17 +138,21 @@ for reader.HasNext() {
Build the sources:
- go build ./pulsar
+ make build
-Run the unit tests:
+Run the tests:
- ./docker-ci.sh
+ make test
+
+Run the tests with specific versions of GOLANG and PULSAR:
+
+ make test GOLANG_VERSION=1.18 PULSAR_VERSION=2.10.0
## Contributing
Contributions are welcomed and greatly appreciated. See [CONTRIBUTING.md](CONTRIBUTING.md) for details on submitting patches and the contribution workflow.
-## Contact
+## Community
##### Mailing lists
diff --git a/integration-tests/.htpasswd b/integration-tests/conf/.htpasswd
similarity index 100%
rename from integration-tests/.htpasswd
rename to integration-tests/conf/.htpasswd
diff --git a/integration-tests/client.conf b/integration-tests/conf/client.conf
similarity index 100%
rename from integration-tests/client.conf
rename to integration-tests/conf/client.conf
diff --git a/integration-tests/standalone.conf b/integration-tests/conf/standalone.conf
similarity index 100%
rename from integration-tests/standalone.conf
rename to integration-tests/conf/standalone.conf
diff --git a/pulsar-test-service-start.sh b/scripts/pulsar-test-service-start.sh
similarity index 100%
rename from pulsar-test-service-start.sh
rename to scripts/pulsar-test-service-start.sh
diff --git a/pulsar-test-service-stop.sh b/scripts/pulsar-test-service-stop.sh
similarity index 100%
rename from pulsar-test-service-stop.sh
rename to scripts/pulsar-test-service-stop.sh
diff --git a/run-ci.sh b/scripts/run-ci.sh
similarity index 90%
rename from run-ci.sh
rename to scripts/run-ci.sh
index 2de0eee..e9d768b 100755
--- a/run-ci.sh
+++ b/scripts/run-ci.sh
@@ -27,12 +27,12 @@ go mod download
# Basic compilation
go build ./pulsar
-go build -o pulsar-perf ./perf
+go build -o bin/pulsar-perf ./perf
-./pulsar-test-service-start.sh
+scripts/pulsar-test-service-start.sh
go test -race -coverprofile=/tmp/coverage -timeout=20m ./...
go tool cover -html=/tmp/coverage -o coverage.html
-./pulsar-test-service-stop.sh
+scripts/pulsar-test-service-stop.sh