Skip to content

Commit

Permalink
setup GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
epanchee committed Sep 18, 2023
1 parent c2c86bf commit 597b4e1
Show file tree
Hide file tree
Showing 5 changed files with 321 additions and 0 deletions.
120 changes: 120 additions & 0 deletions .github/workflows/check_artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Compiled binaries checks

on:
pull_request:
push:
branches:
- main

env:
CARGO_TERM_COLOR: always
CARGO_NET_GIT_FETCH_WITH_CLI: true

jobs:
fetch_deps:
name: Fetch cargo dependencies
runs-on: ubuntu-latest

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v3
- uses: webfactory/[email protected]
with:
ssh-private-key: |
${{ secrets.GOV_PRIVATE_KEY }}
${{ secrets.CORE_PRIVATE_KEY }}

- uses: actions/cache@v3
if: always()
with:
path: |
~/.cargo/bin
~/.cargo/git/checkouts
~/.cargo/git/db
~/.cargo/registry/cache
~/.cargo/registry/index
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- run: |
git config url."ssh://[email protected]/astroport-fi/hidden_astroport_governance.git".insteadOf "https://github.com/astroport-fi/hidden_astroport_governance"
git config url."ssh://[email protected]/astroport-fi/hidden_astroport_core.git".insteadOf "https://github.com/astroport-fi/hidden_astroport_core"

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.68.0
override: true

- name: Fetch cargo deps
uses: actions-rs/cargo@v1
with:
command: fetch
args: --locked

check-artifacts-size:
runs-on: ubuntu-latest
name: Check Artifacts Size
needs: fetch_deps
steps:
- name: Checkout sources
uses: actions/checkout@v3

- uses: actions/cache@v3
with:
path: |
~/.cargo/bin
~/.cargo/git/checkouts
~/.cargo/git/db
~/.cargo/registry/cache
~/.cargo/registry/index
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# docker can't pull private sources, so we fail if cache is missing
fail-on-cache-miss: true

- name: Build Artifacts
run: |
docker run \
-v "$GITHUB_WORKSPACE":/code \
-v ~/.cargo/registry:/usr/local/cargo/registry \
-v ~/.cargo/git:/usr/local/cargo/git \
cosmwasm/workspace-optimizer:0.12.13

- name: Save artifacts cache
uses: actions/cache/save@v3
with:
path: artifacts
key: ${{ runner.os }}-artifacts-${{ hashFiles('**/Cargo.lock') }}

- name: Check Artifacts Size
run: |
$GITHUB_WORKSPACE/scripts/check_artifacts_size.sh



cosmwasm-check:
runs-on: ubuntu-latest
name: Cosmwasm check
needs: check-artifacts-size
steps:
# We need this only to get Cargo.lock
- name: Checkout sources
uses: actions/checkout@v3
- name: Restore cached artifacts
uses: actions/cache/restore@v3
with:
path: artifacts
key: ${{ runner.os }}-artifacts-${{ hashFiles('**/Cargo.lock') }}
fail-on-cache-miss: true
- name: Install cosmwasm-check
# Uses --debug for compilation speed
run: cargo install --debug --version 1.4.0 cosmwasm-check
- name: Cosmwasm check
run: |
cosmwasm-check $GITHUB_WORKSPACE/artifacts/*.wasm --available-capabilities cosmwasm_1_1,iterator,stargate
66 changes: 66 additions & 0 deletions .github/workflows/code_coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Code coverage

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
CARGO_TERM_COLOR: always
CARGO_NET_GIT_FETCH_WITH_CLI: true

jobs:
code-coverage:
name: Code coverage
runs-on: ubuntu-latest

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- uses: webfactory/[email protected]
with:
ssh-private-key: |
${{ secrets.GOV_PRIVATE_KEY }}
${{ secrets.CORE_PRIVATE_KEY }}

- name: Checkout repository
uses: actions/checkout@v2
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin
~/.cargo/git/checkouts
~/.cargo/git/db
~/.cargo/registry/cache
~/.cargo/registry/index
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- run: |
git config url."ssh://[email protected]/astroport-fi/hidden_astroport_governance.git".insteadOf "https://github.com/astroport-fi/hidden_astroport_governance"
git config url."ssh://[email protected]/astroport-fi/hidden_astroport_core.git".insteadOf "https://github.com/astroport-fi/hidden_astroport_core"

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.68.0
override: true

- name: Run cargo-tarpaulin
uses: actions-rs/[email protected]
with:
version: '0.22.0'
args: '--exclude-files *tests*.rs -e astroport-osmo-e2e-tests'

- name: Upload to codecov.io
if: github.ref == 'refs/heads/main'
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}
fail_ci_if_error: true
37 changes: 37 additions & 0 deletions .github/workflows/release_artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release Artifacts
on:
push:
tags:
- "v*.*.*"

jobs:
release-artifacts:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin
~/.cargo/git/checkouts
~/.cargo/git/db
~/.cargo/registry/cache
~/.cargo/registry/index
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# docker can't pull private sources, so we fail if cache is missing
fail-on-cache-miss: true
- name: Build Artifacts
run: |
docker run \
-v "$GITHUB_WORKSPACE":/code \
-v ~/.cargo/registry:/usr/local/cargo/registry \
-v ~/.cargo/git:/usr/local/cargo/git \
cosmwasm/workspace-optimizer:0.12.13
tar -zcvf cosmwasm-artifacts.tar.gz artifacts
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: cosmwasm-artifacts.tar.gz
token: ${{ secrets.GITHUB_TOKEN }}
80 changes: 80 additions & 0 deletions .github/workflows/tests_and_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Contract tests and checks

on:
pull_request:
push:
branches:
- main

env:
CARGO_TERM_COLOR: always
CARGO_NET_GIT_FETCH_WITH_CLI: true

jobs:
test_and_check:
name: Test and check
runs-on: ubuntu-latest

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v3
- uses: webfactory/[email protected]
with:
ssh-private-key: |
${{ secrets.GOV_PRIVATE_KEY }}
${{ secrets.CORE_PRIVATE_KEY }}

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

- run: |
git config url."ssh://[email protected]/astroport-fi/hidden_astroport_governance.git".insteadOf "https://github.com/astroport-fi/hidden_astroport_governance"
git config url."ssh://[email protected]/astroport-fi/hidden_astroport_core.git".insteadOf "https://github.com/astroport-fi/hidden_astroport_core"

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

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --no-fail-fast --locked
env:
RUST_BACKTRACE: 1

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

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
18 changes: 18 additions & 0 deletions scripts/check_artifacts_size.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -e
set -o pipefail

# terra: https://github.com/terra-money/wasmd/blob/2308975f45eac299bdf246737674482eaa51051c/x/wasm/types/validation.go#L12
# injective: https://github.com/InjectiveLabs/wasmd/blob/e087f275712b5f0a798791495dee0e453d67cad3/x/wasm/types/validation.go#L19
maximum_size=800

for artifact in artifacts/*.wasm; do
artifactsize=$(du -k "$artifact" | cut -f 1)
if [ "$artifactsize" -gt $maximum_size ]; then
echo "Artifact file size exceeded: $artifact"
echo "Artifact size: $artifactsize"
echo "Max size: $maximum_size"
exit 1
fi
done

0 comments on commit 597b4e1

Please sign in to comment.