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

add templates and unit test ci for all PR & push actions #3

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Bug report
about: Create a bug report to help us improve
title: "[BUG] title_of_bug"
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Describe the steps to reproduce the behavior.

**Context & versions**
Delineate the correct versions of all the components involved in reproducing the bug.

**(if applicable) suggested solution**
If you know the solution to the bug, let us know!
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[FEATURE] title-of-feature "
labels: enhancement
assignees: ''

---

**Problem definition**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Feature specification**
A clear and concise description of what you want to happen.

**Additional context**
Add any other context or screenshots about the feature request here.
18 changes: 18 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Summary of changes

<Describe summary of major changes here>

## Report of required housekeeping

- [ ] Github issue OR spec proposal link
- [ ] Wrote tests
- [ ] Added a relevant changelog entry to CHANGELOG.md

----

## (FOR ADMIN) Before merging

- [ ] Added appropriate labels to PR
- [ ] Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)
- [ ] Confirm added tests are consistent with the intended behavior of changes
- [ ] Ensure all tests pass
38 changes: 38 additions & 0 deletions .github/workflows/release-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release Artifacts
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10
- "v[0-9]+.[0-9]+.[0-9]+-rc*" # Push events to matching v*, i.e. v1.0-rc1, v20.15.10-rc5

jobs:
release-artifacts:
env:
CONTRACT_DIR: contracts/airdrop
CARGO_MANIFEST_DIR: ${{ env.CONTRACT_DIR }}/Cargo.toml
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Generate Cargo.lock
run: |
cargo fetch --manifest-path=${{ env.CARGO_MANIFEST_DIR }} --verbose
- name: Build Artifacts
run: |
docker run --rm -v "$(pwd)"/${{ env.CONTRACT_DIR }}:/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.11.5
tar -zcvf cosmwasm-artifacts.tar.gz artifacts
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: cosmwasm-artifacts.tar.gz
body_path: CHANGELOG.md
67 changes: 67 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Formatting Check & Test

on:
pull_request:
push:
branches:
- main
- master
- "release/*"

jobs:
clippy:
name: Actions - clippy
runs-on: ubuntu-latest
env:
CARGO_MANIFEST_DIR: contracts/airdrop/Cargo.toml
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
profile: minimal
override: true
- run: cargo fetch --manifest-path=${{ env.CARGO_MANIFEST_DIR }} --verbose
- run: cargo clippy --manifest-path=${{ env.CARGO_MANIFEST_DIR }} --all --all-targets -- -D warnings

rustfmt:
name: Actions - rustfmt
runs-on: ubuntu-latest
env:
CARGO_MANIFEST_DIR: contracts/airdrop/Cargo.toml
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt
profile: minimal
override: true
- run: cargo fmt --manifest-path=${{ env.CARGO_MANIFEST_DIR }} -- --check

unit-test:
name: Actions - unit test
runs-on: ${{ matrix.os }}
env:
CARGO_MANIFEST_DIR: contracts/airdrop/Cargo.toml
strategy:
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
- run: cargo fetch --manifest-path=${{ env.CARGO_MANIFEST_DIR }} --verbose
- run: cargo build --manifest-path=${{ env.CARGO_MANIFEST_DIR }}
- run: cargo test --manifest-path=${{ env.CARGO_MANIFEST_DIR }} --verbose --all
env:
RUST_BACKTRACE: 1
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ coverage/

node_modules/
dist/

artifacts
1 change: 0 additions & 1 deletion artifacts/checksums.txt

This file was deleted.

Binary file removed artifacts/mirror_airdrop.wasm
Binary file not shown.
34 changes: 18 additions & 16 deletions contracts/airdrop/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions contracts/airdrop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ overflow-checks = true
backtraces = ["cosmwasm-std/backtraces"]

[dependencies]
cw20 = "0.8.0-rc1"
cw-storage-plus = "0.8.0-rc1"
cosmwasm-std = { version = "0.16.0-rc5" }
cosmwasm-storage = { version = "0.16.0-rc5" }
cw20 = "0.8.0"
cw-storage-plus = "0.8.0"
cosmwasm-std = { version = "0.16.0" }
cosmwasm-storage = { version = "0.16.0" }
schemars = "0.8.1"
sha3 = { version = "0.9.1", default-features = false }
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
hex = "0.4"

[dev-dependencies]
cosmwasm-schema = "0.16.0-rc5"
cosmwasm-schema = "0.16.0"
7 changes: 3 additions & 4 deletions contracts/airdrop/src/testing/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ fn claim() {
]
);

assert_eq!(
true,
assert!(
from_binary::<IsClaimedResponse>(
&query(
deps.as_ref(),
Expand All @@ -261,7 +260,7 @@ fn claim() {
.is_claimed
);

let res = execute(deps.as_mut(), mock_env(), info.clone(), msg.clone());
let res = execute(deps.as_mut(), mock_env(), info, msg);
match res {
Err(StdError::GenericErr { msg, .. }) => assert_eq!(msg, "already claimed"),
_ => panic!("DO NOT ENTER HERE"),
Expand All @@ -280,7 +279,7 @@ fn claim() {
};

let info = mock_info("terra1qfqa2eu9wp272ha93lj4yhcenrc6ymng079nu8", &[]);
let res = execute(deps.as_mut(), mock_env(), info.clone(), msg.clone()).unwrap();
let res = execute(deps.as_mut(), mock_env(), info, msg).unwrap();
assert_eq!(
res.messages,
vec![SubMsg::new(CosmosMsg::Wasm(WasmMsg::Execute {
Expand Down