Skip to content

Commit 480ae29

Browse files
CSResselnori-agent
andcommitted
ci: Add minimal Rust CI workflow
Add a basic CI workflow for Rust code with: cargo check, fmt, clippy, and test. Uses sccache for build caching. Runs on Linux (ubuntu-24.04) and macOS (macos-14). Triggers on PRs and pushes to main/dev. Also fixes pre-existing formatting in acp/src/connection.rs. 🤖 Generated with [Nori](https://nori.ai) Co-Authored-By: Nori <noreply@tilework.tech>
1 parent 29d0543 commit 480ae29

2 files changed

Lines changed: 103 additions & 3 deletions

File tree

.github/workflows/rust-ci.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: rust-ci
2+
on:
3+
pull_request: {}
4+
push:
5+
branches: [main, dev]
6+
7+
jobs:
8+
checks:
9+
name: ${{ matrix.name }}
10+
runs-on: ${{ matrix.runner }}
11+
timeout-minutes: 20
12+
defaults:
13+
run:
14+
working-directory: codex-rs
15+
env:
16+
CARGO_INCREMENTAL: "0"
17+
SCCACHE_CACHE_SIZE: 10G
18+
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- runner: ubuntu-24.04
24+
target: x86_64-unknown-linux-gnu
25+
name: Linux checks
26+
- runner: macos-14
27+
target: aarch64-apple-darwin
28+
name: macOS checks
29+
30+
steps:
31+
- uses: actions/checkout@v5
32+
33+
- uses: dtolnay/rust-toolchain@1.90
34+
with:
35+
targets: ${{ matrix.target }}
36+
components: rustfmt, clippy
37+
38+
# sccache setup
39+
- name: Install sccache
40+
uses: taiki-e/install-action@44c6d64aa62cd779e873306675c7a58e86d6d532 # v2
41+
with:
42+
tool: sccache
43+
version: 0.7.5
44+
45+
- name: Configure sccache backend
46+
shell: bash
47+
run: |
48+
set -euo pipefail
49+
if [[ -n "${ACTIONS_CACHE_URL:-}" && -n "${ACTIONS_RUNTIME_TOKEN:-}" ]]; then
50+
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
51+
echo "Using sccache GitHub backend"
52+
else
53+
echo "SCCACHE_GHA_ENABLED=false" >> "$GITHUB_ENV"
54+
echo "SCCACHE_DIR=${{ github.workspace }}/.sccache" >> "$GITHUB_ENV"
55+
echo "Using sccache local disk fallback"
56+
fi
57+
58+
- name: Enable sccache wrapper
59+
shell: bash
60+
run: echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
61+
62+
- name: Restore sccache cache (fallback)
63+
if: ${{ env.SCCACHE_GHA_ENABLED != 'true' }}
64+
uses: actions/cache/restore@v4
65+
with:
66+
path: ${{ github.workspace }}/.sccache/
67+
key: sccache-${{ matrix.runner }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}-${{ github.run_id }}
68+
restore-keys: |
69+
sccache-${{ matrix.runner }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}-
70+
sccache-${{ matrix.runner }}-${{ matrix.target }}-
71+
72+
# CI checks
73+
- name: cargo check
74+
run: cargo check --target ${{ matrix.target }} --all-features
75+
76+
- name: cargo fmt
77+
run: cargo fmt -- --check
78+
79+
- name: cargo clippy
80+
run: cargo clippy --target ${{ matrix.target }} --all-features -- -D warnings
81+
82+
- name: cargo test
83+
run: cargo test --target ${{ matrix.target }} --all-features
84+
85+
# Save sccache
86+
- name: Save sccache cache (fallback)
87+
if: always() && !cancelled() && env.SCCACHE_GHA_ENABLED != 'true'
88+
continue-on-error: true
89+
uses: actions/cache/save@v4
90+
with:
91+
path: ${{ github.workspace }}/.sccache/
92+
key: sccache-${{ matrix.runner }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}-${{ github.run_id }}
93+
94+
- name: sccache stats
95+
if: always()
96+
continue-on-error: true
97+
run: sccache --show-stats || true

codex-rs/acp/src/connection.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ impl AcpConnection {
8080

8181
// Spawn a dedicated thread with a single-threaded tokio runtime
8282
let worker_thread = thread::spawn(move || {
83-
#[expect(clippy::expect_used, reason = "Runtime creation in dedicated thread is infallible in practice")]
83+
#[expect(
84+
clippy::expect_used,
85+
reason = "Runtime creation in dedicated thread is infallible in practice"
86+
)]
8487
let rt = tokio::runtime::Builder::new_current_thread()
8588
.enable_all()
8689
.build()
@@ -407,8 +410,8 @@ impl acp::Client for ClientDelegate {
407410
arguments: acp::ReadTextFileRequest,
408411
) -> acp::Result<acp::ReadTextFileResponse> {
409412
// Read file content
410-
let content = std::fs::read_to_string(&arguments.path)
411-
.map_err(acp::Error::into_internal_error)?;
413+
let content =
414+
std::fs::read_to_string(&arguments.path).map_err(acp::Error::into_internal_error)?;
412415
Ok(acp::ReadTextFileResponse {
413416
content,
414417
meta: None,

0 commit comments

Comments
 (0)