-
Notifications
You must be signed in to change notification settings - Fork 0
181 lines (152 loc) · 4.95 KB
/
ci.yml
File metadata and controls
181 lines (152 loc) · 4.95 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: CI
on:
pull_request:
branches: [ main ]
push:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
jobs:
# ===== CHANGE DETECTION =====
changes:
name: Detect Changes
runs-on: ubuntu-latest
outputs:
rust: ${{ steps.filter.outputs.rust }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
rust:
- '**/*.rs'
- '**/Cargo.toml'
- 'Cargo.lock'
# ===== CODE QUALITY CHECKS =====
format:
name: Check Formatting
needs: changes
if: needs.changes.outputs.rust == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --check
working-directory: think
lint:
name: Lint Code
needs: changes
if: needs.changes.outputs.rust == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
targets: wasm32-wasip1
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Run clippy
run: make lint
working-directory: think
# ===== BUILD VERIFICATION =====
build:
name: Build WASM
needs: changes
if: needs.changes.outputs.rust == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-wasip1
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Build WASM
run: make build
working-directory: think
# ===== TESTS =====
test:
name: Run Tests
needs: changes
if: needs.changes.outputs.rust == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Run tests
run: make test
working-directory: think
- name: FTL Test
uses: fastertools/actions/actions/setup-ftl@v1
with:
version: 'latest'
install-dependencies: true
# ===== CI SUMMARY =====
ci-summary:
name: CI Summary
if: always()
needs: [changes, format, lint, build, test]
runs-on: ubuntu-latest
steps:
- name: Create summary
run: |
echo "## CI Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Change detection
if [[ "${{ needs.changes.outputs.rust }}" == "true" ]]; then
echo "🔄 **Changes**: Rust files detected" >> $GITHUB_STEP_SUMMARY
else
echo "⏭️ **Changes**: No Rust changes, jobs skipped" >> $GITHUB_STEP_SUMMARY
fi
# Only show results if Rust changes detected
if [[ "${{ needs.changes.outputs.rust }}" == "true" ]]; then
echo "" >> $GITHUB_STEP_SUMMARY
# Format results
if [[ "${{ needs.format.result }}" == "success" ]]; then
echo "✅ **Format**: Code properly formatted" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Format**: Formatting issues detected" >> $GITHUB_STEP_SUMMARY
fi
# Lint results
if [[ "${{ needs.lint.result }}" == "success" ]]; then
echo "✅ **Lint**: No clippy warnings" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Lint**: Clippy warnings detected" >> $GITHUB_STEP_SUMMARY
fi
# Build results
if [[ "${{ needs.build.result }}" == "success" ]]; then
echo "✅ **Build**: WASM compilation successful" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Build**: Compilation failed" >> $GITHUB_STEP_SUMMARY
fi
# Test results
if [[ "${{ needs.test.result }}" == "success" ]]; then
echo "✅ **Test**: All unit tests passed" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Test**: Unit tests failed" >> $GITHUB_STEP_SUMMARY
fi
fi
- uses: fastertools/actions/actions/setup-ftl@v1
with:
version: 'latest'
install-dependencies: true