Skip to content

Commit

Permalink
Merge branch 'main' into make-format
Browse files Browse the repository at this point in the history
  • Loading branch information
loloicci committed Sep 11, 2023
2 parents c5f7139 + 880ef9d commit 85847d5
Show file tree
Hide file tree
Showing 33 changed files with 789 additions and 664 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-generated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: '1.20'

- uses: actions/checkout@v3
with:
Expand Down
185 changes: 185 additions & 0 deletions .github/workflows/ci-smart-contract.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
name: Smart Contract CI
# Smart Contract CI workflow runs CI test for checking if smart contract works well
# This workflow is run on pushes to main & every Pull Requests where a .go, .mod, .sum, ci_test/**.sh, and this file have been changed
on:
pull_request:
push:
branches:
- main

env:
TEST_DOCKER_IMAGE: finschianode:smartcontractci

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/main'"

check-diffs:
runs-on: ubuntu-latest
outputs:
get_diff: ${{ steps.diff.outputs.diff }}
steps:
- uses: actions/checkout@v3
- name: Get diff
id: diff
uses: technote-space/get-diff-action@v6.1.2
with:
PATTERNS: |
**/**.go
go.mod
go.sum
.github/workflows/ci-smart-contract.yml
ci_test/**
get-cosmwasm-releases:
runs-on: ubuntu-latest
outputs:
cosmwasm_versions: ${{ steps.releases.outputs.versions }}
steps:
- uses: actions/checkout@v3
- name: Get cosmwasm releases
id: releases
run: |
response=$(curl -s "https://api.github.com/repos/Finschia/cosmwasm/releases")
versions=$(echo "$response" | jq -r '[.[].tag_name]' | jq -c .)
echo "versions=${versions}" >> "$GITHUB_OUTPUT"
build:
runs-on: ubuntu-latest
needs: check-diffs
if: ${{ needs.check-diffs.outputs.get_diff }}
strategy:
matrix:
go-arch: ["amd64"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
- name: Build
run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build
- name: Upload build
uses: actions/upload-artifact@v3
with:
name: fnsad
path: ./build/fnsad

test-smart-contract-on-local-node:
runs-on: ubuntu-latest
needs: [build, get-cosmwasm-releases]
strategy:
fail-fast: false
matrix:
versions: ${{ fromJson(needs.get-cosmwasm-releases.outputs.cosmwasm_versions) }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
- name: Download smart contracts
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: 'Finschia/cosmwasm'
version: tags/${{ matrix.versions }}
regex: true
file: '.*'
target: 'contracts/'
- name: Download build
uses: actions/download-artifact@v3
with:
name: fnsad
path: ./build
- name: Build install
run: make install
- name: Set configure file
run: ./init_single.sh
shell: bash
# sleep 1 second to wait for finschia to start up
- name: Start local node
id: start
run: |
fnsad start &
sleep 1
- name: CI test
run: bash ./ci_test/queue_ci.sh
shell: bash
- name: Stop local node
if: ${{ always() && steps.start.conclusion == 'success' }}
run: kill $(ps -ef | grep "fnsad start" | grep -v grep | awk '{print $2}')

build-finschia-docker-image:
runs-on: ubuntu-latest
needs: check-diffs
if: ${{ needs.check-diffs.outputs.get_diff }}
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- name: Build and export
uses: docker/build-push-action@v4
with:
file: Dockerfile
context: .
tags: ${{ env.TEST_DOCKER_IMAGE }}
outputs: type=docker,dest=/tmp/finschia-ci-test.tar
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: finschia-ci-test
path: /tmp/finschia-ci-test.tar

test-smart-contract-in-docker-container:
runs-on: ubuntu-latest
needs: [build-finschia-docker-image, get-cosmwasm-releases]
strategy:
fail-fast: false
matrix:
versions: ${{ fromJson(needs.get-cosmwasm-releases.outputs.cosmwasm_versions) }}
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- name: Download smart contracts
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: 'Finschia/cosmwasm'
version: tags/${{ matrix.versions }}
regex: true
file: '.*'
target: 'contracts/'
- name: Download docker image
uses: actions/download-artifact@v3
with:
name: finschia-ci-test
path: /tmp
- name: Load image
run: |
docker load --input /tmp/finschia-ci-test.tar
docker image ls -a
- name: Set configure file
run: |
export FNSAD="docker run -i --rm -p 26656:26656 -p 26657:26657 -v ${pwd}/.finschia:/root/.finschia ${{ env.TEST_DOCKER_IMAGE }} fnsad"
./init_single.sh
shell: bash
# sleep 5 seconds to wait for finschia to start up
- name: Start docker container
id: docker_start
run: |
container_id=$(docker run -d \
-p 26656:26656 -p 26657:26657 \
-v ${pwd}/.finschia:/root/.finschia \
-v $(pwd)/ci_test:/root/ci_test \
-v $(pwd)/contracts:/root/contracts \
${{ env.TEST_DOCKER_IMAGE }} fnsad start)
echo "container_id=$container_id" >> "$GITHUB_OUTPUT"
sleep 5
- name: CI test
run: |
docker exec ${{ steps.docker_start.outputs.container_id }} apk add --no-cache jq bash && \
docker exec ${{ steps.docker_start.outputs.container_id }} bash ./ci_test/queue_ci.sh
- name: Stop docker container
if: ${{ always() && steps.docker_start.conclusion == 'success' }}
run: docker stop ${{ steps.docker_start.outputs.container_id }}
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
go.sum
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: '1.20'
- uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.47.0
version: v1.51
args: --timeout 10m
github-token: ${{ secrets.GITHUB_TOKEN }}
if: env.GIT_DIFF
2 changes: 1 addition & 1 deletion .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:

- name: Compile finschia
run: |
make build-reproducible-${{ matrix.arch }}
make build-reproducible ARCH=${{ matrix.arch }}
cd ./build
mv fnsad-linux-${{ matrix.arch }} fnsad-${{ env.ID }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/sims.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: '1.20'
- name: Display go version
run: go version
- run: make build
Expand All @@ -35,7 +35,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: '1.20'
- name: Display go version
run: go version
- name: Install runsim
Expand All @@ -52,7 +52,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: '1.20'
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v6.1.2
Expand All @@ -78,7 +78,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: '1.20'
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v6.1.2
Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: '1.20'
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v6.1.2
Expand Down Expand Up @@ -134,7 +134,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: '1.20'
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v6.1.2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: '1.20'
- name: Create release
uses: goreleaser/goreleaser-action@v4
with:
Expand Down
40 changes: 10 additions & 30 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: '1.20'
- name: Display go version
run: go version
- name: install tparse
Expand All @@ -41,7 +41,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: '1.20'
- uses: technote-space/get-diff-action@v6.1.2
with:
PATTERNS: |
Expand All @@ -59,7 +59,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: '1.20'
- name: Create a file with all the pkgs
run: go list ./... > pkgs.txt
- name: Split pkgs into 4 files
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: '1.20'
- uses: technote-space/get-diff-action@v6.1.2
with:
PATTERNS: |
Expand All @@ -108,16 +108,9 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -y build-essential libtool autoconf automake
- name: install libsodium
run: |
make libsodium
if: env.GIT_DIFF
- name: test & coverage report creation
env:
CGO_CFLAGS: "-I${{ github.workspace }}/tools/sodium/linux_amd64/include"
CGO_LDFLAGS: "-L${{ github.workspace }}/tools/sodium/linux_amd64/lib -lsodium"
run: |
cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 30m -coverprofile=${{ matrix.part }}profile.out -covermode=atomic -tags='ledger test_ledger_mock goleveldb gcc libsodium'
cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 30m -coverprofile=${{ matrix.part }}profile.out -covermode=atomic -tags='ledger test_ledger_mock goleveldb gcc'
if: env.GIT_DIFF
- uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -184,7 +177,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: '1.20'
- uses: technote-space/get-diff-action@v6.1.2
with:
PATTERNS: |
Expand All @@ -199,16 +192,9 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -y build-essential libtool autoconf automake
- name: install libsodium
run: |
make libsodium
if: env.GIT_DIFF
- name: test & coverage report creation
env:
CGO_CFLAGS: "-I${{ github.workspace }}/tools/sodium/linux_amd64/include"
CGO_LDFLAGS: "-L${{ github.workspace }}/tools/sodium/linux_amd64/lib -lsodium"
run: |
xargs --arg-file=pkgs.txt.part.${{ matrix.part }} go test -mod=readonly -json -timeout 30m -tags='cli_test goleveldb gcc libsodium' | tee ${{ matrix.part }}-integration-output.txt
xargs --arg-file=pkgs.txt.part.${{ matrix.part }} go test -mod=readonly -json -timeout 30m -tags='cli_test goleveldb gcc' | tee ${{ matrix.part }}-integration-output.txt
if: env.GIT_DIFF
- uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -264,7 +250,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: '1.20'
- uses: technote-space/get-diff-action@v6.1.2
with:
PATTERNS: |
Expand All @@ -279,15 +265,9 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -y build-essential libtool autoconf automake
- name: install libsodium
run: make libsodium
if: env.GIT_DIFF
- name: test report creation
env:
CGO_CFLAGS: "-I${{ github.workspace }}/tools/sodium/linux_amd64/include"
CGO_LDFLAGS: "-L${{ github.workspace }}/tools/sodium/linux_amd64/lib -lsodium"
run: |
xargs --arg-file=pkgs.txt.part.${{ matrix.part }} go test -mod=readonly -json -timeout 30m -tags='cli_multi_node_test goleveldb libsodium' | tee ${{ matrix.part }}-integration-multi-node-output.txt
xargs --arg-file=pkgs.txt.part.${{ matrix.part }} go test -mod=readonly -json -timeout 30m -tags='cli_multi_node_test goleveldb' | tee ${{ matrix.part }}-integration-multi-node-output.txt
if: env.GIT_DIFF
- uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -339,7 +319,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: '1.20'
- name: Install docker-compose
run: sudo apt-get update && sudo apt-get install -y docker-compose
- name: Start localnet
Expand Down
Loading

0 comments on commit 85847d5

Please sign in to comment.