From eb76df22af662774063e9f0b4bfe1d2bc764fc59 Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Wed, 11 May 2022 10:00:31 +0300 Subject: [PATCH] better ci --- .github/workflows/ci.yml | 63 ++++++++++++++++++++++++++++++---------- Makefile | 24 +++++++++++++-- 2 files changed, 69 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d61e14cb42..b6e2e71305 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,20 +1,53 @@ name: CI on: [push, pull_request] jobs: - build: - runs-on: ubuntu-latest + tests: + strategy: + matrix: + os: [ ubuntu-20.04, macos-11 ] # list of os: https://github.com/actions/virtual-environments + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: 1.17 - - name: "Build binaries" - run: make all - - name: "Run tests" - run: make test - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 - with: - file: ./cover.out + - uses: actions/checkout@v3 + - run: git submodule update --init --recursive --force + - uses: actions/setup-go@v3 + with: + go-version: 1.18.x + - name: Install dependencies on Linux + if: runner.os == 'Linux' + run: sudo apt update && sudo apt install build-essential + - uses: actions/cache@v3 + with: + path: | + ~/.cache/go-build + ~/Library/Caches/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: ${{ runner.os }}-go- + + - name: Build + run: make all + + - name: Reproducible build test + run: | + make geth + shasum -a256 ./build/bin/geth > bor1.sha256 + make geth + shasum -a256 ./build/bin/geth > bor2.sha256 + if ! cmp -s bor1.sha256 bor2.sha256; then + echo >&2 "Reproducible build broken"; cat bor1.sha256; cat bor2.sha256; exit 1 + fi + + - name: Lint + if: runner.os == 'Linux' + uses: golangci/golangci-lint-action@v3 + with: + version: v1.46 + skip-pkg-cache: true + skip-build-cache: true + + - name: Test + run: make test + + - name: Data race tests + run: make test-race \ No newline at end of file diff --git a/Makefile b/Makefile index 6469b8510f..d23903faac 100644 --- a/Makefile +++ b/Makefile @@ -4,11 +4,21 @@ .PHONY: geth android ios evm all test clean -GOBIN = ./build/bin GO ?= latest +GOBIN = $(CURDIR)/build/bin GORUN = env GO111MODULE=on go run GOPATH = $(shell go env GOPATH) +GIT_COMMIT ?= $(shell git rev-list -1 HEAD) +GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD) +GIT_TAG ?= $(shell git describe --tags `git rev-list --tags="v*" --max-count=1`) + +PACKAGE = github.com/ethereum/go-ethereum +GO_FLAGS += -trimpath -buildvcs=false +GO_FLAGS += -ldflags "-X ${PACKAGE}/params.GitCommit=${GIT_COMMIT} -X ${PACKAGE}/params.GitBranch=${GIT_BRANCH} -X ${PACKAGE}/params.GitTag=${GIT_TAG}" + +GOTEST = GODEBUG=cgocheck=0 go test $(GO_FLAGS) ./... -p 1 -shuffle=on + bor: $(GORUN) build/ci.go install ./cmd/geth mkdir -p $(GOPATH)/bin/ @@ -45,8 +55,16 @@ ios: @echo "Import \"$(GOBIN)/Geth.framework\" to use the library." test: - # Skip mobile and cmd tests since they are being deprecated - go test -v $$(go list ./... | grep -v go-ethereum/cmd/) -cover -coverprofile=cover.out + $(GOTEST) --timeout 5m -cover -coverprofile=cover.out + +test-race: + $(GOTEST) --timeout 5m -race + +test-integration: + $(GOTEST) --timeout 30m -tags integration + +escape: + cd $(path) && go test -gcflags "-m -m" -run none -bench=BenchmarkJumpdest* -benchmem -memprofile mem.out lint: ## Run linters. $(GORUN) build/ci.go lint