diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 957413f..eca5d11 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -4,7 +4,23 @@ on: branches: - master pull_request: + jobs: + lint: + name: Lint and fmt check + runs-on: ubuntu-latest + steps: + - name: Check out source code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: "go.mod" + + - name: Linting and fmt check + run: make lint + build: name: CI runs-on: ubuntu-latest @@ -17,16 +33,19 @@ jobs: with: go-version-file: './go.mod' + - name: Start dependencies + run: make deps-start + - name: Running CI run: make ci - - name: Convert coverage file to lcov - run: | - GO111MODULE=off go get -u github.com/jandelgado/gcov2lcov - $(go env GOPATH)/bin/gcov2lcov -infile=coverage.txt -outfile=coverage.lcov - - - name: Coveralls - uses: coverallsapp/github-action@master + - name: Codecov + uses: codecov/codecov-action@v4 with: - github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: ./coverage.lcov + fail_ci_if_error: true # optional (default = false) + files: ./coverage.txt + name: codecov-umbrella # optional + token: ${{ secrets.CODECOV_TOKEN }} # required + + - name: Stop dependencies + run: make deps-stop diff --git a/Makefile b/Makefile index 6395940..8d0c33d 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,13 @@ VERSION?="0.0.1" -DOCKER = docker default: test test: fmtcheck go test ./... -cover -race -testint: fmtcheck deps +testint: fmtcheck go test ./... -cover -race -tags=integration -count=1 - docker stop harvester-consul - docker stop harvester-redis - - + cover: fmtcheck go test ./... -coverpkg=./... -coverprofile=cover.out -tags=integration -covermode=atomic && \ go tool cover -func=cover.out &&\ @@ -24,27 +20,23 @@ fmtcheck: @sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'" lint: fmtcheck - $(DOCKER) run --env=GOFLAGS=-mod=vendor --rm -v $(CURDIR):/app -w /app golangci/golangci-lint:v1.61.0 golangci-lint -v run + docker run --env=GOFLAGS=-mod=vendor --rm -v $(CURDIR):/app -w /app golangci/golangci-lint:v1.61.0 golangci-lint -v run deeplint: fmtcheck - $(DOCKER) run --env=GOFLAGS=-mod=vendor --rm -v $(CURDIR):/app -w /app golangci/golangci-lint:v1.61.0 golangci-lint run --exclude-use-default=false --enable-all -D dupl --build-tags integration + docker run --env=GOFLAGS=-mod=vendor --rm -v $(CURDIR):/app -w /app golangci/golangci-lint:v1.61.0 golangci-lint run --exclude-use-default=false --enable-all -D dupl --build-tags integration -deps: - docker container inspect harvester-consul > /dev/null 2>&1 || docker run -d --rm -p 8500:8500 -p 8600:8600/udp --name=harvester-consul consul:1.4.3 agent -server -ui -node=server-1 -bootstrap-expect=1 -client=0.0.0.0 -http-port 8500 -log-level=err - docker container inspect harvester-redis > /dev/null 2>&1 || docker run -d --rm -p 6379:6379 --name harvester-redis -e ALLOW_EMPTY_PASSWORD=yes bitnami/redis:6.2 +deps-start: + docker compose up -d deps-stop: - docker stop harvester-consul - docker stop harvester-redis + docker compose down -ci: fmtcheck lint deps +ci: fmtcheck go test ./... -race -cover -tags=integration -coverprofile=coverage.txt -covermode=atomic - docker stop harvester-consul - docker stop harvester-redis - + # disallow any parallelism (-j) for Make. This is necessary since some # commands during the build process create temporary files that collide # under parallel conditions. .NOTPARALLEL: -.PHONY: default test testint cover fmt fmtcheck lint deeplint ci deps deps-stop \ No newline at end of file +.PHONY: default test testint cover fmt fmtcheck lint deeplint ci deps-start deps-stop \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index d26ec0b..9cf1fbb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,13 +1,6 @@ -version: '2' - -networks: - consul-network: - driver: bridge - services: consul: - container_name: harvester_consul_dev - image: consul:1.15 + image: bitnami/consul:latest networks: - consul-network ports: @@ -17,9 +10,22 @@ services: - '8500:8500' - '8600:8600' - '8600:8600/udp' - + environment: + - CONSUL_BOOTSTRAP_EXPECT=1 + - CONSUL_CLIENT_LAN_ADDRESS=0.0.0.0 + - CONSUL_DISABLE_KEYRING_FILE=true + - CONSUL_NODE_NAME=server-1 + - CONSUL_HTTP_PORT_NUMBER=8500 + - CONSUL_ENABLE_UI=true + - CONSUL_AGENT_MODE=server + redis: - container_name: harvester_redis_dev - image: redis:alpine + image: docker.io/bitnami/redis:6.2 + environment: + - ALLOW_EMPTY_PASSWORD=yes ports: - - '6379:6379' \ No newline at end of file + - "6379:6379" + +networks: + consul-network: + driver: bridge \ No newline at end of file