Skip to content

Commit

Permalink
no longer need to run the linter in Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed Feb 15, 2024
1 parent 4558892 commit 25d25ca
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 72 deletions.
68 changes: 43 additions & 25 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,55 @@
name: Lint
name: golangci-lint
on:
push:
branches:
- master
- main
pull_request:
merge_group:

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read

jobs:
golangci:
# We need to run the linter on the same image we use for building, since it
# needs the C libraries installed for the dependencies to typecheck.
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

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


- name: Run golangci-lint
run: make docker-lint
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.22'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.56

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
#
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true, then all caching functionality will be completely disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
# skip-build-cache: true

# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"
47 changes: 0 additions & 47 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,6 @@ test:
@go test $(PACKAGES) -v
.PHONY: test

test-cleveldb:
@echo "--> Running go test"
@go test $(PACKAGES) -tags cleveldb -v
.PHONY: test-cleveldb

test-rocksdb:
@echo "--> Running go test"
@go test $(PACKAGES) -tags rocksdb -v
.PHONY: test-rocksdb

test-boltdb:
@echo "--> Running go test"
@go test $(PACKAGES) -tags boltdb -v
.PHONY: test-boltdb

test-badgerdb:
@echo "--> Running go test"
@go test $(PACKAGES) -tags badgerdb -v
.PHONY: test-badgerdb

test-pebble:
@echo "--> Running go test"
@go test $(PACKAGES) -tags pebbledb -v

test-all:
@echo "--> Running go test"
@go test $(PACKAGES) -tags cleveldb,boltdb,rocksdb,grocksdb_clean_link,badgerdb,pebbledb -v
.PHONY: test-all

test-all-with-coverage:
@echo "--> Running go test for all databases, with coverage"
Expand All @@ -56,7 +28,6 @@ test-all-with-coverage:
-race \
-coverprofile=coverage.txt \
-covermode=atomic \
-tags=memdb,goleveldb,cleveldb,boltdb,rocksdb,grocksdb_clean_link,badgerdb,pebbledb \
-v
.PHONY: test-all-with-coverage

Expand All @@ -78,25 +49,7 @@ docker-test-image:
.PHONY: docker-test-image

# Runs the same test as is executed in CI, but locally.
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 "" \
$(DOCKER_TEST_IMAGE):$(DOCKER_TEST_IMAGE_VERSION) \
make test-all-with-coverage
.PHONY: docker-test

docker-lint:
@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 "" \
$(DOCKER_TEST_IMAGE):$(DOCKER_TEST_IMAGE_VERSION) \
golangci-lint run ./...
.PHONY: docker-test

tools:
go get -v $(GOTOOLS)
Expand Down

0 comments on commit 25d25ca

Please sign in to comment.