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

Add support GitHub Actions #166

Closed
wants to merge 8 commits into from
Closed
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
78 changes: 78 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Rust

on:
pull_request:
push:

env:
CARGO_TERM_COLOR: always
CI: 1

jobs:
cargo-audit:
name: Audit Rust vulnerabilities
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: rust-audit-check
uses: actions-rs/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}

cargo-test:
name: Cargo Test
runs-on: ubuntu-latest

container:
image: archlinux:base-devel

steps:
- name: Install Packages
run: pacman -Syu rust clang gcc --noconfirm --needed
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Compile
run: cargo test --no-run --locked

- name: Test
run: cargo test

cargo-fmt:
name: Code Format
runs-on: ubuntu-latest

container:
image: archlinux:base-devel

steps:
- name: Install Packages
run: pacman -Syu rust clang gcc --noconfirm --needed
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check format
run: cargo fmt --all -- --check

cargo-clippy:
name: Clippy
runs-on: ubuntu-latest

container:
image: archlinux:base-devel

steps:
- name: Install Packages
run: pacman -Syu rust clang gcc --noconfirm --needed
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also why is the secret key needed for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only needed for forked repos. I will remove it before change to "Ready for Review" state.

8 changes: 4 additions & 4 deletions src/devel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ pub async fn possible_devel_updates(config: &Config) -> Result<Vec<String>> {
let mut pkgbases: HashMap<&str, Vec<alpm::Package>> = HashMap::new();

for pkg in db.pkgs().iter() {
let name = pkg.base().unwrap_or(pkg.name());
let name = pkg.base().unwrap_or_else(|| pkg.name());
pkgbases.entry(name).or_default().push(pkg);
}

Expand Down Expand Up @@ -305,13 +305,13 @@ pub async fn filter_devel_updates(
let db = config.alpm.localdb();

for pkg in db.pkgs().iter() {
let name = pkg.base().unwrap_or(pkg.name());
let name = pkg.base().unwrap_or_else(|| pkg.name());
pkgbases.entry(name).or_default().push(pkg);
}

config.raur.cache_info(cache, &updates).await?;
let updates = updates
.into_iter()
.iter()
.map(|u| pkgbases.remove(u.as_str()).unwrap())
.collect::<Vec<_>>();

Expand Down Expand Up @@ -418,7 +418,7 @@ pub fn load_devel_info(config: &Config) -> Result<Option<DevelInfo>> {
}

for pkg in config.alpm.localdb().pkgs().iter() {
let name = pkg.base().unwrap_or(pkg.name());
let name = pkg.base().unwrap_or_else(|| pkg.name());
pkgbases.entry(name).or_default().push(pkg);
}

Expand Down
3 changes: 1 addition & 2 deletions src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,10 @@ fn repo_pkgbuilds<'a>(config: &Config, pkgs: &[Targ<'a>]) -> Result<i32> {
pub fn print_download(_config: &Config, n: usize, total: usize, pkg: &str) {
let total = total.to_string();
println!(
" ({:>padding$}/{}) {}: {}",
" ({:>padding$}/{}) downloading: {}",
n,
total,
//config.color.action.paint("::"),
"downloading",
pkg,
padding = total.len(),
);
Expand Down
7 changes: 3 additions & 4 deletions src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use crate::{args, exec, news};
use std::collections::hash_map::Entry;
use std::collections::{HashMap, HashSet};
use std::io::{stdin, stdout, BufRead, Write};
use std::iter::FromIterator;
use std::path::Path;
use std::process::{Command, Stdio};

Expand Down Expand Up @@ -166,7 +165,7 @@ pub async fn install(config: &mut Config, targets_str: &[String]) -> Result<i32>
c.bold.paint("Resolving dependencies...")
);

let mut actions = resolver.resolve_targets(&targets).await?;
let actions = resolver.resolve_targets(&targets).await?;

if !actions.build.is_empty() && nix::unistd::getuid().is_root() {
bail!("can't install AUR package as root");
Expand Down Expand Up @@ -202,7 +201,7 @@ pub async fn install(config: &mut Config, targets_str: &[String]) -> Result<i32>
return Ok(1);
}

let bases = Bases::from_iter(actions.iter_build_pkgs().map(|p| p.pkg.clone()));
let bases = actions.iter_build_pkgs().map(|p| p.pkg.clone()).collect();
let srcinfos = download_pkgbuilds(config, &bases).await?;

let ret = review(config, &actions, &srcinfos, &bases)?;
Expand All @@ -211,7 +210,7 @@ pub async fn install(config: &mut Config, targets_str: &[String]) -> Result<i32>
}

