Skip to content

Commit

Permalink
Add cargo xtask test
Browse files Browse the repository at this point in the history
  • Loading branch information
ajeetdsouza committed Sep 17, 2021
1 parent a60a305 commit 58313c6
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 34 deletions.
18 changes: 10 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- markdownlint-disable MD024 -->
<!-- markdownlint-disable-file MD024 -->

# Changelog

Expand Down Expand Up @@ -112,13 +112,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Removed

- Aliases: `za`, `zq`, `zqi`, `zr`, `zri`. These are trivial aliases to zoxide that can easily be defined manually, and aren't very useful to most users.
- Aliases: `za`, `zq`, `zqi`, `zr`, `zri`. These are trivial aliases that can
easily be defined manually, and aren't very useful to most users.

## [0.5.0] - 2020-10-30

### Added

- Inaccessible directories are no longer removed; zoxide can now remember paths on removable devices.
- `$_ZO_EXCLUDE_DIRS` now supports globs.
- `zoxide init` now defines `__zoxide_z*` functions that can be aliased as needed.
- Support for the [xonsh](https://xon.sh/) shell.
Expand All @@ -135,6 +135,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed

- Deprecated PWD hooks for POSIX shells.
- Lazy deletion for inaccessible directories.

## [0.4.3] - 2020-07-04

Expand All @@ -153,7 +154,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Increased default value of `$_ZO_MAXAGE` to `10000`.
- Symlinks are treated as separate directories by default, this can be changed by setting `_ZO_RESOLVE_SYMLINKS=1`.
- Symlinks are treated as separate directories by default, this can be changed
by setting `_ZO_RESOLVE_SYMLINKS=1`.

### Removed

Expand Down Expand Up @@ -182,7 +184,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- `zoxide remove` now throws an error if there was no match in the database.
- Interactive mode in `zoxide` no longer throws an error if `fzf` exits gracefully.
- Interactive mode in `zoxide` no longer errors out if `fzf` exits gracefully.
- Canonicalize to regular paths instead of UNC paths on Windows.
- `zoxide init` now uses PWD hooks by default for better performance.
- `$_ZO_ECHO` now only works when set to `1`.
Expand All @@ -203,7 +205,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Query output no longer has the `query:` prefix, so `$(zq)` can now be used as an argument to commands.
- `zoxide query` output no longer has the `query:` prefix.

### Fixed

Expand All @@ -214,7 +216,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Automatic migration from `v0.2.x` databases.
- `$_ZO_EXCLUDE_DIRS` to prevent certain directories from being added to the database.
- `$_ZO_EXCLUDE_DIRS` to prevent directories from being added to the database.
- Support for POSIX-compliant shells.

### Changed
Expand All @@ -225,7 +227,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Achieve thread safety using unique temporary database file names for each `zoxide` instance.
- Thread safety using unique tempfile names for each `zoxide` instance.
- Incomprehensive "could not allocate" message on database corruption.

## [0.2.2] - 2020-03-20
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<!-- markdownlint-disable MD033 -->
<!-- markdownlint-configure-file {
"MD013": {
"code_blocks": false,
"tables": false
},
"MD033": false
} -->

# `zoxide`

Expand Down
20 changes: 11 additions & 9 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,36 @@ let
rust = import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/ad311f5bb5c5ef475985f1e0f264e831470a8510.tar.gz");
pkgs = import <nixpkgs> { overlays = [ rust ]; };
pkgs-latest = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/b4692e4197869c42c46d77e31af7e687e1892f55.tar.gz") {};
pkgs-python = pkgs-latest.python3.withPackages (pkgs: [ pkgs.black pkgs.mypy pkgs.pylint ]);
in
pkgs.mkShell {
buildInputs = [
# Rust
pkgs.rust-bin.stable.latest.default

# Shells
pkgs-latest.bash
pkgs-latest.dash
pkgs-latest.elvish
pkgs-latest.nushell
pkgs-latest.fish
pkgs-latest.powershell
pkgs-latest.nushell
pkgs-latest.xonsh
pkgs-latest.zsh
pkgs.bash
pkgs.dash
pkgs.powershell
pkgs.zsh

# Linters
pkgs-latest.cargo-audit
pkgs-latest.nodePackages.markdownlint-cli
pkgs-latest.python3Packages.black
pkgs-latest.python3Packages.mypy
pkgs-latest.python3Packages.pylint
pkgs-latest.shellcheck
pkgs-latest.shfmt
pkgs-python

# Dependencies
pkgs.cacert
pkgs.libiconv
pkgs-latest.fzf
pkgs-latest.git
pkgs.fzf
pkgs.git
];

RUST_BACKTRACE = 1;
Expand Down
16 changes: 7 additions & 9 deletions templates/powershell.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,13 @@ function __zoxide_cd($dir) {
# Hook to add new entries to the database.
function __zoxide_hook {
$result = __zoxide_pwd
if ($result -ne $null) {
if ($null -ne $result) {
zoxide add -- $result
}
}

# Initialize hook.
{# Initialize $__zoxide_hooked if it does not exist. Removing this will cause
# an unset variable error in StrictMode. #}
$__zoxide_hooked = (Get-Variable __zoxide_hooked -ValueOnly -ErrorAction SilentlyContinue)
if ($__zoxide_hooked -ne 1) {
$__zoxide_hooked = 1
if (-Not (Get-Command '__zoxide_hook' -ErrorAction SilentlyContinue)) {
{%- match hook %}
{%- when InitHook::None %}
{{ not_configured }}
Expand All @@ -53,7 +49,8 @@ if ($__zoxide_hooked -ne 1) {
$ExecutionContext.InvokeCommand.LocationChangedAction = {
$null = __zoxide_hook
}
} else {
}
else {
Write-Error ("`n" +
"zoxide: PWD hooks are not supported below powershell 6.`n" +
" Use 'zoxide init powershell --hook prompt' instead.")
Expand All @@ -79,9 +76,10 @@ function __zoxide_z {
}
else {
$result = __zoxide_pwd
if ($result -ne $null) {
if ($null -ne $result) {
$result = zoxide query --exclude $result -- @args
} else {
}
else {
$result = zoxide query -- @args
}
if ($LASTEXITCODE -eq 0) {
Expand Down
22 changes: 15 additions & 7 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
use std::process::Command;

use clap::{ArgEnum, Clap};
use clap::Clap;

#[derive(Clap, Debug)]
struct App {
#[clap(arg_enum)]
#[clap(subcommand)]
task: Task,
#[clap(long)]
nix: Option<bool>,
}

#[derive(ArgEnum, Debug)]
#[derive(Clap, Debug)]
enum Task {
CI,
Test { keywords: Vec<String> },
}

fn run(args: &[&str], nix: bool) {
Expand All @@ -32,17 +33,24 @@ fn run(args: &[&str], nix: bool) {

fn main() {
let app = App::parse();
let color = if std::env::var_os("CI").is_some() { "--color=always" } else { "--color=auto" };
let nix = app.nix.unwrap_or_else(|| Command::new("nix-shell").arg("--version").output().is_ok());
let run = |args: &[&str]| run(args, nix);
match app.task {
Task::CI => {
let color = if std::env::var_os("CI").is_some() { "--color=always" } else { "" };
run(&["cargo", "fmt", "--", "--check", color, "--files-with-diff"]);
run(&["cargo", "check", "--all-features", color]);
run(&["cargo", "clippy", "--all-features", color, "--", "--deny=warnings", "--deny=clippy::all"]);
run(&["cargo", "clippy", "--all-features", color, "--", "--deny=clippy::all", "--deny=warnings"]);
run(&["cargo", "test", if nix { "--all-features" } else { "" }, color, "--no-fail-fast"]);
// color: https://github.com/rustsec/rustsec/pull/436
run(&["cargo", "audit", "--deny=warnings"]);
run(&["cargo", "audit", color, "--deny=warnings"]);
if nix {
run(&["markdownlint", "--ignore-path=.gitignore", "."]);
}
}
Task::Test { keywords } => {
let mut args = vec!["cargo", "test", if nix { "--all-features" } else { "" }, "--no-fail-fast", "--"];
args.extend(keywords.iter().map(String::as_str));
run(&args);
}
}
}

0 comments on commit 58313c6

Please sign in to comment.