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

Add autofix protobuf job #2031

Merged
merged 6 commits into from
Nov 12, 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
27 changes: 27 additions & 0 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: autofix.ci # needed to securely identify the workflow

on:
pull_request:

permissions:
contents: read

jobs:
autofix-protobuf:
runs-on: ubuntu-latest
container:
image: ghcr.io/cosmos/proto-builder:0.14.0
options: --user root # workaround for a problem during actions/checkout, see https://github.com/actions/checkout/issues/1014
steps:
- uses: actions/checkout@v4
- name: Fix permissions # needed because of root user fix above
run: git config --global --add safe.directory "$PWD"
- name: Format protobuf
run: find ./ -name "*.proto" -exec clang-format -i {} \;
- name: Generate protobuf
run: sh ./scripts/protocgen.sh
- name: Format
run: make format

# Get latest version from https://autofix.ci/setup
- uses: autofix-ci/action@dd55f44df8f7cdb7a6bf74c78677eb8acd40cd0a
22 changes: 22 additions & 0 deletions .github/workflows/proto-buf-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Protobuf Linting
# run buf lint (https://buf.build/)
# This workflow is only run when a .proto file has been changed
on:
pull_request:
paths:
- "proto/**"

permissions:
contents: read

jobs:
buf-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/[email protected]

# lint checks
- uses: bufbuild/buf-lint-action@v1
with:
input: "proto"
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ SIMAPP = ./app

# for dockerized protobuf tools
DOCKER := $(shell which docker)
BUF_IMAGE=bufbuild/buf@sha256:3cb1f8a4b48bd5ad8f09168f10f607ddc318af202f5c057d52a45216793d85e5 #v1.4.0
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(BUF_IMAGE)
HTTPS_GIT := https://github.com/CosmWasm/wasmd.git

export GO111MODULE = on
Expand Down Expand Up @@ -187,10 +185,10 @@ proto-swagger-gen:
@./scripts/protoc-swagger-gen.sh

proto-lint:
@$(DOCKER_BUF) lint --error-format=json
@$(protoImage) buf lint --error-format=json

proto-check-breaking:
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=main
@$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=main

.PHONY: all install install-debug \
go-mod-cache draw-deps clean build format \
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/ibc_fees_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"
"time"

wasmvmtypes "github.com/CosmWasm/wasmvm/v2/types"
ibcfee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types"
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck
Expand All @@ -23,7 +24,6 @@ import (
"github.com/CosmWasm/wasmd/app"
wasmibctesting "github.com/CosmWasm/wasmd/tests/ibctesting"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
wasmvmtypes "github.com/CosmWasm/wasmvm/v2/types"
)

func TestIBCFeesTransfer(t *testing.T) {
Expand Down
10 changes: 6 additions & 4 deletions x/wasm/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1615,12 +1615,14 @@ func TestIterateContractsByCode(t *testing.T) {

func TestIterateContractsByCodeWithMigration(t *testing.T) {
// mock migration so that it does not fail when migrate example1 to example2.codeID
mockWasmVM := wasmtesting.MockWasmEngine{MigrateFn: func(codeID wasmvm.Checksum, env wasmvmtypes.Env, migrateMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.ContractResult, uint64, error) {
return &wasmvmtypes.ContractResult{Ok: &wasmvmtypes.Response{}}, 1, nil
},
mockWasmVM := wasmtesting.MockWasmEngine{
MigrateFn: func(codeID wasmvm.Checksum, env wasmvmtypes.Env, migrateMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.ContractResult, uint64, error) {
return &wasmvmtypes.ContractResult{Ok: &wasmvmtypes.Response{}}, 1, nil
},
MigrateWithInfoFn: func(codeID wasmvm.Checksum, env wasmvmtypes.Env, migrateMsg []byte, migrateInfo wasmvmtypes.MigrateInfo, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.ContractResult, uint64, error) {
return &wasmvmtypes.ContractResult{Ok: &wasmvmtypes.Response{}}, 1, nil
}}
},
}
wasmtesting.MakeInstantiable(&mockWasmVM)
ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, WithWasmEngine(&mockWasmVM))
k, c := keepers.WasmKeeper, keepers.ContractKeeper
Expand Down
22 changes: 22 additions & 0 deletions x/wasm/types/query.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.