Skip to content

Commit

Permalink
staking contracts transition to secret cosmwasm
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishek-1857 committed Dec 26, 2023
0 parents commit b6a858e
Show file tree
Hide file tree
Showing 788 changed files with 184,654 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[alias]
wasm = "build --release --lib --target wasm32-unknown-unknown"
wasm-debug = "build --lib --target wasm32-unknown-unknown"
all-test = "test --workspace"
unit-test = "test --lib"
integration-test = "test --package integration-tests -- --ignored --test-threads 1 -Z unstable-options --report-time"
test-tube = "test --features test-tube"

[env]
RUSTFLAGS = "-C link-arg=-s"
12 changes: 12 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Cargo audit
on:
schedule:
- cron: '0 0 * * *'
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
78 changes: 78 additions & 0 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Based on https://github.com/actions-rs/example/blob/master/.github/workflows/quickstart.yml

on: [push, pull_request]

name: Basic

jobs:
test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install latest stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: wasm32-unknown-unknown
override: true

- name: Run tests
uses: actions-rs/cargo@v1
with:
toolchain: stable
command: all-test
args: --locked
env:
RUST_BACKTRACE: 1

- name: Compile WASM contract
uses: actions-rs/cargo@v1
with:
toolchain: stable
command: wasm
args: --locked
env:
RUSTFLAGS: "-C link-arg=-s"

lints:
name: Lints
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
toolchain: stable
command: fmt
args: --all -- --check

- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
toolchain: stable
command: clippy
args: --all-targets -- -D warnings

- name: Generate Schema
run: ./scripts/schema.sh

- name: Show Schema changes
run: git status --porcelain

- name: Schema Changes
# fails if any changes not committed
run: test -z "$(git status --porcelain)"
35 changes: 35 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# From: https://github.com/codecov/example-rust/blob/main/.github/workflows/rust.yml
name: Coverage

on:
- push

env:
CARGO_TERM_COLOR: always

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: llvm-tools-preview
- name: cargo install cargo-llvm-cov
run: cargo install cargo-llvm-cov
- name: cargo llvm-cov
run: cargo llvm-cov --workspace --lcov --output-path lcov.info
- name: Codecov
# You may pin to the exact commit or the version.
# uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378
uses: codecov/codecov-action@v3
with:
# Repository upload token - get it from codecov.io. Required only for private repositories
# token: # optional
# Specify whether the Codecov output should be verbose
verbose: true
fail_ci_if_error: true
101 changes: 101 additions & 0 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Integration Tests

on:
pull_request:
push:
branches:
- main

jobs:
test:
name: Integration tests
runs-on: ubuntu-latest
env:
GAS_OUT_DIR: gas_reports
GAS_LIMIT: 100000000
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install latest nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2023-02-02
target: wasm32-unknown-unknown
override: true

- name: Rust Dependencies Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
artifacts/
key: ${{ runner.os }}-cargo-with-artifacts-${{ hashFiles('**/Cargo.lock') }}

- name: Set latest just version
run: echo "JUST_VERSION=$(cargo search just -q | sed -n -e '/^just[[:space:]]/p' | cut -d '"' -f 2)" >> $GITHUB_ENV

- name: Get cached just
uses: actions/cache@v3
with:
path: ~/.cargo/bin/just
key: ${{ runner.os }}-just-${{ env.JUST_VERSION }}

- name: Install just
run: cargo install just || true

- name: Get mainnet GAS_LIMIT
run: echo "MAINNET_GAS_LIMIT=$(curl -s https://juno-rpc.polkachu.com/consensus_params | jq -r '.result.consensus_params.block.max_gas')" >> $GITHUB_ENV

- name: Mainnet block GAS_LIMIT changed
if: ${{ env.MAINNET_GAS_LIMIT != env.GAS_LIMIT }}
uses: actions/github-script@v6
with:
script: core.setFailed(`Integration tests must update GAS_LIMIT from ${process.env.GAS_LIMIT} to ${process.env.MAINNET_GAS_LIMIT}`)

- name: Run Integration Tests
run: just integration-test

- name: Combine Test Gas Reports
run: cd ci/integration-tests/ && jq -rs 'reduce .[] as $item ({}; . * $item)' gas_reports/*.json > gas_report.json

- name: Raw Gas Report
run: cat ci/integration-tests/gas_report.json

- name: Set GIT_BRANCH
run: echo "GIT_BRANCH=$(echo ${{ github.ref }} | sed 's|/|-|g')" >> $GITHUB_ENV

- name: Upload Gas Report
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/upload-artifact@v3
with:
name: dao-dao-gas-report-${{ env.GIT_BRANCH }}
path: ci/integration-tests/gas_report.json
retention-days: 90

- name: Download main gas report
id: download_gas
# Because the max retention period of github artifacts is 90 days
# there's a possibility the main's report no longer exists
continue-on-error: true
if: ${{ github.ref != 'refs/heads/main' }}
# NOTE: We can't use github's `actions/download-artifact` because it doesnt support
# downloading an artifact cross workflows yet
# https://github.com/actions/download-artifact/issues/3
uses: dawidd6/action-download-artifact@v2
with:
branch: main
workflow: integration_tests.yml
name: dao-dao-gas-report-refs-heads-main

- name: Post gas diff to PR
if: ${{ github.ref != 'refs/heads/main' && steps.download_gas.outputs.found_artifact == 'true' }}
uses: de-husk/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
current_json: ci/integration-tests/gas_report.json
old_json: gas_report.json
51 changes: 51 additions & 0 deletions .github/workflows/release-contracts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Release contracts

permissions:
contents: write

on:
push:
tags:
- 'v*'
branches:
- main
- ci/release-contracts

jobs:
release:
runs-on: ubuntu-latest
container: cosmwasm/workspace-optimizer:0.14.0
steps:
- uses: actions/checkout@v3

# tar is required for cargo cache
- run: apk add --no-cache tar

- name: Set up cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Compile contracts
timeout-minutes: 30
run: optimize_workspace.sh .

- name: Upload contracts
uses: actions/upload-artifact@v3
with:
name: contracts
path: artifacts/

- name: release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71 changes: 71 additions & 0 deletions .github/workflows/test_tube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Test Tube Tests

on:
pull_request:
push:
branches:
- main

jobs:
test:
name: Integration tests
runs-on: ubuntu-latest
env:
GAS_OUT_DIR: gas_reports
GAS_LIMIT: 100000000
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install latest nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2023-02-02
target: wasm32-unknown-unknown
override: true

- name: Setup Go
uses: actions/setup-go@v4

- name: Clone libwasmv (needed for test-tube)
uses: actions/checkout@v2
with:
repository: CosmWasm/wasmvm
path: ./wasmvm
ref: v1.4.1

- name: Install libwasmv
run: cd ./wasmvm && make build-rust && cd ../

- name: Rust Dependencies Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
artifacts/
key: ${{ runner.os }}-cargo-with-artifacts-${{ hashFiles('**/Cargo.lock') }}

- name: Set latest just version
run: echo "JUST_VERSION=$(cargo search just -q | sed -n -e '/^just[[:space:]]/p' | cut -d '"' -f 2)" >> $GITHUB_ENV

- name: Get cached just
uses: actions/cache@v3
with:
path: ~/.cargo/bin/just
key: ${{ runner.os }}-just-${{ env.JUST_VERSION }}

- name: Install just
run: cargo install just || true

- name: Run download deps
run: just download-deps

- name: Run workspace optimize
run: just workspace-optimize

- name: Run Test Tube Integration Tests
run: just test-tube
Loading

0 comments on commit b6a858e

Please sign in to comment.