Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure CI and fix clippy warnings #5

Merged
merged 3 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: cargo
directory: /
schedule:
interval: weekly
labels:
- 'dependencies'
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
labels:
- 'github actions'
27 changes: 27 additions & 0 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Dependencies
on:
push:
branches-ignore:
- 'dependabot/**'
- 'releases/**'
paths:
- 'Cargo.toml'
- 'deny.toml'
pull_request:
paths:
- 'Cargo.toml'
- 'deny.toml'
schedule:
- cron: '0 0 * * 0'
env:
CARGO_TERM_COLOR: always
jobs:
dependencies:
name: Check dependencies
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v3

- name: Check dependencies
uses: EmbarkStudios/cargo-deny-action@v1
67 changes: 67 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Main
on:
push:
branches-ignore:
- 'releases/**'
- 'dependabot/**'
paths-ignore:
- '**.md'
- '.gitignore'
- '.github/dependabot.yml'
pull_request:
paths-ignore:
- '**.md'
- '.gitignore'
- '.github/dependabot.yml'
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Clone repo
uses: actions/checkout@v3

- name: Cache crates
uses: Swatinem/rust-cache@v1

- name: Test
uses: actions-rs/cargo@v1
with:
command: test

clippy:
name: Clippy
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Clone repo
uses: actions/checkout@v3

- name: Cache crates
uses: Swatinem/rust-cache@v1

- name: Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --no-deps --all-features -- -D warnings

format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v3

- name: Format
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use standard_paths::*;
use standard_paths::LocationType::*;