let mut err = if !config.chroot {
repo_install(config, &mut actions.install)
repo_install(config, &actions.install)
} else {
Ok(0)
};
Expand Down
18 changes: 8 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,23 +308,21 @@ fn handle_repo(config: &mut Config) -> Result<i32> {
let installed = if local_pkg.version() != pkg.version() {
format!(" [installed: {}]", local_pkg.version())
} else {
format!(" [installed]")
" [installed]".to_string()
};
print!("{}", installedc.paint(installed));
}
println!();
}
}
} else if config.quiet {
println!("{}", repo.name);
} else {
if config.quiet {
println!("{}", repo.name);
} else {
println!(
"{} {}",
repo.name,
repo.servers[0].trim_start_matches("file://")
);
}
println!(
"{} {}",
repo.name,
repo.servers[0].trim_start_matches("file://")
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn remove(config: &mut Config) -> Result<i32> {
.targets
.iter()
.filter_map(|pkg| db.pkg(pkg.as_str()).ok())
.map(|pkg| pkg.base().unwrap_or(pkg.name()))
.map(|pkg| pkg.base().unwrap_or_else(|| pkg.name()))
.collect::<Vec<_>>();

let mut db_map: HashMap<String, Vec<String>> = HashMap::new();
Expand Down
4 changes: 2 additions & 2 deletions src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ pub async fn search_install(config: &mut Config) -> Result<i32> {
}
AnyPkg::AurPkg(pkg) => {
let n = format!("{:>pad$}", n + 1, pad = pad);
print!("{}{} ", "", c.number_menu.paint(n));
print!("{} ", c.number_menu.paint(n));
print_pkg(config, pkg, false)
}
};
Expand All @@ -279,7 +279,7 @@ pub async fn search_install(config: &mut Config) -> Result<i32> {
}
AnyPkg::AurPkg(pkg) => {
let n = format!("{:>pad$}", n + 1, pad = pad);
print!("{}{} ", "", c.number_menu.paint(n));
print!("{} ", c.number_menu.paint(n));
print_pkg(config, pkg, false)
}
};
Expand Down
6 changes: 2 additions & 4 deletions src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ pub async fn list(config: &Config) -> Result<i32> {
let mut show_aur = args.targets.is_empty() && config.mode != "repo";
let dbs = config.alpm.syncdbs();

if args.targets.is_empty() {
if config.mode != "aur" {
args.targets = dbs.iter().map(|db| db.name()).collect();
}
if args.targets.is_empty() && config.mode != "aur" {
args.targets = dbs.iter().map(|db| db.name()).collect();
};

if config.aur_namespace() {
Expand Down
12 changes: 5 additions & 7 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,11 @@ pub fn split_repo_aur_targets<'a, T: AsTarg>(
} else if config.mode == "repo" {
local.push(targ);
} else if let Some(repo) = targ.repo {
if config.aur_namespace() && repo == "aur" {
aur.push(targ);
} else if repo == "__aur__" {
// hack for search install
aur.push(targ);
} else {
local.push(targ);
match repo {
"aur" if config.aur_namespace() => aur.push(targ),
// __aur__ -- hack for search install
"__aur__" => aur.push(targ),
_ => local.push(targ),
}
} else if config
.alpm
Expand Down