-
Notifications
You must be signed in to change notification settings - Fork 10
131 lines (120 loc) · 4.17 KB
/
Copy pathci.yml
File metadata and controls
131 lines (120 loc) · 4.17 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
lint:
name: Lint
runs-on: windows-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
with:
shared-key: ci-lint-windows-x64
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Format
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --all --all-targets -- -D warnings
- name: Check gpui-full feature
run: cargo check -p codirigent-ui --features gpui-full
test:
name: Test
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: ci-test-${{ runner.os }}-${{ runner.arch }}
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Test
run: cargo test --all --all-targets
warm-release-cache:
name: Warm Release Cache (${{ matrix.name }})
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- name: Windows x64
runner: windows-latest
target: x86_64-pc-windows-msvc
- name: macOS Apple Silicon
runner: macos-14
target: aarch64-apple-darwin
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install sccache
uses: mozilla-actions/sccache-action@v0.0.9
- uses: Swatinem/rust-cache@v2
with:
shared-key: release-${{ matrix.target }}
cache-targets: "false"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Build release binaries
run: |
cargo build --profile dist --features gpui-full --target ${{ matrix.target }} -p codirigent
cargo build --profile dist --target ${{ matrix.target }} -p codirigent-hook
check-unwraps:
name: Check for new unwrap() calls
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for new unwrap() calls
shell: bash
run: |
# Count unwraps in production code only (exclude #[cfg(test)] blocks and test dirs).
count_prod_unwraps() {
local ref="$1"
local total=0
while IFS= read -r file; do
# Find the first #[cfg(test)] line; count unwraps only before it
test_line=$(git show "$ref:$file" | grep -n '#\[cfg(test)\]' | head -1 | cut -d: -f1)
if [ -n "$test_line" ]; then
count=$(git show "$ref:$file" | head -n "$((test_line - 1))" | grep -v '///' | grep -c '\.unwrap()' || true)
else
count=$(git show "$ref:$file" | grep -v '///' | grep -c '\.unwrap()' || true)
fi
total=$((total + count))
done < <(git ls-tree -r --name-only "$ref" -- crates/ | grep '/src/.*\.rs$' | grep -v '/tests/')
echo "$total"
}
CURRENT=$(count_prod_unwraps HEAD)
BASELINE=$(count_prod_unwraps origin/main)
echo "Baseline unwraps (production): $BASELINE"
echo "Current unwraps (production): $CURRENT"
if [ "$CURRENT" -gt "$BASELINE" ]; then
echo "❌ New unwrap() calls in production code! ($((CURRENT - BASELINE)) added)"
echo "Please use safe error handling instead. See docs/coding-guidelines/error-handling.md"
exit 1
else
echo "✅ No new unwrap() calls in production code"
fi