Skip to content

Commit 6be5cb3

Browse files
lukekimclaude
andauthored
chore: cargo fmt --all + CI hardening (rustfmt gate, resilient Linux install) (#79)
* chore: cargo fmt --all + add rustfmt CI gate Trunk had accumulated rustfmt drift — CI never ran `cargo fmt --check` and there is no rustfmt.toml, so pre-existing code had multi-line attributes, unwrapped imports, and inconsistent call wrapping. - Run `cargo fmt --all` across the workspace (src/params.rs, src/client.rs). - Add a `rustfmt` job to build.yml (`cargo fmt --all --check`) so formatting stays clean going forward. Pure formatting — no behavioral change; all lib tests and doctests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * ci: make Linux Spice install resilient to GitHub 429 rate limits `curl https://install.spiceai.org | /bin/bash` has no `-f` flag, so when the proxied GitHub script returns an HTTP 429 rate-limit page, that page is piped into bash and executed (syntax error → exit 2) — an intermittent flake seen on PR CI. Add `-f` + `pipefail` so a bad HTTP response is a real curl failure, and retry the installer and `spice install` (mirrors the resilient macOS step from #72/#78). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3070059 commit 6be5cb3

3 files changed

Lines changed: 160 additions & 92 deletions

File tree

.github/workflows/build.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@ env:
1212
CARGO_TERM_COLOR: always
1313

1414
jobs:
15+
fmt:
16+
name: rustfmt
17+
runs-on: ubuntu-latest
18+
steps:
19+
# actions/checkout v4.2.2
20+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
21+
22+
- name: Install Rust toolchain
23+
# dtolnay/rust-toolchain (pinned 2026-06-30)
24+
uses: dtolnay/rust-toolchain@fa04a1451ff1842e2626ccb99004d0195b455a88
25+
with:
26+
toolchain: 1.93.1
27+
components: rustfmt
28+
29+
- name: Check formatting
30+
run: cargo fmt --all --check
31+
1532
build_toolchains:
1633
name: Clippy on ${{ matrix.toolchain }}
1734
runs-on: ubuntu-latest
@@ -97,9 +114,21 @@ jobs:
97114
env:
98115
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99116
run: |
100-
curl https://install.spiceai.org | /bin/bash
101-
echo "$HOME/.spice/bin" >> $GITHUB_PATH
102-
$HOME/.spice/bin/spice install
117+
# install.spiceai.org proxies a GitHub-hosted script and can return an
118+
# HTTP 429 (rate-limit) page; without -f, `curl | bash` pipes that page
119+
# into bash and fails the job. Use -f + pipefail so a bad response is a
120+
# real error, and retry the rate-limitable network steps.
121+
set -o pipefail
122+
for i in 1 2 3; do
123+
curl -fsSL https://install.spiceai.org | /bin/bash && break
124+
echo "spice installer attempt $i failed (likely GitHub 429); retrying in 15s"
125+
[ "$i" = 3 ] && exit 1
126+
sleep 15
127+
done
128+
echo "$HOME/.spice/bin" >> "$GITHUB_PATH"
129+
"$HOME/.spice/bin/spice" install \
130+
|| { sleep 15 && "$HOME/.spice/bin/spice" install; } \
131+
|| { sleep 15 && "$HOME/.spice/bin/spice" install; }
103132
104133
- name: Install Spice (https://install.spiceai.org) (MacOS)
105134
if: startsWith(matrix.os, 'macos')

src/client.rs

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -992,34 +992,30 @@ mod tests {
992992
Mock::given(method("POST"))
993993
.and(path("/v1/queries"))
994994
.and(body_json(json!({ "sql": "SELECT 1" })))
995-
.respond_with(
996-
ResponseTemplate::new(202).set_body_json(json!({
997-
"query_id": query_id,
998-
"status": "PENDING",
999-
"status_url": format!("{}/v1/queries/{query_id}/status", server.uri()),
1000-
"results_url": format!("{}/v1/queries/{query_id}/results", server.uri())
1001-
})),
1002-
)
995+
.respond_with(ResponseTemplate::new(202).set_body_json(json!({
996+
"query_id": query_id,
997+
"status": "PENDING",
998+
"status_url": format!("{}/v1/queries/{query_id}/status", server.uri()),
999+
"results_url": format!("{}/v1/queries/{query_id}/results", server.uri())
1000+
})))
10031001
.mount(&server)
10041002
.await;
10051003

10061004
Mock::given(method("GET"))
10071005
.and(path("/v1/queries"))
10081006
.and(query_param("status", "running"))
10091007
.and(query_param("limit", "5"))
1010-
.respond_with(
1011-
ResponseTemplate::new(200).set_body_json(json!({
1012-
"queries": [
1013-
{
1014-
"query_id": query_id,
1015-
"status": "RUNNING",
1016-
"created_at": "2025-01-01T00:00:00Z",
1017-
"sql_preview": "SELECT 1"
1018-
}
1019-
],
1020-
"total_count": 1
1021-
})),
1022-
)
1008+
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
1009+
"queries": [
1010+
{
1011+
"query_id": query_id,
1012+
"status": "RUNNING",
1013+
"created_at": "2025-01-01T00:00:00Z",
1014+
"sql_preview": "SELECT 1"
1015+
}
1016+
],
1017+
"total_count": 1
1018+
})))
10231019
.mount(&server)
10241020
.await;
10251021

@@ -1034,10 +1030,8 @@ mod tests {
10341030
Mock::given(method("GET"))
10351031
.and(path(format!("/v1/queries/{query_id}")))
10361032
.respond_with(
1037-
ResponseTemplate::new(200).set_body_json(query_manifest_response(
1038-
query_id,
1039-
QueryStatus::Succeeded,
1040-
)),
1033+
ResponseTemplate::new(200)
1034+
.set_body_json(query_manifest_response(query_id, QueryStatus::Succeeded)),
10411035
)
10421036
.mount(&server)
10431037
.await;
@@ -1078,7 +1072,10 @@ mod tests {
10781072

10791073
let job = client.query("SELECT 1").await.expect("submit async query");
10801074
assert_eq!(job.id(), query_id);
1081-
assert_eq!(job.status().await.expect("get query status"), QueryStatus::Running);
1075+
assert_eq!(
1076+
job.status().await.expect("get query status"),
1077+
QueryStatus::Running
1078+
);
10821079

10831080
let info = job.info().await.expect("get query info");
10841081
assert_eq!(info.query_id, query_id);

0 commit comments

Comments
 (0)