Skip to content

Commit

Permalink
DEV 841: Further docker, tests improvements (#280)
Browse files Browse the repository at this point in the history
* Restructure tests

* Remove libindy

* Remove docker-localnet image

* New docker compose draft

* Comment out build section

* Fix docker builds

* Working docker-compose based localnet

* Fix doc

* Fix localnet setup

* Fix image name

* Fix test paths

* Fix paths

* Fix paths

* Expose RPC ports

* Add docker version output

* Print docker compose version

* Docker compose version

* Revert docker compose version print

* Fix paths

* Make other steps to use compose based localnet

* Remove testnet image building and publishing

* Fix ports

* Comment external address

* Remove external address from localnet nodes

* Fix paths

* Get rid of configure mapping in docker entrypoint script

* Add api, consensus configuration to localnet

* Fix paths in the upgrade test

* Fix linter issues

* For the previous commit

* Make container.env to utilize cosmos native env vars

* Revert unnecessary changes

* Add new line at the EOF

* Remove remainings of the testnet image

* Extract env vars of testnet into separate files

* Fix images publishing

* Move import-keys script to localnet

* Set default minimum gas prices for localnet

* Set CREATE_EMPTY_BLOCKS to false

* Replace PAT with GITHUB_TOKEN

* Fix registry name in release pipeline

* Add missing seed_mode

* Fix panic in case of invalid key format (#284)

Co-authored-by: Ankur Banerjee <[email protected]>
Signed-off-by: Andrew Nikitin <[email protected]>
  • Loading branch information
2 people authored and Andrew Nikitin committed Feb 28, 2022
1 parent 18f34d0 commit 5f7b8fb
Show file tree
Hide file tree
Showing 66 changed files with 1,097 additions and 602 deletions.
198 changes: 70 additions & 128 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,12 @@ on:
- "v*"

jobs:
setup-workflow:
name: "Setup workflow"
runs-on: ubuntu-latest
outputs:
GITHUB_REPOSITORY_NAME: ${{ steps.cache.outputs.GITHUB_REPOSITORY_NAME }}
GITHUB_ORG_NAME: ${{ steps.cache.outputs.GITHUB_ORG_NAME }}
TAG: ${{ steps.cache.outputs.TAG }}
VERSION: ${{ steps.cache.outputs.VERSION }}
steps:
- name: Git checkout
uses: actions/checkout@v2

- name: Set outputs
id: cache
run: |
# Exposes org_name in lower case. Required by Docker.
echo "::set-output name=GITHUB_ORG_NAME::$(echo ${GITHUB_REPOSITORY_OWNER,,})"
# Exposes org_name/repository_name in lower case. Required by Docker.
echo "::set-output name=GITHUB_REPOSITORY_NAME::$(echo ${GITHUB_REPOSITORY,,})"
# Version is tag without `v` prefix. Required by Debian package.
TAG=${GITHUB_REF/refs\/tags\//}
echo "::set-output name=TAG::$TAG"
VERSION="${TAG:1}" # Remove first character
echo "::set-output name=VERSION::$VERSION"

build-binary:
name: Build binary
runs-on: ubuntu-20.04
outputs:
VERSION: ${{ steps.set-version.outputs.VERSION }}
steps:
- name: Set up Go 1.17
uses: actions/setup-go@v2
Expand All @@ -58,141 +33,129 @@ jobs:
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@v2
with:
fetch-depth: 0 # Required to fetch version

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

build-deb-package:
name: Build Debian package
- name: Set version
id: set-version
run: |
VERSION=$(build/cheqd-noded version 2>&1)
echo "::set-output name=VERSION::$VERSION"
build-tar-package:
name: Build tar package
runs-on: ubuntu-20.04
needs: [ build-binary, setup-workflow ]
needs: build-binary
env:
PACKAGE_NAME: "cheqd-node"
VERSION: ${{ needs.setup-workflow.outputs.VERSION }}
VERSION: ${{ needs.build-binary.outputs.VERSION }}
steps:
- uses: actions/checkout@v2

- name: Load binary artifact
uses: actions/download-artifact@v2
with:
name: cheqd-noded
path: /home/runner/go/bin

- name: Restore binary permissions
run: sudo chmod +x /home/runner/go/bin/cheqd-noded
run: sudo chmod +x cheqd-noded

- name: Make intermediate archive
- name: Build tar
working-directory: ./build-tools
run: |
./build-tar.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }}
./build-tar.sh "../cheqd-noded"
- name: Store tar package artifact
uses: actions/upload-artifact@v2
with:
name: cheqd-node_${{ env.VERSION }}.tar.gz
path: build-tools/output/cheqd-node_${{ env.VERSION }}.tar.gz

build-deb-package:
name: Build Debian package
runs-on: ubuntu-20.04
needs: [ build-binary ]
env:
VERSION: ${{ needs.build-binary.outputs.VERSION }}
steps:
- uses: actions/checkout@v2

- name: Load binary artifact
uses: actions/download-artifact@v2
with:
name: cheqd-noded

- name: Restore binary permissions
run: sudo chmod +x cheqd-noded

- name: Install fpm
run: |
sudo apt-get install ruby ruby-dev rubygems build-essential
sudo gem install --no-document fpm
- name: Build Debian package # Depends on tar archive
- name: Build deb
working-directory: ./build-tools
run: |
./build-deb.sh ${{ env.PACKAGE_NAME }} ${{ env.VERSION }}
./build-deb.sh "../cheqd-noded"
- name: Store Debian package artifact
uses: actions/upload-artifact@v2
with:
name: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb
path: build-tools/output/${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb
name: cheqd-node_${{ env.VERSION }}_amd64.deb
path: build-tools/output/cheqd-node_${{ env.VERSION }}_amd64.deb

build-node-image:
name: Build cheqd-node Docker image
build-node-images:
name: Build cheqd-node and cheqd-cli images
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # FIXME: Starport requires full repository
fetch-depth: 0 # Required to fetch version

- name: Build cheqd-cli with 'cheqd-noded' as entrypoint
run: docker build --target base -t cheqd-cli -f docker/Dockerfile --build-arg UID=$(id -u) --build-arg GID=$(id -g) .
run: docker build --target base -t cheqd-cli -f docker/Dockerfile .

- name: Build cheqd-node 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) .
run: docker build --target node -t cheqd-node -f docker/Dockerfile .

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

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

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

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

build-testnet-image:
name: Build cheqd-testnet image
runs-on: ubuntu-20.04
needs: build-node-image
steps:
- name: Check out
uses: actions/checkout@v2

- name: Download node image
uses: actions/download-artifact@v2
with:
name: cheqd-cli-image.tar

- name: Load node image
run: docker load -i cheqd-cli-image.tar

- name: Build
run: docker build -f tests/networks/docker-localnet/Dockerfile --no-cache -t cheqd-testnet .

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

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

publish:
name: "Publish images and release"
# Reference to workflow-setup job is required to access its various outputs.
needs: [ setup-workflow, build-node-image, build-testnet-image, build-deb-package ]
needs: [ build-binary, build-node-images, build-deb-package, build-tar-package ]
runs-on: ubuntu-latest
env:
GITHUB_REPOSITORY_NAME: ${{ needs.setup-workflow.outputs.GITHUB_REPOSITORY_NAME }}
GITHUB_ORG_NAME: ${{ needs.setup-workflow.outputs.GITHUB_ORG_NAME }}
TAG: ${{ needs.setup-workflow.outputs.TAG }}
VERSION: ${{ needs.setup-workflow.outputs.VERSION }}
PACKAGE_NAME: "cheqd-node"
TESTNET_IMAGE_NAME: "cheqd-testnet"
VERSION: ${{ needs.build-binary.outputs.VERSION }}
REGISTRY: ghcr.io
steps:
- name: Git checkout
uses: actions/checkout@v2
Expand All @@ -213,61 +176,40 @@ jobs:
- name: Load cheqd-node image
run: docker load -i cheqd-node-image.tar

- name: Download testnet image
uses: actions/download-artifact@v2
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
name: cheqd-testnet-image.tar

- name: Load testnet image
run: docker load -i cheqd-testnet-image.tar

- name: Login to docker
run: |
echo ${{ secrets.GH_PAT }} | docker login ghcr.io --username ${{ secrets.GH_USER }} --password-stdin
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push cheqd-node image
run: |
docker tag cheqd-node ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:${{ env.VERSION }}
docker tag cheqd-node ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:latest
docker push ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:${{ env.VERSION }}
docker push ghcr.io/${{ env.GITHUB_REPOSITORY_NAME }}:latest
docker tag cheqd-node ghcr.io/${{ github.repository }}:${{ env.VERSION }}
docker tag cheqd-node ghcr.io/${{ github.repository }}:latest
docker push ghcr.io/${{ github.repository }}:${{ env.VERSION }}
docker push ghcr.io/${{ github.repository }}:latest
- name: Push cheqd-cli image
run: |
docker tag cheqd-cli ghcr.io/${{ env.GITHUB_ORG_NAME }}/cheqd-cli:${{ env.VERSION }}
docker tag cheqd-cli ghcr.io/${{ env.GITHUB_ORG_NAME }}/cheqd-cli:latest
docker push ghcr.io/${{ env.GITHUB_ORG_NAME }}:${{ env.VERSION }}
docker push ghcr.io/${{ env.GITHUB_ORG_NAME }}:latest
- name: Push testnet image
run: |
docker tag cheqd-testnet ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:${{ env.VERSION }}
docker tag cheqd-testnet ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:latest
docker push ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:${{ env.VERSION }}
docker push ghcr.io/${{ github.repository_owner }}/${{ env.TESTNET_IMAGE_NAME }}:latest
docker tag cheqd-cli ghcr.io/${{ github.repository_owner }}/cheqd-cli:${{ env.VERSION }}
docker tag cheqd-cli ghcr.io/${{ github.repository_owner }}/cheqd-cli:latest
docker push ghcr.io/${{ github.repository_owner }}/cheqd-cli:${{ env.VERSION }}
docker push ghcr.io/${{ github.repository_owner }}/cheqd-cli:latest
- name: Download deb
uses: actions/download-artifact@v2
with:
name: ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb
name: cheqd-node_${{ env.VERSION }}_amd64.deb

- name: Load binary artifact
- name: Download tar
uses: actions/download-artifact@v2
with:
name: cheqd-noded

- name: Restore binary permissions
run: sudo chmod +x cheqd-noded

- name: Make tar archive
run: tar -zcvf ${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz cheqd-noded
name: cheqd-node_${{ env.VERSION }}.tar.gz

- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ env.TAG }}"
automatic_release_tag: "${{ env.GITHUB_REF_NAME }}"
prerelease: true
files: |
${{ env.PACKAGE_NAME }}_${{ env.VERSION }}_amd64.deb
${{ env.PACKAGE_NAME }}_${{ env.VERSION }}.tar.gz
cheqd-node_${{ env.VERSION }}_amd64.deb
cheqd-node_${{ env.VERSION }}.tar.gz
Loading

0 comments on commit 5f7b8fb

Please sign in to comment.