forked from osmosis-labs/osmosis
-
Notifications
You must be signed in to change notification settings - Fork 1
133 lines (116 loc) · 4.34 KB
/
contracts.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Cosmwasm Contracts
on:
pull_request:
branches:
- "**"
paths:
- "**/**/*.wasm"
- "**/**.rs"
- "**/**Cargo.toml"
- "**/**Cargo.lock"
- "**/cosmwasm/**"
- "**/wasmbinding/**"
- ".github/workflows/contracts.yml"
push:
branches:
- "main"
- "v[0-9]**"
paths:
- "**/**/*.wasm"
- "**/**.rs"
- "**/**Cargo.toml"
- "**/**Cargo.lock"
- "**/cosmwasm/**"
- "**/wasmbinding/**"
- ".github/workflows/contracts.yml"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
test:
name: Optimize Cosmwasm Contracts
runs-on: ubuntu-latest
strategy:
matrix:
contract: [
{workdir: ./x/ibc-rate-limit/, bytecode: x/ibc-rate-limit/bytecode/rate_limiter.wasm, build: artifacts/rate_limiter.wasm, name: rate_limiter},
{workdir: ./cosmwasm/, bytecode: tests/ibc-hooks/bytecode/crosschain_swaps.wasm, build: artifacts/crosschain_swaps.wasm, name: crosschain_swaps},
{workdir: ./cosmwasm/, bytecode: tests/ibc-hooks/bytecode/swaprouter.wasm, build: artifacts/swaprouter.wasm, name: swaprouter},
{workdir: ./cosmwasm/, bytecode: tests/ibc-hooks/bytecode/outpost.wasm, build: artifacts/outpost.wasm, name: outpost},
]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Optimize
working-directory: ${{ matrix.contract.workdir }}
run: >
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/workspace-optimizer:0.12.10
- name: 'Upload optimized contract artifact'
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.contract.name }}
path: ${{ matrix.contract.workdir }}${{ matrix.contract.build }}
retention-days: 1
- name: 'Upload Cargo.lock artifact'
uses: actions/upload-artifact@v3
with:
name: Cargo.lock
path: ${{ matrix.contract.workdir }}Cargo.lock
retention-days: 1
# TODO: workspace optimizer compiles all contracts in the workspace, so we could just run that once
# and then check the diff of all the bytecode files
- name: Check Test Data
working-directory: ${{ matrix.contract.workdir }}
run: >
diff "${GITHUB_WORKSPACE}/${{ matrix.contract.bytecode }}" ${{ matrix.contract.build }}
tests:
name: Test Cosmwasm Contracts
runs-on: ubuntu-latest
strategy:
matrix:
contract: [
{workdir: ./x/ibc-rate-limit/, bytecode: x/ibc-rate-limit/bytecode/rate_limiter.wasm, build: artifacts/rate_limiter.wasm, name: rate_limiter},
{workdir: ./cosmwasm/, bytecode: tests/ibc-hooks/bytecode/crosschain_swaps.wasm, build: artifacts/crosschain_swaps.wasm, name: crosschain_swaps},
{workdir: ./cosmwasm/, bytecode: tests/ibc-hooks/bytecode/swaprouter.wasm, build: artifacts/swaprouter.wasm, name: swaprouter},
{workdir: ./cosmwasm/, bytecode: tests/ibc-hooks/bytecode/outpost.wasm, build: artifacts/outpost.wasm, name: outpost},
]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install toolchain
uses: dtolnay/[email protected]
with:
target: wasm32-unknown-unknown
- name: Add the wasm target
working-directory: ${{ matrix.contract.workdir }}
run: >
rustup target add wasm32-unknown-unknown;
- name: Test
working-directory: ${{ matrix.contract.workdir }}
run: >
cargo test
lints:
name: Cosmwasm Lints
runs-on: ubuntu-latest
strategy:
matrix:
workdir: [./x/ibc-rate-limit, ./cosmwasm]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install toolchain
uses: dtolnay/[email protected]
with:
components: rustfmt, clippy
- name: Format
working-directory: ${{ matrix.workdir }}
run: >
cargo fmt --all -- --check
- name: run cargo clippy
working-directory: ${{ matrix.workdir }}
run: >
cargo clippy -- -D warnings