1414permissions :
1515 contents : read
1616
17+ env :
18+ # Regression guard for the deployed contract only. Raised from the
19+ # previous 55000: that limit was never actually enforced (the old
20+ # check globbed *.wasm, so SIZE held two values and `[` aborted with
21+ # "too many arguments" — which, as an `if` condition, silently read
22+ # as false). The contract has since grown to ~87 KB. Hoisted to
23+ # workflow level so the size-report job below stays in sync with it.
24+ MAX_WASM_BYTES : " 92160" # 90 KB
25+
1726jobs :
1827 test :
1928 name : Test & Build
5261 run : cargo build --target wasm32-unknown-unknown --release
5362
5463 - name : Check WASM size
55- env :
56- # Regression guard for the deployed contract only. Raised from the
57- # previous 55000: that limit was never actually enforced (the old
58- # check globbed *.wasm, so SIZE held two values and `[` aborted with
59- # "too many arguments" — which, as an `if` condition, silently read
60- # as false). The contract has since grown to ~87 KB.
61- MAX_WASM_BYTES : " 92160" # 90 KB
6264 run : |
6365 set -euo pipefail
6466 ARTIFACT=target/wasm32-unknown-unknown/release/stellar_contracts.wasm
@@ -81,3 +83,104 @@ jobs:
8183
8284 - name : Run clippy (deny warnings)
8385 run : cargo clippy --all-targets --all-features -- -D warnings
86+
87+ deny :
88+ name : License & Advisory Check
89+ runs-on : ubuntu-latest
90+
91+ steps :
92+ - name : Checkout repository
93+ uses : actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
94+
95+ - name : Run cargo-deny (licenses & advisories)
96+ uses : EmbarkStudios/cargo-deny-action@3c6349835b2b7b196a839186cb8b78e02f7b5f25 # v2.1.1
97+ with :
98+ manifest-path : Dechat/stellar-contracts/Cargo.toml
99+ command : check licenses advisories bans sources
100+
101+ wasm-size-report :
102+ name : WASM Size Report
103+ runs-on : ubuntu-latest
104+ if : github.event_name == 'pull_request'
105+
106+ steps :
107+ - name : Checkout PR head
108+ uses : actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
109+ with :
110+ path : head
111+ ref : ${{ github.event.pull_request.head.sha }}
112+
113+ - name : Checkout PR base
114+ uses : actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
115+ with :
116+ path : base
117+ ref : ${{ github.event.pull_request.base.sha }}
118+
119+ - name : Set up Rust
120+ uses : dtolnay/rust-toolchain@2c7215f132e9ebf062739d9130488b56d53c060c # stable
121+ with :
122+ toolchain : stable
123+ targets : wasm32-unknown-unknown
124+
125+ - name : Cache Cargo registry & shared target dir
126+ uses : actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
127+ with :
128+ path : |
129+ ~/.cargo/registry
130+ ~/.cargo/git
131+ .wasm-size-target
132+ key : ${{ runner.os }}-cargo-wasm-size-${{ hashFiles('head/Dechat/stellar-contracts/Cargo.lock') }}
133+ restore-keys : |
134+ ${{ runner.os }}-cargo-wasm-size-
135+
136+ - name : Build head WASM
137+ working-directory : head/Dechat/stellar-contracts
138+ # --lib only: this crate also has src/bin/deploy_fiat_bridge_futurenet.rs,
139+ # which compiles to its own .wasm and would collide with a glob match.
140+ run : cargo build --target wasm32-unknown-unknown --release --lib
141+ env :
142+ CARGO_TARGET_DIR : ${{ github.workspace }}/.wasm-size-target
143+
144+ - name : Record head size
145+ id : head_size
146+ run : |
147+ SIZE=$(wc -c < "${{ github.workspace }}/.wasm-size-target/wasm32-unknown-unknown/release/stellar_contracts.wasm" | tr -d '[:space:]')
148+ echo "size=$SIZE" >> "$GITHUB_OUTPUT"
149+
150+ - name : Build base WASM
151+ working-directory : base/Dechat/stellar-contracts
152+ run : cargo build --target wasm32-unknown-unknown --release --lib
153+ env :
154+ CARGO_TARGET_DIR : ${{ github.workspace }}/.wasm-size-target
155+
156+ - name : Record base size
157+ id : base_size
158+ run : |
159+ SIZE=$(wc -c < "${{ github.workspace }}/.wasm-size-target/wasm32-unknown-unknown/release/stellar_contracts.wasm" | tr -d '[:space:]')
160+ echo "size=$SIZE" >> "$GITHUB_OUTPUT"
161+
162+ - name : Write size report
163+ run : |
164+ cat > wasm-size-report.json <<EOF
165+ {
166+ "pr_number": ${{ github.event.pull_request.number }},
167+ "base_sha": "${{ github.event.pull_request.base.sha }}",
168+ "head_sha": "${{ github.event.pull_request.head.sha }}",
169+ "base_size": ${{ steps.base_size.outputs.size }},
170+ "head_size": ${{ steps.head_size.outputs.size }},
171+ "limit": ${{ env.MAX_WASM_BYTES }}
172+ }
173+ EOF
174+
175+ # PRs from forks get a read-only GITHUB_TOKEN under the `pull_request`
176+ # event, so this job can't post a comment directly. The report is
177+ # handed off as an artifact to wasm-size-comment.yml, which runs via
178+ # `workflow_run` in the base repo's context (write-capable token) and
179+ # only ever reads this JSON — it never checks out or executes PR code,
180+ # so it stays safe from a malicious PR's build script.
181+ - name : Upload size report artifact
182+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
183+ with :
184+ name : wasm-size-report
185+ path : wasm-size-report.json
186+ retention-days : 7
0 commit comments