feat: [x] support team #77
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
name: Build & Test | |
on: | |
push: | |
branches: [ "master", "feature/x" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
e2e-test: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
services: | |
redis: | |
image: redis | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 6379:6379 | |
zookeeper: | |
image: wurstmeister/zookeeper | |
ports: | |
- 2181:2181 | |
kafka: | |
image: wurstmeister/kafka | |
ports: | |
- 9092:9092 | |
env: | |
KAFKA_ADVERTISED_HOST_NAME: 127.0.0.1 | |
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 | |
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true" | |
KAFKA_CREATE_TOPICS: "e2e_test_topic:3:1" | |
mongodb: | |
image: mongo | |
env: | |
MONGO_INITDB_ROOT_USERNAME: test_user | |
MONGO_INITDB_ROOT_PASSWORD: password | |
MONGO_INITDB_DATABASE: test | |
options: >- | |
--health-cmd "echo 'db.runCommand(\"ping\").ok' | mongosh localhost:27017/test --quiet" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 27017:27017 | |
etcd: | |
image: docker.io/bitnami/etcd:3.5 | |
ports: | |
- 2379:2379 | |
env: | |
ALLOW_NONE_AUTHENTICATION: yes | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.17' | |
- name: Test with coverage | |
run: go test -v -cover -timeout 5m -coverpkg=./... -parallel 4 -covermode=atomic -gcflags=all=-l $(go list ./test/e2e/...) -coverprofile=coverage_full.txt | |
env: | |
REDIS_HOST: localhost | |
REDIS_PORT: 6379 | |
- name: Filter unnecessary codes coverage | |
run: | | |
cat coverage_full.txt | grep -v "github.com/quwan-sre/observability-go-contrib/test" > coverage.txt | |
rm coverage_full.txt | |
- uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
compatibility-test: | |
needs: e2e-test | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
go-version: [ '1.17', '1.18', '1.19' ] | |
timeout-minutes: 2 | |
services: | |
redis: | |
image: redis | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 6379:6379 | |
zookeeper: | |
image: wurstmeister/zookeeper | |
ports: | |
- 2181:2181 | |
kafka: | |
image: wurstmeister/kafka | |
ports: | |
- 9092:9092 | |
env: | |
KAFKA_ADVERTISED_HOST_NAME: 127.0.0.1 | |
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 | |
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true" | |
KAFKA_CREATE_TOPICS: "e2e_test_topic:3:1" | |
mongodb: | |
image: mongo | |
env: | |
MONGO_INITDB_ROOT_USERNAME: test_user | |
MONGO_INITDB_ROOT_PASSWORD: password | |
MONGO_INITDB_DATABASE: test | |
options: >- | |
--health-cmd "echo 'db.runCommand(\"ping\").ok' | mongosh localhost:27017/test --quiet" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 27017:27017 | |
etcd: | |
image: docker.io/bitnami/etcd:3.5 | |
ports: | |
- 2379:2379 | |
env: | |
ALLOW_NONE_AUTHENTICATION: yes | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Go ${{ matrix.go-version }} | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Display Go version | |
run: go version | |
- name: Test with coverage | |
run: go test -v -cover -timeout 5m -coverpkg=./... -parallel 4 -covermode=atomic -gcflags=all=-l $(go list ./test/e2e/...) -coverprofile=coverage_full.txt | |
env: | |
REDIS_HOST: localhost | |
REDIS_PORT: 6379 |