Skip to content

Commit ad43c0f

Browse files
committed
multi: add more github workflows
This commit adds github workflows for unit tests and itests. It also removes the private repo items from the workflow as these are no longer needed.
1 parent 56ea7e2 commit ad43c0f

File tree

5 files changed

+176
-20
lines changed

5 files changed

+176
-20
lines changed

.github/workflows/main.yml

Lines changed: 117 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ env:
1717
GOCACHE: /home/runner/work/go/pkg/build
1818
GOPATH: /home/runner/work/go
1919
GO_VERSION: 1.17.x
20-
GOPRIVATE: "github.com/lightninglabs/aperture-mailbox"
21-
TOKEN: ${{ secrets.ACCESS_TOKEN }}
2220

2321
jobs:
22+
########################
23+
# build pkg and wasm bin
24+
########################
2425
build:
25-
name: build package, run linter
26+
name: build package and wasm
2627
runs-on: ubuntu-latest
2728
steps:
2829
- name: git checkout
@@ -32,32 +33,132 @@ jobs:
3233
uses: actions/cache@v1
3334
with:
3435
path: /home/runner/work/go
35-
key: lndclient-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
36+
key: lnc-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
3637
restore-keys: |
37-
lndclient-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
38-
lndclient-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-
39-
lndclient-${{ runner.os }}-go-${{ env.GO_VERSION }}-
40-
lndclient-${{ runner.os }}-go-
38+
lnc-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
39+
lnc-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-
40+
lnc-${{ runner.os }}-go-${{ env.GO_VERSION }}-
41+
lnc-${{ runner.os }}-go-
4142
4243
- name: setup go ${{ env.GO_VERSION }}
4344
uses: actions/setup-go@v2
4445
with:
4546
go-version: '~${{ env.GO_VERSION }}'
4647

47-
- name: configure for private repos
48-
run: git config --global url."https://roasbeef:${TOKEN}@github.com".insteadOf "https://github.com"
49-
50-
- name: lint
51-
run: make lint
52-
5348
- name: go compile
5449
run: make build
5550

5651
- name: wasm compile
5752
run: make wasm
5853

54+
########################
55+
# lint code
56+
########################
57+
lint:
58+
name: lint code
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: git checkout
62+
uses: actions/checkout@v2
63+
64+
- name: Fetch all history for linter
65+
run: git fetch --prune --unshallow
66+
67+
- name: go cache
68+
uses: actions/cache@v1
69+
with:
70+
path: /home/runner/work/go
71+
key: lnc-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
72+
restore-keys: |
73+
lnc-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
74+
lnc-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-
75+
lnc-${{ runner.os }}-go-${{ env.GO_VERSION }}-
76+
lnc-${{ runner.os }}-go-
77+
78+
- name: setup go ${{ env.GO_VERSION }}
79+
uses: actions/setup-go@v2
80+
with:
81+
go-version: '${{ env.GO_VERSION }}'
82+
83+
- name: lint
84+
run: GOGC=50 make lint
85+
86+
########################
87+
# run unit tests
88+
########################
89+
unit-test:
90+
name: run unit tests
91+
runs-on: ubuntu-latest
92+
strategy:
93+
# Allow other tests in the matrix to continue if one fails.
94+
fail-fast: false
95+
matrix:
96+
unit_type:
97+
- unit
98+
- unit-race
99+
steps:
100+
- name: git checkout
101+
uses: actions/checkout@v2
102+
103+
- name: go cache
104+
uses: actions/cache@v1
105+
with:
106+
path: /home/runner/work/go
107+
key: lnc-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
108+
restore-keys: |
109+
lnc-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
110+
lnc-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-
111+
lnc-${{ runner.os }}-go-${{ env.GO_VERSION }}-
112+
lnc-${{ runner.os }}-go-
113+
114+
- name: setup go ${{ env.GO_VERSION }}
115+
uses: actions/setup-go@v2
116+
with:
117+
go-version: '~${{ env.GO_VERSION }}'
118+
119+
- name: run ${{ matrix.unit_type }}
120+
run: make ${{ matrix.unit_type }}
121+
122+
########################
123+
# run integration tests
124+
########################
125+
integration-test:
126+
name: run itests
127+
runs-on: ubuntu-latest
128+
steps:
129+
- name: git checkout
130+
uses: actions/checkout@v2
131+
132+
- name: go cache
133+
uses: actions/cache@v1
134+
with:
135+
path: /home/runner/work/go
136+
key: lnc-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
137+
restore-keys: |
138+
lnc-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
139+
lnc-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-
140+
lnc-${{ runner.os }}-go-${{ env.GO_VERSION }}-
141+
lnc-${{ runner.os }}-go-
142+
143+
- name: setup go ${{ env.GO_VERSION }}
144+
uses: actions/setup-go@v2
145+
with:
146+
go-version: '${{ env.GO_VERSION }}'
147+
59148
- name: prepare for itest
60149
run: mkdir -p /home/runner/.aperture
61150

