Skip to content

Commit 4a8d2d5

Browse files
committed
change build action
Signed-off-by: Fedor Partanskiy <[email protected]>
1 parent 7a86629 commit 4a8d2d5

File tree

7 files changed

+698
-939
lines changed

7 files changed

+698
-939
lines changed

.github/workflows/build.yml

+56-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,64 @@
11
name: Build
22

33
on:
4+
push:
5+
branches: [ "**" ]
46
pull_request:
7+
branches: [ "**" ]
8+
workflow_dispatch:
9+
10+
env:
11+
GO_VER: 1.24.1
12+
PROTOC_VER: 29.3
13+
PROTOC_GEN_GO_VER: v1.36.5
514

615
jobs:
16+
validate:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
name: Checkout Code
21+
22+
- name: Install Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version: ${{ env.GO_VER }}
26+
27+
- name: Install Protoc
28+
uses: arduino/setup-protoc@v3
29+
with:
30+
version: ${{ env.PROTOC_VER }}
31+
32+
- name: check go.mod
33+
run: |
34+
go mod tidy
35+
git diff --exit-code go.mod
36+
37+
- name: check vendor
38+
run: |
39+
go mod vendor
40+
git diff --exit-code
41+
42+
- name: go fmt
43+
run: |
44+
go fmt ./...
45+
git diff --exit-code
46+
47+
- name: goimports
48+
run: |
49+
go install golang.org/x/tools/cmd/goimports@latest
50+
goimports -l -w `find . -name '*.go' | grep -v vendor | grep -v 'pb.go'`
51+
git diff --exit-code
52+
53+
- name: check protobuf
54+
run: |
55+
go install google.golang.org/protobuf/cmd/protoc-gen-go@${{ env.PROTOC_GEN_GO_VER }}
56+
make protos
57+
git diff --exit-code
758
859
build:
60+
needs:
61+
- validate
962
runs-on: ubuntu-latest
1063
steps:
1164
- uses: actions/checkout@v4
@@ -14,15 +67,8 @@ jobs:
1467
- name: Install Go
1568
uses: actions/setup-go@v5
1669
with:
17-
go-version: 1.22.4
18-
19-
- name: Prepare Env
20-
run: bash scripts/prepare_environ.sh
70+
go-version: ${{ env.GO_VER }}
2171

2272
- name: Test
23-
working-directory: /home/runner/go/src/github.com/hyperledger-labs/SmartBFT
24-
run: make all
25-
26-
- name: Post
27-
working-directory: /home/runner/go/src/github.com/hyperledger-labs/SmartBFT
28-
run: ./scripts/post.sh
73+
run: |
74+
go test -count 1 -race ./...

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ all:
55
bash ./scripts/build_checks.sh
66
protos:
77
protoc --go_opt=paths=source_relative --go_out=. smartbftprotos/*.proto
8-
find . -name "*.pb.go" | grep -v "^./vendor" | xargs goimports -w
8+
protoc --go_opt=paths=source_relative --go_out=. examples/naive_chain/*.proto
9+
protoc --go_opt=paths=source_relative --go_out=. test/*.proto

examples/naive_chain/test_message.pb.go

+48-64
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/build_checks.sh

+13-13
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ err() {
1010

1111
echo -e "\nTesting commit: ------${ANSI_GREEN}" $(git log -1 --no-merges | head -$(( $(git log -1 --no-merges | wc -l) - 2 )) | tail -1) "${ANSI_RESET}------\n"
1212

13-
go get -u golang.org/x/tools/cmd/goimports
14-
go get -u google.golang.org/protobuf/cmd/protoc-gen-go
15-
13+
go install golang.org/x/tools/cmd/goimports@latest
14+
go install google.golang.org/protobuf/cmd/[email protected]
1615

1716
BUILDDIR=.build
1817
if [ ! -d "$BUILDDIR" ]; then
1918
mkdir $BUILDDIR
2019
fi
2120
cd $BUILDDIR
2221

23-
PROTOC_ZIP=protoc-3.8.0-linux-x86_64.zip
22+
PROTOC_VER=29.3
23+
PROTOC_ZIP=protoc-$PROTOC_VER-linux-x86_64.zip
2424
if [ ! -f "$PROTOC_ZIP" ]; then
2525
echo "$PROTOC_ZIP does not exist"
26-
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.12.3/protoc-3.12.3-linux-x86_64.zip
27-
unzip protoc-3.12.3-linux-x86_64.zip
26+
wget https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VER/$PROTOC_ZIP
27+
unzip $PROTOC_ZIP
2828
fi
2929

3030
export PATH=$PATH:$BUILDDIR/bin/
@@ -52,13 +52,13 @@ else
5252
fi
5353

5454
make protos
55-
# git status | grep "pb.go" | grep -q "modified"
56-
# if [ $? -eq 0 ];then
57-
# git status
58-
# err "protobuf not up to date"
59-
# git diff
60-
# exit 1
61-
# fi
55+
git status | grep "pb.go" | grep -q "modified"
56+
if [ $? -eq 0 ];then
57+
git status
58+
err "protobuf not up to date"
59+
git diff
60+
exit 1
61+
fi
6262

6363
( sleep 600; ps -ef | grep test | grep -v "go test" | grep -v grep | awk '{print $2}' | xargs kill -SIGABRT ) &
6464

0 commit comments

Comments
 (0)