-
Notifications
You must be signed in to change notification settings - Fork 192
150 lines (143 loc) · 4.97 KB
/
Copy pathcontract-test.yml
File metadata and controls
150 lines (143 loc) · 4.97 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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Contract Test Pipeline
on:
push:
paths:
- '**.wasm'
- 'src/**'
- 'tests/**'
- 'Cargo.toml'
- 'Cargo.lock'
pull_request:
paths:
- '**.wasm'
- 'src/**'
- 'tests/**'
- 'Cargo.toml'
- 'Cargo.lock'
workflow_dispatch:
inputs:
network:
description: Target network for integration tests
required: false
default: testnet
type: choice
options: [testnet, mainnet]
wasm_path:
description: Path to compiled WASM file (optional)
required: false
type: string
permissions:
contents: read
jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libudev-dev
- name: Run unit tests
run: cargo test --locked -- --test-threads=1
lint-contract:
name: Contract Lint
runs-on: ubuntu-latest
needs: unit-tests
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libudev-dev
- name: Install starforge
run: cargo build --locked --release && cp target/release/starforge /usr/local/bin/starforge
- name: Lint contract (if WASM available)
if: ${{ inputs.wasm_path != '' }}
run: starforge lint --wasm "${{ inputs.wasm_path }}"
continue-on-error: true
gas-analysis:
name: Gas Analysis
runs-on: ubuntu-latest
needs: unit-tests
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libudev-dev
- name: Build
run: cargo build --locked --release
- name: Install starforge
run: cp target/release/starforge /usr/local/bin/starforge
- name: Run gas analysis (if WASM available)
if: ${{ inputs.wasm_path != '' }}
run: starforge gas analyze --wasm "${{ inputs.wasm_path }}" --network "${{ inputs.network || 'testnet' }}"
continue-on-error: true
security-audit:
name: Security Audit
runs-on: ubuntu-latest
needs: unit-tests
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libudev-dev
- name: Build
run: cargo build --locked --release
- name: Install starforge
run: cp target/release/starforge /usr/local/bin/starforge
- name: Run security audit (if WASM available)
if: ${{ inputs.wasm_path != '' }}
run: starforge audit --wasm "${{ inputs.wasm_path }}" --output json > audit-results.json
continue-on-error: true
- name: Upload audit results
if: always()
uses: actions/upload-artifact@v4
with:
name: audit-results
path: audit-results.json
if-no-files-found: ignore
notify:
name: Notify Results
runs-on: ubuntu-latest
needs: [unit-tests, lint-contract, gas-analysis, security-audit]
if: always()
steps:
- name: Notify on failure
if: ${{ contains(needs.*.result, 'failure') && secrets.SLACK_WEBHOOK_URL != '' }}
uses: slackapi/slack-github-action@v1
with:
payload: |
{
"text": "❌ Contract test pipeline failed",
"attachments": [{
"color": "danger",
"fields": [
{ "title": "Repository", "value": "${{ github.repository }}", "short": true },
{ "title": "Branch", "value": "${{ github.ref_name }}", "short": true },
{ "title": "Commit", "value": "${{ github.sha }}", "short": false },
{ "title": "Details", "value": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", "short": false }
]
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
- name: Notify on success
if: ${{ !contains(needs.*.result, 'failure') && secrets.SLACK_WEBHOOK_URL != '' }}
uses: slackapi/slack-github-action@v1
with:
payload: |
{
"text": "✅ Contract test pipeline passed",
"attachments": [{
"color": "good",
"fields": [
{ "title": "Repository", "value": "${{ github.repository }}", "short": true },
{ "title": "Branch", "value": "${{ github.ref_name }}", "short": true }
]
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK