Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add CI #24

Merged
merged 19 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .github/ci.yaml

This file was deleted.

72 changes: 72 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
issues:
exclude-dirs:
- lib
7 changes: 7 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "solhint:recommended",
"rules": {
"compiler-version": ["error", "^0.8.13"],
"func-visibility": ["warn", {"ignoreConstructors": true}]
}
}
63 changes: 62 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,80 @@
.PHONY: devnet-up
# suave-geth
.PHONY: devnet-up devnet-down
devnet-up:
@docker compose --file ./compose.yaml up --detach

.PHONY: devnet-down
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 \
--go_out=src/go/pb --go_opt=paths=source_relative \
--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
3 changes: 3 additions & 0 deletions buf.work.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: v1
directories:
- src/proto
Loading