Skip to content

Commit

Permalink
ci: migrate long sims (#6084)
Browse files Browse the repository at this point in the history
Cancel ci if no .go files have been touched. There is no clean way of
doing this so i opted to `exit 1` on the diff job if no go files were
changed and have builds depend on diff passing

- migrate proto checks  to github actions.
- providing make commands to use buf within docker.
-  test-sim-multi-seed-long migration to github actions. Follows same
  logic and only runs on release branches.
-  add protobuf section to CONTRIBUTING.md.
  • Loading branch information
tac0turtle authored Apr 28, 2020
1 parent c032ebd commit 4b3eb0e
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 52 deletions.
30 changes: 0 additions & 30 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,6 @@ jobs:
paths:
- ".git"

proto:
executor: protoc
steps:
- make:
target: protoc-gen-gocosmos
description: "Generate go plugin for protoc"
- make:
target: proto-gen proto-lint proto-check-breaking
description: "Lint and verify Protocol Buffer definitions"

test-sim-multi-seed-long:
executor: golang
steps:
- make:
target: test-sim-multi-seed-long
description: "Test multi-seed simulation (long)"

update-swagger-docs:
executor: golang
steps:
Expand All @@ -114,19 +97,6 @@ workflows:
tags:
only:
- /^v.*/
- test-sim-multi-seed-long:
requires:
- setup-dependencies
# These filters ensure that the long sim only runs during release
filters:
branches:
ignore: /.*/
tags:
only:
- /^v.*/
- proto:
requires:
- setup-dependencies
- build-docs:
context: docs-deployment-master
filters:
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/proto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Proto check
on: [pull_request]
jobs:
proto-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: technote-space/get-diff-action@v1
id: git_diff
with:
SUFFIX_FILTER: .proto
SET_ENV_NAME_INSERTIONS: 1
SET_ENV_NAME_LINES: 1
- name: lint
run: make proto-lint-docker
if: "env.GIT_DIFF != ''"
- name: check-breakage
run: make proto-check-breaking-docker
if: "env.GIT_DIFF != ''"
47 changes: 47 additions & 0 deletions .github/workflows/release-sims.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release Sims
on:
push:
branches:
- /^v.*/

jobs:
cleanup-runs:
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'"

build:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip-sims')"
steps:
- uses: actions/checkout@v2
- run: |
make build
install-runsim:
runs-on: ubuntu-latest
needs: build
steps:
- name: install runsim
run: |
export GO111MODULE="on" && go get github.com/cosmos/tools/cmd/runsim@v1.0.0
- uses: actions/cache@v1
with:
path: ~/go/bin
key: ${{ runner.os }}-go-runsim-binary

test-sim-multi-seed-long:
runs-on: ubuntu-latest
needs: [build, install-runsim]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: ~/go/bin
key: ${{ runner.os }}-go-runsim-binary
- name: test-sim-multi-seed-long
run: |
make test-sim-multi-seed-long
36 changes: 25 additions & 11 deletions .github/workflows/sims.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
name: Sims
on: [pull_request]
jobs:
diff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v1
id: git_diff
with:
SUFFIX_FILTER: |
.go
.mod
.sum
SET_ENV_NAME_INSERTIONS: 1
SET_ENV_NAME_LINES: 1
- name: Fail if no changes
# this is used to notify the other jobs that there are no changes and so they should not run
run: exit 1
if: "env.GIT_DIFF == ''"

cleanup-runs:
runs-on: ubuntu-latest
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'"
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'"

build:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip-sims')"
steps:
- uses: actions/setup-go@v2-beta
- uses: actions/checkout@v2
- run: |
make build
install-runsim:
runs-on: ubuntu-latest
needs: build
needs: [build, diff]
steps:
- uses: actions/setup-go@v2-beta
- name: install runsim
Expand All @@ -32,9 +50,8 @@ jobs:

test-sim-nondeterminism:
runs-on: ubuntu-latest
needs: [build, install-runsim]
needs: [build, install-runsim, diff]
steps:
- uses: actions/setup-go@v2-beta
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
Expand All @@ -46,9 +63,8 @@ jobs:
test-sim-import-export:
runs-on: ubuntu-latest
needs: [build, install-runsim]
needs: [build, install-runsim, diff]
steps:
- uses: actions/setup-go@v2-beta
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
Expand All @@ -60,9 +76,8 @@ jobs:
test-sim-after-import:
runs-on: ubuntu-latest
needs: [build, install-runsim]
needs: [build, install-runsim, diff]
steps:
- uses: actions/setup-go@v2-beta
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
Expand All @@ -74,9 +89,8 @@ jobs:
test-sim-multi-seed-short:
runs-on: ubuntu-latest
needs: [build, install-runsim]
needs: [build, install-runsim, diff]
steps:
- uses: actions/setup-go@v2-beta
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,21 @@ jobs:
steps:
- uses: actions/setup-go@v2-beta
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v1
id: git_diff
with:
SUFFIX_FILTER: |
.go
.mod
.sum
- name: build
run: |
make build
if: "env.GIT_DIFF != ''"
- name: test & coverage report creation
run: |
go test ./... -mod=readonly -timeout 12m -race -coverprofile=coverage.txt -covermode=atomic -tags='ledger test_ledger_mock'
if: "env.GIT_DIFF != ''"
- name: filter out DONTCOVER
run: |
excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')"
Expand All @@ -34,7 +43,9 @@ jobs:
echo "Excluding ${filename} from coverage report..."
sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt
done
if: "env.GIT_DIFF != ''"
- uses: codecov/codecov-action@v1
with:
file: ./coverage.txt # optional
fail_ci_if_error: true
if: "env.GIT_DIFF != ''"
25 changes: 16 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ contributors, the general procedure for contributing has been established:
4. Follow standard Github best practices: fork the repo, branch from the
HEAD of `master`, make some commits, and submit a PR to `master`
- For core developers working within the cosmos-sdk repo, to ensure a clear
ownership of branches, branches must be named with the convention
`{moniker}/{issue#}-branch-name`
ownership of branches, branches must be named with the convention
`{moniker}/{issue#}-branch-name`
5. Be sure to submit the PR in `Draft` mode submit your PR early, even if
it's incomplete as this indicates to the community you're working on
something and allows them to provide comments early in the development process
Expand Down Expand Up @@ -124,7 +124,7 @@ Please don't make Pull Requests from `master`.

## Dependencies

We use [Go 1.11 Modules](https://github.com/golang/go/wiki/Modules) to manage
We use [Go 1.14 Modules](https://github.com/golang/go/wiki/Modules) to manage
dependency versions.

The master branch of every Cosmos repository should just build with `go get`,
Expand All @@ -134,6 +134,14 @@ get away with telling people they can just `go get` our software.
Since some dependencies are not under our control, a third party may break our
build, in which case we can fall back on `go mod tidy -v`.

## Protobuf

We use [Protocol Buffers](https://developers.google.com/protocol-buffers) along with [gogoproto](https://github.com/gogo/protobuf) to generate code for use in Cosmos-SDK.

For linting and checking breaking changes, we use [buf](https://buf.build/). There are two options for linting and to check if your changes will cause a break. The first is that you can install [buf](https://buf.build/docs/installation) locally, the commands for running buf after installing are `make proto-lint` and the breaking changes check will be `make proto-check-breaking`. If you do not want to install buf and have docker installed already then you can use these commands `make proto-lint-docker` and `make proto-check-breaking-docker`.

To generate the protobuf stubs you must have `protoc` and `protoc-gen-gocosmos` installed. To install these tools run `make protoc` & `make protoc-gen-gocosmos`. After this step you will be able to run `make proto-gen` to generate the protobuf stubs.

## Testing

All repos should be hooked up to [CircleCI](https://circleci.com/).
Expand Down Expand Up @@ -232,11 +240,11 @@ releases will be based off of that release.
- create a PR into `master` containing ONLY the CHANGELOG.md updates
- tag and release `release/vX.XX.X`
## Code Owner Membership
## Code Owner Membership
In the ethos of open source projects, and out of necessity to keep the code
alive, the core contributor team will strive to permit special repo privileges
to developers who show an aptitude towards developing with this code base.
to developers who show an aptitude towards developing with this code base.
Several different kinds of privileges may be granted however most common
privileges to be granted are merge rights to either part of, or the entire the
Expand All @@ -247,17 +255,16 @@ potential new candidates as well as the potential for existing code-owners to
exit or "pass on the torch". This private meeting is to be a held as a
phone/video meeting. Subsequently at the end of the meeting, one of the existing
code owners should open a PR modifying the `CODEOWNERS` file. The other code
owners should then all approve this PR to publicly display their support.
owners should then all approve this PR to publicly display their support.
Only if unanimous consensus is reached among all the existing code-owners will
an invitation be extended to a new potential-member. Likewise, when an existing
member is suggested to be removed/or have their privileges reduced, the member
in question must agree on the decision for their removal or else no action
should be taken. If however, a code-owner is verifiably shown to intentionally
have had acted maliciously or grossly negligent, code-owner privileges may be
stripped with no prior warning or consent from the member in question.
stripped with no prior warning or consent from the member in question.
Earning this privilege should be considered to be no small feat and is by no
means guaranteed by any quantifiable metric. It is a symbol of great trust of
the community of this project.
the community of this project.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ LEDGER_ENABLED ?= true
BINDIR ?= $(GOPATH)/bin
SIMAPP = ./simapp
MOCKS_DIR = $(CURDIR)/tests/mocks
HTTPS_GIT := https://github.com/cosmos/cosmos-sdk.git
DOCKER_BUF := docker run -v $(shell pwd):/workspace --workdir /workspace bufbuild/buf

export GO111MODULE = on

Expand Down Expand Up @@ -255,6 +257,14 @@ proto-lint:
proto-check-breaking:
@buf check breaking --against-input '.git#branch=master'

proto-lint-docker:
@$(DOCKER_BUF) check lint --error-format=json
.PHONY: proto-lint

proto-check-breaking-docker:
@$(DOCKER_BUF) check breaking --against-input $(HTTPS_GIT)#branch=master
.PHONY: proto-check-breaking-ci

TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.33.1
GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
COSMOS_PROTO_URL = https://raw.githubusercontent.com/regen-network/cosmos-proto/master
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ parent:
[![license](https://img.shields.io/github/license/cosmos/cosmos-sdk.svg)](https://github.com/cosmos/cosmos-sdk/blob/master/LICENSE)
[![LoC](https://tokei.rs/b1/github/cosmos/cosmos-sdk)](https://github.com/cosmos/cosmos-sdk)
[![API Reference](https://godoc.org/github.com/cosmos/cosmos-sdk?status.svg)](https://godoc.org/github.com/cosmos/cosmos-sdk)
[![Discord chat](https://img.shields.io/discord/669268347736686612.svg)](https://discord.gg/AzefAFd)

The Cosmos-SDK is a framework for building blockchain applications in Golang.
It is being used to build [`Gaia`](https://github.com/cosmos/gaia), the first implementation of the Cosmos Hub.
Expand Down
4 changes: 2 additions & 2 deletions codec/testdata/proto.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ message Dog {
}

message Cat {
string moniker = 1;
int32 lives = 2;
string moniker = 1;
int32 lives = 2;
}

0 comments on commit 4b3eb0e

Please sign in to comment.