mirror of
https://github.com/philmmanjaro/alma.git
synced 2025-07-23 21:49:28 +02:00
Fix Clippy lints & GitHub Action improvements (#74)
* ci: improve - run on all branches to test things - no cargo color, it destroys actions-rs/cargo features - update versions * refactor(lint): fix clippy issues * refactor(lint): fix more clippy issues
This commit is contained in:
parent
a6984b0b84
commit
dc127ed87a
15
.github/workflows/rust.yml
vendored
15
.github/workflows/rust.yml
vendored
@ -2,37 +2,30 @@ name: Rust
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
- uses: actions-rs/cargo@v1.0.1
|
||||
- uses: actions-rs/cargo@v1
|
||||
name: Check format
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
- uses: actions-rs/cargo@v1.0.1
|
||||
- uses: actions-rs/cargo@v1
|
||||
name: Run clippy
|
||||
with:
|
||||
command: clippy
|
||||
args: --all-targets --locked -- -D warnings
|
||||
- uses: actions-rs/cargo@v1.0.1
|
||||
- uses: actions-rs/cargo@v1
|
||||
name: Run tests
|
||||
with:
|
||||
command: test
|
||||
|
@ -12,7 +12,7 @@ impl FromStr for AurHelper {
|
||||
|
||||
fn from_str(s: &str) -> anyhow::Result<Self> {
|
||||
match s {
|
||||
"yay" => Ok(AurHelper {
|
||||
"yay" => Ok(Self {
|
||||
name: String::from("yay"),
|
||||
package_name: String::from("yay-bin"),
|
||||
install_command: vec![
|
||||
|
@ -186,7 +186,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
|
||||
let root_partition_base = storage_device.get_partition(constants::ROOT_PARTITION_INDEX)?;
|
||||
let encrypted_root = if let Some(cryptsetup) = &cryptsetup {
|
||||
info!("Encrypting the root filesystem");
|
||||
EncryptedDevice::prepare(&cryptsetup, &root_partition_base)?;
|
||||
EncryptedDevice::prepare(cryptsetup, &root_partition_base)?;
|
||||
Some(EncryptedDevice::open(
|
||||
cryptsetup,
|
||||
&root_partition_base,
|
||||
|
@ -33,7 +33,7 @@ fn visit_dirs(dir: &Path, filevec: &mut Vec<PathBuf>) -> Result<(), io::Error> {
|
||||
impl Preset {
|
||||
fn load(path: &Path) -> anyhow::Result<Self> {
|
||||
let data = fs::read_to_string(path).with_context(|| format!("{}", path.display()))?;
|
||||
Ok(toml::from_str(&data).with_context(|| format!("{}", path.display()))?)
|
||||
toml::from_str(&data).with_context(|| format!("{}", path.display()))
|
||||
}
|
||||
|
||||
fn process(
|
||||
@ -41,7 +41,7 @@ impl Preset {
|
||||
packages: &mut HashSet<String>,
|
||||
scripts: &mut Vec<Script>,
|
||||
environment_variables: &mut HashSet<String>,
|
||||
path: &PathBuf,
|
||||
path: &Path,
|
||||
aur_packages: &mut HashSet<String>,
|
||||
) -> anyhow::Result<()> {
|
||||
if let Some(preset_packages) = &self.packages {
|
||||
@ -111,7 +111,7 @@ impl PresetsCollection {
|
||||
// Build vector of paths to files, then sort by path name
|
||||
// Recursively load directories of preset files
|
||||
let mut dir_paths: Vec<PathBuf> = Vec::new();
|
||||
visit_dirs(&preset, &mut dir_paths)
|
||||
visit_dirs(preset, &mut dir_paths)
|
||||
.with_context(|| format!("{}", preset.display()))?;
|
||||
|
||||
// Order not guaranteed so we sort
|
||||
@ -128,11 +128,11 @@ impl PresetsCollection {
|
||||
)?;
|
||||
}
|
||||
} else {
|
||||
Preset::load(&preset)?.process(
|
||||
Preset::load(preset)?.process(
|
||||
&mut packages,
|
||||
&mut scripts,
|
||||
&mut environment_variables,
|
||||
&preset,
|
||||
preset,
|
||||
&mut aur_packages,
|
||||
)?;
|
||||
}
|
||||
@ -151,8 +151,8 @@ impl PresetsCollection {
|
||||
|
||||
Ok(Self {
|
||||
packages,
|
||||
scripts,
|
||||
aur_packages,
|
||||
scripts,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ impl LoopDevice {
|
||||
);
|
||||
info!("Mounted {} to {}", file.display(), path.display());
|
||||
|
||||
Ok(LoopDevice { path, losetup })
|
||||
Ok(Self { path, losetup })
|
||||
}
|
||||
|
||||
pub fn path(&self) -> &Path {
|
||||
|
@ -68,7 +68,7 @@ pub fn get_storage_devices(allow_non_removable: bool) -> anyhow::Result<Vec<Devi
|
||||
.context("Could not parse block size to unsigned integer (u128)")?
|
||||
* 512,
|
||||
),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
Ok(result)
|
||||
|
@ -21,7 +21,7 @@ impl<'a> StorageDevice<'a> {
|
||||
.context("Error querying information about the block device")?;
|
||||
let device_name = path
|
||||
.file_name()
|
||||
.and_then(|s| s.to_str())
|
||||
.and_then(std::ffi::OsStr::to_str)
|
||||
.map(String::from)
|
||||
.ok_or_else(|| anyhow!("Invalid device name: {}", path.display()))?;
|
||||
|
||||
|
@ -20,7 +20,7 @@ pub fn mount<'a>(
|
||||
|
||||
info!("Mounting filesystems to {}", mount_path.display());
|
||||
mount_stack
|
||||
.mount(&root_filesystem, mount_path.into(), None)
|
||||
.mount(root_filesystem, mount_path.into(), None)
|
||||
.with_context(|| format!("Error mounting filesystem to {}", mount_path.display()))?;
|
||||
|
||||
let boot_point = mount_path.join("boot");
|
||||
@ -29,7 +29,7 @@ pub fn mount<'a>(
|
||||
}
|
||||
|
||||
mount_stack
|
||||
.mount(&boot_filesystem, boot_point, None)
|
||||
.mount(boot_filesystem, boot_point, None)
|
||||
.context("Error mounting the boot point")?;
|
||||
|
||||
Ok(mount_stack)
|
||||
|
Loading…
x
Reference in New Issue
Block a user