Skip to content

Commit

Permalink
ci: run unit tests against sqlite and postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
positiveblue committed Jun 13, 2023
1 parent 28a0625 commit ebffd58
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ jobs:
matrix:
unit_type:
- unit-race
- unit-race dbbackend=postgres

steps:
- name: git checkout
uses: actions/checkout@v2
Expand Down
22 changes: 17 additions & 5 deletions make/testing_flags.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
TEST_FLAGS =
COVER_PKG = $$(go list -deps ./... | grep '$(PKG)')
DEV_TAGS = dev
COVER_PKG = $$(go list -deps -tags="$(DEV_TAGS)" ./... | grep '$(PKG)' | grep -v lnrpc)
GOLIST := go list -tags="$(DEV_TAGS)" -deps $(PKG)/... | grep '$(PKG)'| grep -v '/vendor/'

# If specific package is being unit tested, construct the full name of the
# subpackage.
Expand All @@ -23,18 +25,28 @@ else
TEST_FLAGS += -test.timeout=20m
endif

# If we are targetting postgres make sure our tests have the tags.
ifeq ($(dbbackend),postgres)
DEV_TAGS += test_db_postgres
endif

# Add any additional tags to the dev tags list.
ifneq ($(tags),)
DEV_TAGS += ${tags}
endif

# UNIT_TARGTED is undefined iff a specific package and/or unit test case is
# not being targeted.
UNIT_TARGETED ?= no

# If a specific package/test case was requested, run the unit test for the
# targeted case. Otherwise, default to running all tests.
ifeq ($(UNIT_TARGETED), yes)
UNIT := $(GOTEST) $(TEST_FLAGS) $(UNITPKG)
UNIT_RACE := $(GOTEST) $(TEST_FLAGS) -race $(UNITPKG)
UNIT := $(GOTEST) -tags="$(DEV_TAGS)" $(TEST_FLAGS) $(UNITPKG)
UNIT_RACE := $(GOTEST) -tags="$(DEV_TAGS)" $(TEST_FLAGS) -race $(UNITPKG)
endif

ifeq ($(UNIT_TARGETED), no)
UNIT := $(GOLIST) | $(XARGS) env $(GOTEST) $(TEST_FLAGS)
UNIT_RACE := $(UNIT) -race
UNIT := $(GOLIST) | $(XARGS) env $(GOTEST) -tags="$(DEV_TAGS)" $(TEST_FLAGS)
UNIT_RACE := $(GOLIST) | $(XARGS) env $(GOTEST) -tags="$(DEV_TAGS)" -race $(TEST_FLAGS)
endif

0 comments on commit ebffd58

Please sign in to comment.