forked from cosmos/ibc-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cosmos#903 from smuu/feature/ci-cd-setup
feat: CI/CD setup
- Loading branch information
Showing
8 changed files
with
216 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: CI and Release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
# Trigger on version tags | ||
tags: | ||
- 'v[0-9]+\.[0-9]+\.[0-9]+' | ||
- 'v[0-9]+\.[0-9]+\.[0-9]+-rc(?:[0-9]+|\.[0-9]+)' | ||
pull_request: | ||
workflow_dispatch: | ||
# Inputs the workflow accepts. | ||
inputs: | ||
version: | ||
# Friendly description to be shown in the UI instead of 'name' | ||
description: "Semver type of new version (major / minor / patch)" | ||
# Input has to be provided for the workflow to run | ||
required: true | ||
type: choice | ||
options: | ||
- patch | ||
- minor | ||
- major | ||
|
||
jobs: | ||
lint: | ||
uses: ./.github/workflows/lint.yml | ||
with: | ||
GO_VERSION: '1.20' | ||
|
||
test: | ||
uses: ./.github/workflows/test.yml | ||
with: | ||
GO_VERSION: '1.20' | ||
|
||
proto: | ||
uses: ./.github/workflows/proto.yml | ||
|
||
# Make a release if this is a manually trigger job, i.e. workflow_dispatch | ||
release: | ||
needs: [lint, test, proto] | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event_name == 'workflow_dispatch' }} | ||
permissions: "write-all" | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Version Release | ||
uses: celestiaorg/.github/.github/actions/version-release@v0.1.1 | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
version-bump: ${{inputs.version}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Check if the generated protobuf code matches the committed code | ||
name: Protobuf | ||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
proto-gen: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: "Check protobuf generated code matches committed code" | ||
# yamllint disable | ||
run: | | ||
set -euo pipefail | ||
make proto-gen | ||
if ! git diff --stat --exit-code ; then | ||
echo ">> ERROR:" | ||
echo ">>" | ||
echo ">> Protobuf generated code requires update (either tools or .proto files may have changed)." | ||
echo ">> Ensure your tools are up-to-date, re-run 'make proto-gen' and update this PR." | ||
echo ">>" | ||
exit 1 | ||
fi | ||
# yamllint enable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,74 @@ | ||
name: Build and Test | ||
# Tests / Code Coverage workflow | ||
# This workflow is triggered by ci_release.yml workflow | ||
name: Tests / Code Coverage | ||
on: | ||
push: | ||
tags: | ||
- v* | ||
branches: | ||
- main | ||
pull_request: | ||
jobs: | ||
workflow_call: | ||
inputs: | ||
GO_VERSION: | ||
description: 'Go version to use' | ||
type: string | ||
required: true | ||
|
||
build: | ||
jobs: | ||
go_mod_tidy_check: | ||
name: Go Mod Tidy Check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ inputs.GO_VERSION }} | ||
- run: go mod tidy | ||
- name: check for diff | ||
run: git diff --exit-code | ||
|
||
- name: Set up Go | ||
test_coverage: | ||
name: Unit Tests Coverage | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: set up go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.19 | ||
go-version: ${{ inputs.GO_VERSION }} | ||
- name: Test & Coverage | ||
run: make cover | ||
- uses: codecov/codecov-action@v3.1.3 | ||
with: | ||
file: ./coverage.txt | ||
|
||
- name: Build | ||
run: go build -v ./... | ||
unit_test: | ||
name: Run Unit Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: set up go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ inputs.GO_VERSION }} | ||
- name: execute test run | ||
run: make test-unit | ||
|
||
- name: Test & Coverage | ||
run: | | ||
go install github.com/ory/go-acc@v0.2.6 | ||
go-acc -o coverage.txt ./... -- -v --race | ||
unit_race_test: | ||
name: Run Unit Tests with Race Detector | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: set up go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ inputs.GO_VERSION }} | ||
- name: execute test run | ||
run: make test-unit-race | ||
|
||
- uses: codecov/codecov-action@v3 | ||
integration_test: | ||
name: Run Integration Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: set up go | ||
uses: actions/setup-go@v4 | ||
with: | ||
file: ./coverage.txt | ||
go-version: ${{ inputs.GO_VERSION }} | ||
- name: Integration Tests | ||
run: echo "No integration tests yet" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
coverage.txt | ||
proto/pb | ||
proto/tendermint | ||
types/pb/tendermint | ||
types/pb/tendermint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
DOCKER := $(shell which docker) | ||
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf | ||
|
||
## help: Show this help message | ||
help: Makefile | ||
@echo " Choose a command run in "$(PROJECTNAME)":" | ||
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /' | ||
.PHONY: help | ||
|
||
## cover: generate to code coverage report. | ||
cover: | ||
@echo "--> Generating Code Coverage" | ||
@go install github.com/ory/go-acc@latest | ||
@go-acc -o coverage.txt `go list ./...` | ||
.PHONY: cover | ||
|
||
## test-unit: Running unit tests | ||
test-unit: | ||
@echo "--> Running unit tests" | ||
@go test `go list ./...` | ||
.PHONY: test-unit | ||
|
||
## test-unit-race: Running unit tests with data race detector | ||
test-unit-race: | ||
@echo "--> Running unit tests with data race detector" | ||
@go test -race `go list ./...` | ||
.PHONY: test-unit-race | ||
|
||
## proto-gen: Generate protobuf files. Requires docker. | ||
proto-gen: | ||
@echo "--> Generating Protobuf files" | ||
./proto/get_deps.sh | ||
./proto/gen.sh | ||
.PHONY: proto-gen | ||
|
||
## proto-lint: Lint protobuf files. Requires docker. | ||
proto-lint: | ||
@echo "--> Linting Protobuf files" | ||
@$(DOCKER_BUF) lint --error-format=json | ||
.PHONY: proto-lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters