Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pr and test #93

Merged
merged 5 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: pr

on:
pull_request:
branches:
- "main"

jobs:
artifact:
permissions:
contents: write
pull-requests: write

name: artifact
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust
run: |
rustup toolchain install 1.72 \
--profile minimal \
--target wasm32-unknown-unknown \
--no-self-update

- name: Cache dependencies
uses: Swatinem/rust-cache@v2

- name: Install Deps
run: make install-prod

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build wasm
run: |
cargo generate-lockfile
make ci-build

- name: Pull request artifacts
uses: gavv/pull-request-artifacts@v2
with:
commit: ${{ github.event.pull_request.head.sha }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
artifacts-branch: artifacts
artifacts: |
wasm_codes.zip
64 changes: 14 additions & 50 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,60 +20,19 @@ jobs:
with:
go-version: '1.21'

- name: Cache dependencies
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: Install Rust
run: rustup update 1.72

- name: Install rename
run: sudo apt-get install -y rename
run: |
rustup toolchain install 1.72 \
--profile minimal \
--target wasm32-unknown-unknown \
--no-self-update

- name: Install rust deps
run: make install
- name: Cache dependencies
uses: Swatinem/rust-cache@v2

- name: Run tests
run: cargo test --workspace --exclude hpl-tests

artifact:
permissions:
contents: write
pull-requests: write

name: artifact
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Dependencies
run: |
rustup update 1.72
sudo apt-get install -y rename
make install

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build wasm
run: make ci-build

- name: Pull request artifacts
uses: gavv/pull-request-artifacts@v2
with:
commit: ${{ github.event.pull_request.head.sha }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
artifacts-branch: artifacts
artifacts: |
wasm_codes.zip

coverage:
runs-on: ubuntu-latest
env:
Expand All @@ -87,8 +46,13 @@ jobs:

- name: Install Rust
run: |
rustup update nightly
rustup target add wasm32-unknown-unknown
rustup toolchain install 1.72 \
--profile minimal \
--target wasm32-unknown-unknown \
--no-self-update

- name: Cache dependencies
uses: Swatinem/rust-cache@v2

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
Expand Down
24 changes: 17 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,34 @@ clean:
@cargo clean
@rm -rf ./artifacts

install:
install: install-dev

install-dev: install-prod
cargo install --force cw-optimizoor beaker

install-prod:
cargo install --force cosmwasm-check
rustup target add wasm32-unknown-unknown

schema:
ls ./contracts | xargs -n 1 -t beaker wasm ts-gen

build:
cargo build
cargo wasm
check:
ls -d ./artifacts/*.wasm | xargs -I x cosmwasm-check x

optimize:
docker run --rm -v "$(PWD)":/code \
--mount type=volume,source="$(BASE)_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/optimizer:0.15.0

optimize-fast:
cargo cw-optimizoor
rename --force 's/(.*)-(.*)\.wasm/$$1\.wasm/d' artifacts/*

check: build
ls -d ./artifacts/*.wasm | xargs -I x cosmwasm-check x
build: optimize-fast check
cargo build
cargo wasm

ci-build: check
ci-build: optimize check
zip -jr wasm_codes.zip artifacts
Loading