Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Build Docker image during test #50

Merged
merged 7 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,27 @@ jobs:
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'"

Test:
# The custom image here contains pre-built libraries for leveldb and
# rocksdb, which are needed to build and test those modules.
# To update the container image, see docker.yml.
runs-on: ubuntu-latest
container: cometbft/cometbft-db-testing
steps:
- uses: actions/checkout@v3

- name: Set up Docker Build
uses: docker/setup-buildx-action@v2.4.1
with:
driver: docker

- name: Build Docker image
uses: docker/build-push-action@v4
with:
context: ./tools
file: ./tools/Dockerfile
tags: "cometbft/cometbft-db-testing:latest"
load: true

- name: test & coverage report creation
run: |
CGO_ENABLED=1 go test ./... -mod=readonly -timeout 8m -race -coverprofile=coverage.txt -covermode=atomic -tags=memdb,goleveldb,cleveldb,boltdb,rocksdb,badgerdb -v
NON_INTERACTIVE=1 make docker-test

- uses: codecov/codecov-action@v3
with:
file: ./coverage.txt
5 changes: 0 additions & 5 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@
name: Docker testing image
on:
workflow_dispatch:
pull_request:
paths:
- "tools/*"
push:
branches:
- main
paths:
- "tools/*"
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10
- "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+" # e.g. v0.37.0-alpha.1, v0.38.0-alpha.10
Expand Down
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ PACKAGES=$(shell go list ./...)
INCLUDE = -I=${GOPATH}/src/github.com/cometbft/cometbft-db -I=${GOPATH}/src -I=${GOPATH}/src/github.com/gogo/protobuf/protobuf
DOCKER_TEST_IMAGE ?= cometbft/cometbft-db-testing
DOCKER_TEST_IMAGE_VERSION ?= latest
NON_INTERACTIVE ?= 0
DOCKER_TEST_INTERACTIVE_FLAGS ?= -it

ifeq (1,$(NON_INTERACTIVE))
DOCKER_TEST_INTERACTIVE_FLAGS :=
endif

export GO111MODULE = on

Expand Down Expand Up @@ -70,9 +76,9 @@ docker-test-image:
.PHONY: docker-test-image

# Runs the same test as is executed in CI, but locally.
docker-test: docker-test-image
@echo "--> Running all tests with all databases with Docker"
@docker run -it --rm --name cometbft-db-test \
docker-test:
@echo "--> Running all tests with all databases with Docker (interactive flags: \"$(DOCKER_TEST_INTERACTIVE_FLAGS)\")"
@docker run $(DOCKER_TEST_INTERACTIVE_FLAGS) --rm --name cometbft-db-test \
-v `pwd`:/cometbft \
-w /cometbft \
--entrypoint "" \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ local machine, use `make test-all` to test them all.
To test all databases within a Docker container, run:

```bash
make docker-test-image
make docker-test
```

Expand Down