62-
- name: unit-race
63-
run: make unit-race
151+
- name: run itest
152+
run: make itest
153+
154+
- name: Zip log files on failure
155+
if: ${{ failure() }}
156+
run: 7z a logs-itest.zip itest/**/*.log
157+
158+
- name: Upload log files on failure
159+
uses: actions/upload-artifact@v2.2.4
160+
if: ${{ failure() }}
161+
with:
162+
name: logs-itest
163+
path: logs-itest.zip
164+
retention-days: 5

Makefile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,16 @@ GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
1919
GOLIST := go list $(PKG)/... | grep -v '/vendor/'
2020
XARGS := xargs -L 1
2121

22-
UNIT := $(GOLIST) | $(XARGS) env $(GOTEST) -tags="rpctest $(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS)
23-
UNIT_RACE := $(UNIT) -race
24-
2522
LDFLAGS := -s -w -buildid=
2623

2724
RM := rm -f
2825
CP := cp
2926
MAKE := make
3027
XARGS := xargs -L 1
3128

32-
LINT = $(LINT_BIN) run -v
29+
LINT = $(LINT_BIN) run -v --build-tags itest
30+
31+
include make/testing_flags.mk
3332

3433
default: build
3534

@@ -71,6 +70,12 @@ unit-race:
7170
@$(call print, "Running unit race tests.")
7271
env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(UNIT_RACE)
7372

73+
itest: itest-run
74+
75+
itest-run:
76+
@$(call print, "Running integration tests.")
77+
$(GOTEST) ./itest -tags="$(ITEST_TAGS)" $(TEST_FLAGS) -logoutput -goroutinedump -logdir=itest_logs
78+
7479
# =========
7580
# UTILITIES
7681
# =========

itest/test_list_off_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//go:build !itest
2+
// +build !itest
3+
4+
package itest
5+
6+
var testCases []*testCase
7+
8+
var stagingMailboxTests []*testCase

itest/test_list_test.go renamed to itest/test_list_on_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build itest
2+
// +build itest
3+
14
package itest
25

36
var testCases = []*testCase{

make/testing_flags.mk

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
TEST_FLAGS =
2+
3+
# If a specific unit test case is being target, construct test.run filter.
4+
ifneq ($(case),)
5+
TEST_FLAGS += -test.run=$(case)
6+
UNIT_TARGETED = yes
7+
endif
8+
9+
# Define the integration test.run filter if the icase argument was provided.
10+
ifneq ($(icase),)
11+
TEST_FLAGS += -test.run=TestLightningNodeConnect/$(icase)
12+
endif
13+
14+
# If a timeout was requested, construct initialize the proper flag for the go
15+
# test command. If not, we set 20m (up from the default 10m).
16+
ifneq ($(timeout),)
17+
TEST_FLAGS += -test.timeout=$(timeout)
18+
else
19+
TEST_FLAGS += -test.timeout=20m
20+
endif
21+
22+
# UNIT_TARGETED is undefined iff a specific package and/or unit test case is
23+
# not being targeted.
24+
UNIT_TARGETED ?= no
25+
26+
# If a specific package/test case was requested, run the unit test for the
27+
# targeted case. Otherwise, default to running all tests.
28+
ifeq ($(UNIT_TARGETED), yes)
29+
UNIT := $(GOTEST) $(TEST_FLAGS)
30+
UNIT_RACE := $(GOTEST) $(TEST_FLAGS) -race
31+
endif
32+
33+
ifeq ($(UNIT_TARGETED), no)
34+
UNIT := $(GOLIST) | $(XARGS) env $(GOTEST) $(TEST_FLAGS)
35+
UNIT_RACE := $(UNIT) -race
36+
endif
37+
38+
# Construct the integration test command with the added build flags.
39+
ITEST_TAGS := itest

0 commit comments

Comments
 (0)