Skip to content

Commit 0cd427b

Browse files
authored
Merge pull request #65 from spinkube/fmt
add rustfmt.toml to configure format
2 parents 137a78e + 1203e8f commit 0cd427b

File tree

7 files changed

+39
-30
lines changed

7 files changed

+39
-30
lines changed

.github/workflows/ci.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ jobs:
1313
with:
1414
workspaces: |
1515
"containerd-shim-* -> target"
16-
- name: "Install dependencies"
16+
- run:
17+
rustup toolchain install nightly --component rustfmt
18+
- name: Setup build env
1719
run: |
18-
sudo apt-get update
19-
sudo apt-get install -y protobuf-compiler libseccomp-dev
20+
./scripts/setup-linux.sh
2021
- name: fmt
2122
run: |
2223
make fmt
@@ -43,10 +44,9 @@ jobs:
4344
- uses: actions/checkout@v4
4445
- uses: actions/download-artifact@v4
4546
- uses: azure/setup-kubectl@v4
46-
- name: "Install dependencies"
47+
- name: Setup build env
4748
run: |
48-
sudo apt-get update
49-
sudo apt-get install -y protobuf-compiler libseccomp-dev
49+
./scripts/setup-linux.sh
5050
- name: Extract containerd-shim-spin-linux-${{ env.ARCH }}
5151
run: |
5252
mkdir -p ./bin

Makefile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,12 @@ tests/clean:
6161

6262
.PHONY: fmt
6363
fmt:
64-
$(foreach shim,$(SHIMS),cargo fmt --all --manifest-path=containerd-shim-$(shim)/Cargo.toml -- --check;)
65-
$(foreach shim,$(SHIMS),cargo clippy --all-targets --all-features --workspace --manifest-path=containerd-shim-$(shim)/Cargo.toml -- -D warnings;)
66-
cargo fmt --all -- --check
64+
cargo +nightly fmt --all -- --check
6765
cargo clippy --all-targets --all-features --workspace -- --deny=warnings
6866

6967
.PHONY: fix
7068
fix:
71-
$(foreach shim,$(SHIMS),cargo fmt --all --manifest-path=containerd-shim-$(shim)/Cargo.toml;)
72-
$(foreach shim,$(SHIMS),cargo clippy --all-targets --all-features --workspace --manifest-path=containerd-shim-$(shim)/Cargo.toml --fix -- -D warnings;)
73-
cargo fmt --all
69+
cargo +nightly fmt --all
7470
cargo clippy --all-targets --all-features --workspace --fix -- --deny=warnings
7571

7672
.PHONY: build

containerd-shim-spin/src/engine.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1+
use std::{
2+
collections::{hash_map::DefaultHasher, HashSet},
3+
env,
4+
fs::File,
5+
hash::{Hash, Hasher},
6+
io::Write,
7+
net::{SocketAddr, ToSocketAddrs},
8+
path::{Path, PathBuf},
9+
};
10+
111
use anyhow::{anyhow, ensure, Context, Result};
2-
use containerd_shim_wasm::container::{Engine, RuntimeContext, Stdio};
3-
use containerd_shim_wasm::sandbox::WasmLayer;
12+
use containerd_shim_wasm::{
13+
container::{Engine, RuntimeContext, Stdio},
14+
sandbox::WasmLayer,
15+
};
416
use log::info;
517
use oci_spec::image::MediaType;
618
use spin_app::locked::LockedApp;
7-
use spin_loader::cache::Cache;
8-
use spin_loader::FilesMountStrategy;
19+
use spin_loader::{cache::Cache, FilesMountStrategy};
920
use spin_manifest::schema::v2::AppManifest;
10-
use spin_trigger::TriggerHooks;
11-
use spin_trigger::{loader, RuntimeConfig, TriggerExecutor, TriggerExecutorBuilder};
21+
use spin_trigger::{loader, RuntimeConfig, TriggerExecutor, TriggerExecutorBuilder, TriggerHooks};
1222
use spin_trigger_http::HttpTrigger;
1323
use spin_trigger_redis::RedisTrigger;
14-
use std::collections::hash_map::DefaultHasher;
15-
use std::collections::HashSet;
16-
use std::env;
17-
use std::fs::File;
18-
use std::hash::{Hash, Hasher};
19-
use std::io::Write;
20-
use std::net::SocketAddr;
21-
use std::net::ToSocketAddrs;
22-
use std::path::{Path, PathBuf};
2324
use tokio::runtime::Runtime;
2425
use trigger_command::CommandTrigger;
2526
use trigger_sqs::SqsTrigger;

containerd-shim-spin/src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use containerd_shim::Config;
2-
use containerd_shim_wasm::container::Instance;
3-
use containerd_shim_wasm::sandbox::cli::{revision, shim_main, version};
2+
use containerd_shim_wasm::{
3+
container::Instance,
4+
sandbox::cli::{revision, shim_main, version},
5+
};
46

57
mod engine;
68

rustfmt.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
newline_style = "Native"
2+
unstable_features = true # Cargo fmt now needs to be called with `cargo +nightly fmt`
3+
group_imports = "StdExternalCrate" # create three groups for std, external and local crates
4+
# Merge imports from the same module
5+
# See: https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#imports_granularity
6+
imports_granularity = "Crate"

scripts/setup-linux.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
sudo apt -y update
3+
sudo apt-get install -y protobuf-compiler libseccomp-dev
4+

tests/src/integration_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#[cfg(test)]
22
mod test {
3+
use anyhow::Result;
34
use redis::AsyncCommands;
45
use tokio::process::Command;
56

67
use crate::retry_get;
7-
use anyhow::Result;
88

99
const RETRY_TIMES: u32 = 5;
1010
const INTERVAL_IN_SECS: u64 = 10;

0 commit comments

Comments
 (0)