Skip to content

Commit

Permalink
build(tooling): DEV-1096 Improve CI/CD pipelines for release process (#…
Browse files Browse the repository at this point in the history
…304)

* Only run one instance of linter for specific ref
* Bump Checkout action version
* Remove broken timeout argument
* Made style consistent throughout Lint action
* Create dispatcher workflow
* Splitting out build
* Fix YAML formatting errors
* Remove wait on lint
* Specify Go version for linting
* Make Ubuntu version consistent
* Change test.yml to build.yml
* Restore Go setup
* Combine build tarball and Debian into single job
* Added Github CodeQL Action
* DEV-1237 Fix issues with build and test workflows (#309)
* Deactivate lint and release workflows
* Remove set pipefail for workflow
* Use script to check for validator status instead of inline GitHub Actions
* Fix release tagging
* Remove unused script
* Fix variable passing
* FInal release test

Co-authored-by: Ankur Banerjee <[email protected]>
Co-authored-by: jay-dee7 <[email protected]>
  • Loading branch information
3 people authored Apr 12, 2022
1 parent 75ee782 commit 66352a4
Show file tree
Hide file tree
Showing 15 changed files with 359 additions and 525 deletions.
130 changes: 130 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: "Build"
on:
workflow_call:
outputs:
VERSION:
description: "Build version number"
value: ${{ jobs.build-binary.outputs.VERSION }}
defaults:
run:
shell: bash


jobs:
go-unit-tests:
name: "Golang unit tests"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.17'

- name: Run Golang unit tests
run: go test -v ./...

build-binary:
name: "Node binary"
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.set-version.outputs.VERSION }}

steps:
- uses: actions/setup-go@v3
with:
go-version: '1.17'

- name: Fetch Golang protoc compiler plugins
env:
GOLANG_PROTOBUF_VERSION: 1.3.5
GOGO_PROTOBUF_VERSION: 1.3.2
GRPC_GATEWAY_VERSION: 1.14.7
# Taken from: tendermintdev/sdk-proto-gen:v0.2
run: |
go get \
github.com/golang/protobuf/protoc-gen-go@v"$GOLANG_PROTOBUF_VERSION" \
github.com/gogo/protobuf/protoc-gen-gogo@v"$GOGO_PROTOBUF_VERSION" \
github.com/gogo/protobuf/protoc-gen-gogofast@v"$GOGO_PROTOBUF_VERSION" \
github.com/gogo/protobuf/protoc-gen-gogofaster@v"$GOGO_PROTOBUF_VERSION" \
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v"$GRPC_GATEWAY_VERSION" \
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v"$GRPC_GATEWAY_VERSION" \
github.com/regen-network/cosmos-proto/protoc-gen-gocosmos@latest
- name: Install buf
env:
PREFIX: "/usr/local"
VERSION: "1.0.0-rc8"
run: |
curl -sSL "https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-$(uname -s)-$(uname -m).tar.gz" | \
sudo tar -xvzf - -C "${PREFIX}" --strip-components 1
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Required to fetch version

- name: Build node binary
run: |
make proto-gen build
- name: Store artifact
uses: actions/upload-artifact@v3
with:
name: cheqd-noded
path: build/cheqd-noded

- name: Set version number
id: set-version
run: |
VERSION=$(build/cheqd-noded version 2>&1)
echo ::set-output name=VERSION::"$VERSION"
- name: Install fpm
run: |
sudo apt-get install ruby ruby-dev rubygems build-essential
sudo gem install --no-document fpm
- name: Build Debian package
working-directory: ./build-tools
run: |
./build-deb.sh "../build/cheqd-noded"
- name: Store Debian package artifact
uses: actions/upload-artifact@v3
env:
VERSION: ${{ steps.set-version.outputs.VERSION }}
with:
name: cheqd-node_${{ env.VERSION }}_amd64.deb
path: build-tools/output/cheqd-node_${{ env.VERSION }}_amd64.deb

build-docker-images:
name: "Docker images"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Required to fetch version

- name: Build cheqd-cli Docker image 'cheqd-noded' as entrypoint
# TODO: Get rid of UID and GID
run: docker build --target base -t cheqd-cli -f docker/Dockerfile --build-arg UID="$(id -u)" --build-arg GID="$(id -g)" .

- name: Build cheqd-node Docker image with 'node-start' as entrypoint
run: docker build --target node -t cheqd-node -f docker/Dockerfile --build-arg UID="$(id -u)" --build-arg GID="$(id -g)" .

- name: Save cheqd-cli Docker image
run: docker save -o cheqd-cli-image.tar cheqd-cli

- name: Store cheqd-cli artifact
uses: actions/upload-artifact@v3
with:
name: cheqd-cli-image.tar
path: cheqd-cli-image.tar

- name: Save cheqd-node Docker image
run: docker save -o cheqd-node-image.tar cheqd-node

- name: Store cheqd-node artifact
uses: actions/upload-artifact@v3
with:
name: cheqd-node-image.tar
path: cheqd-node-image.tar
25 changes: 23 additions & 2 deletions .github/workflows/dispatch.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
name: "Workflow Dispatch"
on: push
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on: [ push, workflow_dispatch ]

jobs:

call-lint:
name: "Lint"
uses: ./.github/workflows/lint.yml

call-test:
call-build:
name: "Build"
needs: call-lint
uses: ./.github/workflows/build.yml

call-test:
name: "Test"
needs: call-build
uses: ./.github/workflows/test.yml
with:
VERSION: ${{ needs.call-build.outputs.VERSION }}

call-release:
name: "Release"
needs: [call-test, call-build]
if: startsWith(github.ref, 'refs/tags/v')
uses: ./.github/workflows/release.yml
with:
RELEASE_VERSION: ${{ needs.call-build.outputs.VERSION }}
57 changes: 33 additions & 24 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,64 @@
name: Lint
name: "Lint"
on: workflow_call
defaults:
run:
shell: bash
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


jobs:

sh-euox-pipefail-check:
name: "Lint: Check for 'set -euox pipefail' in shell scripts"
name: "Shell pipefail check"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Check that all shell scripts use 'set -euox pipefail'
run: bash .github/scripts/ensure_set_euox_pipefail.sh

# We can't use VALIDATE_GO from super linter because of this issue:
# https://github.com/github/super-linter/issues/143
go-lint:
name: "Lint: Golang"
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: latest
args: --timeout 5m0s

- name: Run 'set -euox pipefail' check
run: bash ./.github/scripts/ensure_set_euox_pipefail.sh

md-link-check:
name: "Lint: Check for broken Markdown links"
name: "Broken Markdown links"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Check if Markdown links are valid

- name: Run Markdown link check
uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
config-file: '.github/linters/mlc_config.json'
use-quiet-mode: 'yes'
use-verbose-mode: 'yes'

go-lint:
# We can't use VALIDATE_GO from super linter because of this issue:
# https://github.com/github/super-linter/issues/143
name: "Golang"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3
with:
go-version: '1.17'

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: latest
args: --timeout 5m0s

super-lint:
name: "Lint: Super Linter"
name: "Super Linter"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Required to fetch version

- name: Run Super Linter
uses: github/super-linter/slim@v4
env:
Expand Down
Loading

0 comments on commit 66352a4

Please sign in to comment.