Skip to content

Commit 3d800b5

Browse files
authored
GitHub Actions (#5)
#### Type of change - Test update #### Description - Add GitHub Actions Signed-off-by: Liran Funaro <liran.funaro@gmail.com>
1 parent 82858a6 commit 3d800b5

29 files changed

Lines changed: 205 additions & 111 deletions

.github/workflows/ci.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Copyright IBM Corp. All Rights Reserved.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
name: CI
6+
7+
on:
8+
push:
9+
branches: [ "**" ]
10+
pull_request:
11+
branches: [ "**" ]
12+
13+
env:
14+
DB_DEPLOYMENT: local
15+
16+
jobs:
17+
18+
lint:
19+
name: Lint and Build
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: actions/setup-go@v5
24+
with:
25+
go-version-file: go.mod
26+
- run: scripts/install-dev-dependencies.sh
27+
28+
- name: Lint
29+
run: |
30+
# Apply automatic formatting.
31+
gofmt -w .
32+
goimports -local "github.com/hyperledger/fabric-x-committer" -w .
33+
# Re make protobufs, overwriting any formatting
34+
PATH="$HOME/bin:$PATH" make proto
35+
# Check if original code changed due to formatting.
36+
git diff --exit-code
37+
# Fetch main to only show new lint issues.
38+
git fetch origin main:main
39+
make lint
40+
41+
- name: Build
42+
run: make build
43+
44+
unit-test:
45+
name: Unit Test (non DB)
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
- uses: actions/setup-go@v5
50+
with:
51+
go-version-file: go.mod
52+
- run: scripts/install-dev-dependencies.sh
53+
- run: make test-no-db
54+
55+
db-test:
56+
name: Requires and Core DB Tests (postgres)
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@v4
60+
- uses: actions/setup-go@v5
61+
with:
62+
go-version-file: go.mod
63+
- run: scripts/install-dev-dependencies.sh
64+
- run: scripts/get-and-start-postgres.sh
65+
- run: make test-requires-db test-core-db
66+
67+
core-db-test:
68+
name: Core DB Tests (yugabyte)
69+
runs-on: ubuntu-latest
70+
steps:
71+
- uses: actions/checkout@v4
72+
- uses: actions/setup-go@v5
73+
with:
74+
go-version-file: go.mod
75+
- run: scripts/install-dev-dependencies.sh
76+
- run: scripts/get-and-start-yuga.sh
77+
- run: make test-core-db
78+
79+
integration-test:
80+
name: Integration Tests (yugabyte)
81+
runs-on: ubuntu-latest
82+
steps:
83+
- uses: actions/checkout@v4
84+
- uses: actions/setup-go@v5
85+
with:
86+
go-version-file: go.mod
87+
- run: scripts/install-dev-dependencies.sh
88+
- run: scripts/get-and-start-yuga.sh
89+
- run: make test-integration
90+
91+
db-resiliency-test:
92+
name: Integration DB Resiliency (container)
93+
runs-on: ubuntu-latest
94+
steps:
95+
- uses: actions/checkout@v4
96+
- uses: actions/setup-go@v5
97+
with:
98+
go-version-file: go.mod
99+
- run: scripts/install-dev-dependencies.sh
100+
- run: make test-integration-db-resiliency
101+
102+
container-test:
103+
name: Build and test all-in-one test image (container)
104+
runs-on: ubuntu-latest
105+
steps:
106+
- uses: actions/checkout@v4
107+
- uses: actions/setup-go@v5
108+
with:
109+
go-version-file: go.mod
110+
- run: scripts/install-dev-dependencies.sh
111+
- run: make test-container

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ COR_DB_PACKAGES=$(shell $(go_cmd) list ./... | grep -E "$(CORE_DB_PACKAGES_REGEX
8888
REQUIRES_DB_PACKAGES=$(shell $(go_cmd) list ./... | grep -E "$(REQUIRES_DB_PACKAGES_REGEXP)")
8989
NO_DB_PACKAGES=$(shell $(go_cmd) list ./... | grep -vE "$(CORE_DB_PACKAGES_REGEXP)|$(REQUIRES_DB_PACKAGES_REGEXP)|$(HEAVY_PACKAGES_REGEXP)")
9090

91-
GO_TEST_FMT_FLAGS := -hide empty-packages $(if $(TRAVIS),-template-dir .gotestfmt/travisci,)
91+
GO_TEST_FMT_FLAGS := -hide empty-packages
9292

9393

9494
# Excludes integration and container tests.
@@ -111,7 +111,7 @@ test-integration-db-resiliency: build
111111

112112
# Tests the all-in-one docker image.
113113
test-container: build-test-node-image
114-
@$(go_test) ./docker/... | gotestfmt ${GO_TEST_FMT_FLAGS}
114+
$(go_cmd) test -v -timeout 30m ./docker/...
115115

116116
# Tests for components that directly talk to the DB, where different DBs might affect behaviour.
117117
test-core-db: build
@@ -227,7 +227,11 @@ build-release-image: build-arch
227227
$(docker_cmd) $(version) $(image_namespace) $(dockerfile_release_dir) $(multiplatform) $(arch_output_dir_rel)
228228

229229
build-test-genesis-block: $(output_dir) build-cli-loadgen
230-
bin/loadgen make-genesis-block -c "$(project_dir)/cmd/config/samples/loadgen.yaml" > "$(output_dir)/sc-genesis-block.proto.bin"
230+
@# We load the env from the Dockerfile to use them to generate the config block.
231+
env -v $(shell grep '^ENV' $(dockerfile_test_node_dir)/Dockerfile | cut -d' ' -f2- | xargs) \
232+
bin/loadgen make-genesis-block \
233+
-c "$(project_dir)/cmd/config/samples/loadgen.yaml" \
234+
>"$(output_dir)/sc-genesis-block.proto.bin"
231235

232236
#########################
233237
# Linter

api/protoblocktx/block_tx.pb.go

Lines changed: 8 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/protocoordinatorservice/coordinator.pb.go

Lines changed: 8 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/protocoordinatorservice/coordinator_grpc.pb.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/protoloadgen/loadgen.pb.go

Lines changed: 8 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/protoloadgen/loadgen_grpc.pb.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/protoqueryservice/query.pb.go

Lines changed: 7 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/protoqueryservice/query_grpc.pb.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/protosigverifierservice/verifier.pb.go

Lines changed: 8 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)