Skip to content

Commit

Permalink
Remove contract compile in Makefile
Browse files Browse the repository at this point in the history
Now that we are checking in the compiled contract definition we no
longer need to compile the contract on each make.
  • Loading branch information
jkilpatr committed Apr 25, 2024
1 parent 1b97ebf commit 721aebc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 68 deletions.
32 changes: 2 additions & 30 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,12 @@ jobs:
go-version: ^1.16
- name: Check out code
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Configure node for CI
run: cd solidity && npm ci
- name: Precompile Solidity contracts
run: cd solidity && npm run typechain
- name: Build the Althea-L1 binary
run: make
lint:
name: Lint
runs-on: ubuntu-latest
needs: Build
needs: build
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
Expand All @@ -43,38 +35,18 @@ jobs:
uses: actions/checkout@v2
- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ job.build.strategy.matrix.node-version }}
- name: Configure node for CI
run: cd solidity && npm ci
- name: Precompile Solidity contracts
run: cd solidity && npm run typechain
- name: Format solidity contracts for Go
run: make contracts-auto
- name: Run golangci-lint
run: golangci-lint run -c .golangci.yml --disable-all --timeout=30m && go mod verify

test:
name: Test
runs-on: ubuntu-latest
needs: Build
needs: build
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.16
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ job.build.strategy.matrix.node-version }}
- name: Configure node for CI
run: cd solidity && npm ci
- name: Precompile Solidity contracts
run: cd solidity && npm run typechain
- name: Format solidity contracts for Go
run: make contracts-auto
- name: Test
run: go test ./... -mod=readonly -timeout 30m -coverprofile=profile.out -covermode=atomic -race
42 changes: 4 additions & 38 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ all: install
install: go.sum install-core

# does not run go mod verify
install-core: contracts-auto
install-core:
export GOFLAGS='-buildmode=pie'
export CGO_CPPFLAGS="-D_FORTIFY_SOURCE=2"
export CGO_LDFLAGS="-Wl,-z,relro,-z,now -fstack-protector"
Expand All @@ -67,11 +67,11 @@ go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
GO111MODULE=on go mod verify

test: contracts-auto
test:
@go test -mod=readonly $(PACKAGES)

# look into .golangci.yml for enabling / disabling linters
lint: contracts-auto
lint:
@echo "--> Running linter"
@golangci-lint run
@go mod verify
Expand Down Expand Up @@ -218,45 +218,11 @@ $(BUILD_TARGETS): go.sum $(BUILDDIR)/
$(BUILDDIR)/:
mkdir -p $(BUILDDIR)/

###############################################################################
### EVM Contracts ###
###############################################################################

COMPILED_CONTRACTS_GO_OUTPUT := contracts/compiled/

contracts: contracts-go

contracts-clean:
@echo "Deleting and recreating compiled-contracts directory"
@rm -fr $(COMPILED_CONTRACTS_GO_OUTPUT)
@mkdir -p ${COMPILED_CONTRACTS_GO_OUTPUT}

contracts-go:
@echo "Formatting compiled contracts and placing in compiled-contracts"
@cd solidity; npm install
@cd solidity; npx hardhat compile
@scripts/compile-contracts-for-go.sh

# Detects if the contracts must be compiled for Go, and potentially does so
# If you need to overwrite the compiled-for-go contracts, use contracts instead
# since that will clean then compile
# Note that this depends on the solidity contracts being compiled already via hardhat
contracts-auto:
ifeq ("$(ls ${COMPILED_CONTRACTS_GO_OUTPUT})", "")
@echo "Compiled contracts folder is empty, compiling now"
@cd solidity; npm install
@cd solidity; npm run typechain
@scripts/compile-contracts-for-go.sh
else
@echo "Detected compiled contract interfaces for Go"
endif


###############################################################################
### MISC DIRECTIVES ###
###############################################################################

tools: proto-tools buf

clean: proto-tools-clean contracts-clean
clean: proto-tools-clean
rm -rf $(BUILDDIR)/ artifacts/

0 comments on commit 721aebc

Please sign in to comment.