forked from SoroLabs/SoroTask
-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (67 loc) · 2.44 KB
/
Copy pathrust.yml
File metadata and controls
81 lines (67 loc) · 2.44 KB
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
name: Rust Contract CI
on:
push:
branches: [ "main", "feat/*" ]
paths:
- 'contract/**'
- '.github/workflows/rust.yml'
pull_request:
branches: [ "main", "feat/*" ]
paths:
- 'contract/**'
- '.github/workflows/rust.yml'
# This ensures all 'run' commands happen inside the Rust directory
defaults:
run:
working-directory: ./contract
env:
CARGO_TERM_COLOR: always
jobs:
validate-and-build:
name: Format, Lint, Test, and Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Modern Rust Toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
components: rustfmt, clippy
- name: Cache Cargo Registry & Build Artifacts
uses: Swatinem/rust-cache@v2
with:
# Tell the cache exactly where our Rust workspace is located
workspaces: "./contract -> target"
- name: Check Formatting (fmt)
run: cargo fmt --all -- --check
- name: Run Linter (clippy) - Strict
# The -D warnings flag fulfills "Fail on warnings" requirement
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run Unit Tests (test)
run: cargo test
- name: Build WebAssembly (build)
run: cargo build --target wasm32-unknown-unknown --release
- name: Run Gas Tracking (Current Branch)
run: |
chmod +x ../scripts/track_gas.sh
../scripts/track_gas.sh
cp ../gas_report.json /tmp/pr_gas.json
cp ../scripts/track_gas.sh /tmp/track_gas.sh
cp ../scripts/compare_gas.py /tmp/compare_gas.py
- name: Run Gas Tracking (Base Branch)
if: github.event_name == 'pull_request'
run: |
git fetch origin ${{ github.base_ref }}
git checkout origin/${{ github.base_ref }} || true
/tmp/track_gas.sh || true
cp ../gas_report.json /tmp/base_gas.json || echo "[]" > /tmp/base_gas.json
git checkout - || true
- name: Compare Gas and Post PR Comment
if: github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
chmod +x /tmp/compare_gas.py
/tmp/compare_gas.py /tmp/base_gas.json /tmp/pr_gas.json > /tmp/gas_diff.md
gh pr comment ${{ github.event.pull_request.number }} --body-file /tmp/gas_diff.md || true