fn main() {
let sp = StandardPaths::new_with_names("app", "org");
let sp = StandardPaths::new("app", "org");
println!("App data location: {:?}", sp.writable_location(AppLocalDataLocation));
}
```
21 changes: 21 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[advisories]
unmaintained = "deny"
yanked = "deny"
notice = "deny"

[licenses]
copyleft = "deny"
allow-osi-fsf-free = "either"

[[licenses.clarify]]
name = "stretch"
expression = "MIT"
license-files = []

[bans]
multiple-versions = "allow"
wildcards = "deny"

[sources]
unknown-registry = "deny"
unknown-git = "deny"
17 changes: 11 additions & 6 deletions examples/find_executables.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
extern crate standard_paths;

use standard_paths::*;
use std::env;
use std::process;
use standard_paths::*;

fn main() {
let args = env::args().skip(1).collect::<Vec<_>>();
Expand Down Expand Up @@ -30,11 +30,16 @@ fn main() {
for exe in args {
let fexe = format!("{:>1$}", exe, ind);
match StandardPaths::find_executable(exe.clone()) {
Some(paths) => println!("{}: \"{}\"", fexe, paths.iter()
.map(|p| p.to_str().unwrap())
.collect::<Vec<_>>()
.join("\", \"")),
_ => println!("{}: not found", fexe)
Some(paths) => println!(
"{}: \"{}\"",
fexe,
paths
.iter()
.map(|p| p.to_str().unwrap())
.collect::<Vec<_>>()
.join("\", \"")
),
_ => println!("{}: not found", fexe),
}
}
}
71 changes: 41 additions & 30 deletions examples/folderid_generator.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
fn main() {
let ids = vec![
("FOLDERID_Desktop", "B4BFCC3A-DB2C-424C-B029-7FE99A87C641"), // DesktopLocation
("FOLDERID_Documents", "FDD39AD0-238F-46AF-ADB4-6C85480369C7"), // DocumentsLocation
("FOLDERID_Fonts", "FD228CB7-AE11-4AE3-864C-16F3910AB8FE"), // FontsLocation
("FOLDERID_Programs", "A77F5D77-2E2B-44C3-A6A2-ABA601054A51"), // ApplicationsLocation
("FOLDERID_Music", "4BD8D571-6D19-48D3-BE97-422220080E43"), // MusicLocation
("FOLDERID_Videos", "18989B1D-99B5-455B-841C-AB7C74E4DDFC"), // MoviesLocation
("FOLDERID_Pictures", "33E28130-4E1E-4676-835A-98395C3BC3BB"), // PicturesLocation
("FOLDERID_Downloads", "374DE290-123F-4565-9164-39C4925E467B"), // DownloadLocation
("FOLDERID_LocalAppData", "F1B32785-6FBA-4FCF-9D55-7B8E7F157091"), // AppLocalDataLocation, AppLocalDataLocation,
// GenericDataLocation, ConfigLocation,
// GenericConfigLocation, AppConfigLocation
("FOLDERID_RoamingAppData", "3EB685DB-65F9-4CF6-A03A-E3EF65729F3D"), // AppDataLocation
("FOLDERID_ProgramData", "62AB5D82-FDC1-4DC3-A9DD-070D1D495D97") // ConfigLocation, AppConfigLocation,
// AppDataLocation, AppLocalDataLocation,
// GenericConfigLocation, GenericDataLocation
let ids = vec![
("FOLDERID_Desktop", "B4BFCC3A-DB2C-424C-B029-7FE99A87C641"), // DesktopLocation
("FOLDERID_Documents", "FDD39AD0-238F-46AF-ADB4-6C85480369C7"), // DocumentsLocation
("FOLDERID_Fonts", "FD228CB7-AE11-4AE3-864C-16F3910AB8FE"), // FontsLocation
("FOLDERID_Programs", "A77F5D77-2E2B-44C3-A6A2-ABA601054A51"), // ApplicationsLocation
("FOLDERID_Music", "4BD8D571-6D19-48D3-BE97-422220080E43"), // MusicLocation
("FOLDERID_Videos", "18989B1D-99B5-455B-841C-AB7C74E4DDFC"), // MoviesLocation
("FOLDERID_Pictures", "33E28130-4E1E-4676-835A-98395C3BC3BB"), // PicturesLocation
("FOLDERID_Downloads", "374DE290-123F-4565-9164-39C4925E467B"), // DownloadLocation
(
"FOLDERID_LocalAppData",
"F1B32785-6FBA-4FCF-9D55-7B8E7F157091",
), // AppLocalDataLocation, AppLocalDataLocation,
// GenericDataLocation, ConfigLocation,
// GenericConfigLocation, AppConfigLocation
(
"FOLDERID_RoamingAppData",
"3EB685DB-65F9-4CF6-A03A-E3EF65729F3D",
), // AppDataLocation
(
"FOLDERID_ProgramData",
"62AB5D82-FDC1-4DC3-A9DD-070D1D495D97",
), // ConfigLocation, AppConfigLocation,
// AppDataLocation, AppLocalDataLocation,
// GenericConfigLocation, GenericDataLocation
];

for &(name, guid) in &ids {
println!("\
println!(
"\
/// https://msdn.microsoft.com/en-us/library/dd378457.aspx#{name}
#[allow(non_upper_case_globals)]
const {name}: GUID = GUID {{
Expand All @@ -27,17 +37,18 @@ const {name}: GUID = GUID {{
Data3: 0x{},
Data4: [0x{}, 0x{}, 0x{}, 0x{}, 0x{}, 0x{}, 0x{}, 0x{}]
}};\n",
guid.get(..8).unwrap(),
guid.get(9..13).unwrap(),
guid.get(14..18).unwrap(),
guid.get(19..21).unwrap(),
guid.get(21..23).unwrap(),
guid.get(24..26).unwrap(),
guid.get(26..28).unwrap(),
guid.get(28..30).unwrap(),
guid.get(30..32).unwrap(),
guid.get(32..34).unwrap(),
guid.get(34..36).unwrap(),
name = name);
guid.get(..8).unwrap(),
guid.get(9..13).unwrap(),
guid.get(14..18).unwrap(),
guid.get(19..21).unwrap(),
guid.get(21..23).unwrap(),
guid.get(24..26).unwrap(),
guid.get(26..28).unwrap(),
guid.get(28..30).unwrap(),
guid.get(30..32).unwrap(),
guid.get(32..34).unwrap(),
guid.get(34..36).unwrap(),
name = name
);
}
}
}
62 changes: 33 additions & 29 deletions examples/list_paths.rs
Original file line number Diff line number Diff line change
@@ -1,50 +1,54 @@
extern crate standard_paths;

use standard_paths::*;
use standard_paths::LocationType::*;
use standard_paths::*;

fn main() {
let locations = vec![
("Home", HomeLocation),
("Desktop", DesktopLocation),
("Documents", DocumentsLocation),
("Download", DownloadLocation),
("Movies", MoviesLocation),
("Music", MusicLocation),
("Pictures", PicturesLocation),
("Applications", ApplicationsLocation),
("Fonts", FontsLocation),
("Runtime", RuntimeLocation),
("Temp", TempLocation),
("Generic Data", GenericDataLocation),
("App Data", AppDataLocation),
("App Local Data", AppLocalDataLocation),
("Generic Cache", GenericCacheLocation),
("App Cache", AppCacheLocation),
("Config", ConfigLocation),
("Generic Config", GenericConfigLocation),
("App Config", AppConfigLocation)
("Home", HomeLocation),
("Desktop", DesktopLocation),
("Documents", DocumentsLocation),
("Download", DownloadLocation),
("Movies", MoviesLocation),
("Music", MusicLocation),
("Pictures", PicturesLocation),
("Applications", ApplicationsLocation),
("Fonts", FontsLocation),
("Runtime", RuntimeLocation),
("Temp", TempLocation),
("Generic Data", GenericDataLocation),
("App Data", AppDataLocation),
("App Local Data", AppLocalDataLocation),
("Generic Cache", GenericCacheLocation),
("App Cache", AppCacheLocation),
("Config", ConfigLocation),
("Generic Config", GenericConfigLocation),
("App Config", AppConfigLocation),
];

let sl = StandardPaths::new_with_names("app", "org");
let sl = StandardPaths::new("app", "org");

println!("\nListing standard locations:");
for &(ref name, ref value) in &locations {
match sl.standard_locations(value.clone()) {
Ok(paths) => println!("{:>14}: \"{}\"", name, paths.iter()
.map(|p| p.to_str().unwrap())
.collect::<Vec<_>>()
.join("\", \"")
),
Err(err) => println!("{:>14}: {}", name, err)
Ok(paths) => println!(
"{:>14}: \"{}\"",
name,
paths
.iter()
.map(|p| p.to_str().unwrap())
.collect::<Vec<_>>()
.join("\", \"")
),
Err(err) => println!("{:>14}: {}", name, err),
}
}

println!("\nListing writable locations:");
for &(ref name, ref value) in &locations {
match sl.writable_location(value.clone()) {
Ok(path) => println!("{:>14}: \"{}\"", name, path.to_str().unwrap()),
Err(err) => println!("{:>14}: {}", name, err)
Err(err) => println!("{:>14}: {}", name, err),
}
}
}
Loading