CI: Add windows clippy job and fix clippy errors (#330)
* CI: Run clippy on windows * Update cargo-clippy-before-script.sh for Windows * Pacify clippy
This commit is contained in:
parent
184ba6cb84
commit
261b3e9ee7
|
@ -6,6 +6,10 @@ os_name="$1"
|
||||||
|
|
||||||
case "$os_name" in
|
case "$os_name" in
|
||||||
"Windows")
|
"Windows")
|
||||||
|
vcpkg install openssl:x64-windows-static-md
|
||||||
|
vcpkg integrate install
|
||||||
|
choco install protoc
|
||||||
|
export PROTOC='C:\ProgramData\chocolatey\lib\protoc\tools\bin\protoc.exe'
|
||||||
;;
|
;;
|
||||||
"macOS")
|
"macOS")
|
||||||
brew install protobuf
|
brew install protobuf
|
||||||
|
|
|
@ -31,6 +31,7 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
- macos-latest-large
|
- macos-latest-large
|
||||||
|
- windows-latest
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
@ -53,6 +54,7 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
- macos-latest-large
|
- macos-latest-large
|
||||||
|
- windows-latest
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
|
@ -205,6 +205,9 @@ where
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn set_perms(dst: &Path, _mode: u32) -> std::io::Result<()> {
|
fn set_perms(dst: &Path, _mode: u32) -> std::io::Result<()> {
|
||||||
let mut perm = fs::metadata(dst)?.permissions();
|
let mut perm = fs::metadata(dst)?.permissions();
|
||||||
|
// This is OK for Windows, but clippy doesn't realize we're doing this
|
||||||
|
// only on Windows.
|
||||||
|
#[allow(clippy::permissions_set_readonly_false)]
|
||||||
perm.set_readonly(false);
|
perm.set_readonly(false);
|
||||||
fs::set_permissions(dst, perm)
|
fs::set_permissions(dst, perm)
|
||||||
}
|
}
|
||||||
|
|
|
@ -451,9 +451,13 @@ mod tests {
|
||||||
plugin: P,
|
plugin: P,
|
||||||
config_path: &'static str,
|
config_path: &'static str,
|
||||||
) -> (LoadedGeyserPlugin, Library, &'static str) {
|
) -> (LoadedGeyserPlugin, Library, &'static str) {
|
||||||
|
#[cfg(unix)]
|
||||||
|
let library = libloading::os::unix::Library::this();
|
||||||
|
#[cfg(windows)]
|
||||||
|
let library = libloading::os::windows::Library::this().unwrap();
|
||||||
(
|
(
|
||||||
LoadedGeyserPlugin::new(Box::new(plugin), None),
|
LoadedGeyserPlugin::new(Box::new(plugin), None),
|
||||||
Library::from(libloading::os::unix::Library::this()),
|
Library::from(library),
|
||||||
config_path,
|
config_path,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -333,9 +333,7 @@ pub fn string_from_winreg_value(val: &winreg::RegValue) -> Option<String> {
|
||||||
let words = unsafe {
|
let words = unsafe {
|
||||||
slice::from_raw_parts(val.bytes.as_ptr() as *const u16, val.bytes.len() / 2)
|
slice::from_raw_parts(val.bytes.as_ptr() as *const u16, val.bytes.len() / 2)
|
||||||
};
|
};
|
||||||
let mut s = if let Ok(s) = String::from_utf16(words) {
|
let Ok(mut s) = String::from_utf16(words) else {
|
||||||
s
|
|
||||||
} else {
|
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
while s.ends_with('\u{0}') {
|
while s.ends_with('\u{0}') {
|
||||||
|
@ -392,11 +390,9 @@ fn add_to_path(new_path: &str) -> bool {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let old_path = if let Some(s) =
|
let Some(old_path) =
|
||||||
get_windows_path_var().unwrap_or_else(|err| panic!("Unable to get PATH: {}", err))
|
get_windows_path_var().unwrap_or_else(|err| panic!("Unable to get PATH: {}", err))
|
||||||
{
|
else {
|
||||||
s
|
|
||||||
} else {
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
#![cfg(feature = "sbf_c")]
|
#![cfg(feature = "sbf_c")]
|
||||||
#![allow(clippy::uninlined_format_args)]
|
#![allow(clippy::uninlined_format_args)]
|
||||||
#![allow(clippy::arithmetic_side_effects)]
|
#![allow(clippy::arithmetic_side_effects)]
|
||||||
#![cfg_attr(not(target_arch = "x86_64"), allow(dead_code, unused_imports))]
|
#![cfg_attr(
|
||||||
|
any(target_os = "windows", not(target_arch = "x86_64")),
|
||||||
|
allow(dead_code, unused_imports)
|
||||||
|
)]
|
||||||
|
|
||||||
use {
|
use {
|
||||||
solana_rbpf::memory_region::MemoryState,
|
solana_rbpf::memory_region::MemoryState,
|
||||||
|
@ -103,7 +106,7 @@ fn bench_program_create_executable(bencher: &mut Bencher) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(all(not(target_os = "windows"), target_arch = "x86_64"))]
|
||||||
fn bench_program_alu(bencher: &mut Bencher) {
|
fn bench_program_alu(bencher: &mut Bencher) {
|
||||||
let ns_per_s = 1000000000;
|
let ns_per_s = 1000000000;
|
||||||
let one_million = 1000000;
|
let one_million = 1000000;
|
||||||
|
|
|
@ -878,8 +878,6 @@ mod tests {
|
||||||
panic!("Unexpected RequestMiddlewareAction variant");
|
panic!("Unexpected RequestMiddlewareAction variant");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
|
||||||
{
|
|
||||||
std::fs::remove_file(&genesis_path).unwrap();
|
std::fs::remove_file(&genesis_path).unwrap();
|
||||||
{
|
{
|
||||||
let mut file = std::fs::File::create(ledger_path.path().join("wrong")).unwrap();
|
let mut file = std::fs::File::create(ledger_path.path().join("wrong")).unwrap();
|
||||||
|
@ -897,5 +895,4 @@ mod tests {
|
||||||
panic!("Unexpected RequestMiddlewareAction variant");
|
panic!("Unexpected RequestMiddlewareAction variant");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue