diff --git a/.github/ci.yaml b/.github/ci.yaml deleted file mode 100644 index fc2e7e1..0000000 --- a/.github/ci.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: "CI: Foundry" -on: - push: - branches: - - main - pull_request: - -env: - FOUNDRY_PROFILE: ci - -jobs: - check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 - - - name: Run tests - run: forge test -vvv diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..9aa6e15 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,72 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + ci: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + + - name: Install protoc-gen-go + run: | + go install google.golang.org/protobuf/cmd/protoc-gen-go@latest + go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest + + - name: Install protoc-gen-grpc-gateway + run: | + go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest + + - name: Set up Protoc + uses: arduino/setup-protoc@v3 + + - name: Install buf + uses: bufbuild/buf-setup-action@v1 + + - name: Install Solhint + run: npm install -g solhint + + - name: Install golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: latest + args: --timeout=5m + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: | + ~/.foundry + ~/go/pkg/mod + key: ${{ runner.os }}-deps-${{ hashFiles('foundry.toml') }}-${{ hashFiles('go.sum') }} + + - name: Start suave-geth + run: make devnet-up + + - name: Build + run: make build + + # - name: Test + # run: make test + + - name: Format check + run: make check-fmt + + - name: Lint + run: make lint + + - name: Stop suave-geth + if: always() + run: make devnet-down diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..2f61c3e --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,3 @@ +issues: + exclude-dirs: + - lib diff --git a/.solhint.json b/.solhint.json new file mode 100644 index 0000000..014fe0c --- /dev/null +++ b/.solhint.json @@ -0,0 +1,7 @@ +{ + "extends": "solhint:recommended", + "rules": { + "compiler-version": ["error", "^0.8.13"], + "func-visibility": ["warn", {"ignoreConstructors": true}] + } +} diff --git a/Makefile b/Makefile index 712553d..51fd8bc 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ -.PHONY: devnet-up +# suave-geth +.PHONY: devnet-up devnet-down devnet-up: @docker compose --file ./compose.yaml up --detach @@ -6,10 +7,43 @@ devnet-up: devnet-down: @docker compose --file ./compose.yaml down +# Solidity +build-solidity: + forge build --via-ir + +test-solidity: + forge test --ffi --via-ir test/**/*.t.sol + +lint-solidity: + solhint 'src/**/*.sol' + +fmt-solidity: + forge fmt src/solidit + +check-fmt-solidity: + forge fmt --check src/solidity + +# Golang .PHONY: run-go run-go: @cd src/go && go run main.go && cd ../../ +build-go: + go build ./src/go + +test-go: + go test ./src/go/... ./test/... + +lint-go: + golangci-lint run + +fmt-go: + go fmt ./src/go/... ./test/... + +check-fmt-go: + gofmt -d ./src/go ./test + +# Protobuf .PHONY: run-proto run-proto: @protoc -I./src/proto \ @@ -17,3 +51,30 @@ run-proto: --go-grpc_out=src/go/pb --go-grpc_opt=paths=source_relative \ --grpc-gateway_out=src/go/pb --grpc-gateway_opt=paths=source_relative \ src/proto/transferable_account.proto + +compile-proto: + @make run-proto + +lint-proto: + buf lint + +fmt-proto: + buf format src/proto + +check-fmt-proto: + buf format -d src/proto + +# General +.PHONY: build test lint fmt check-fmt +build: build-solidity build-go compile-proto + +test: test-solidity test-go + +lint: lint-solidity + +fmt: fmt-solidity fmt-go fmt-proto + +check-fmt: check-fmt-solidity check-fmt-go check-fmt-proto + +# CI +ci: build test lint check-fmt diff --git a/buf.work.yaml b/buf.work.yaml new file mode 100644 index 0000000..f62e33c --- /dev/null +++ b/buf.work.yaml @@ -0,0 +1,3 @@ +version: v1 +directories: + - src/proto