From df9ff44956084c9edbe6473e6328b254a1f1043e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Sun, 8 Sep 2019 03:09:05 -0500 Subject: [PATCH 1/8] Filesystem change directory coverage. --- tests/command_cd_tests.rs | 132 ++++++++++++++++++++++++++++---------- tests/helpers/mod.rs | 8 ++- 2 files changed, 106 insertions(+), 34 deletions(-) diff --git a/tests/command_cd_tests.rs b/tests/command_cd_tests.rs index 7c1a9f6b85..c2d7329f37 100644 --- a/tests/command_cd_tests.rs +++ b/tests/command_cd_tests.rs @@ -1,9 +1,107 @@ mod helpers; use helpers::Playground; +use std::path::PathBuf; #[test] -fn cd_directory_not_found() { +fn filesytem_change_from_current_directory_using_relative_path() { + Playground::setup("cd_test_1", |dirs, _| { + let actual = nu!( + cwd: dirs.root(), + r#" + cd cd_test_1 + pwd | echo $it + "# + ); + + assert_eq!(PathBuf::from(actual), *dirs.test()); + }) +} + +#[test] +fn filesystem_change_from_current_directory_using_absolute_path() { + Playground::setup("cd_test_2", |dirs, _| { + let actual = nu!( + cwd: dirs.test(), + r#" + cd {} + pwd | echo $it + "#, + dirs.formats() + ); + + assert_eq!(PathBuf::from(actual), dirs.formats()); + }) +} + +#[test] +fn filesystem_switch_back_to_previous_working_directory() { + Playground::setup("cd_test_3", |dirs, sandbox| { + sandbox.mkdir("odin"); + + let actual = nu!( + cwd: dirs.test().join("odin"), + r#" + cd {} + cd - + pwd | echo $it + "#, + dirs.test() + ); + + assert_eq!(PathBuf::from(actual), dirs.test().join("odin")); + }) +} + +#[test] +fn filesystem_change_current_directory_to_parent_directory() { + Playground::setup("cd_test_4", |dirs, _| { + let actual = nu!( + cwd: dirs.test(), + r#" + cd .. + pwd | echo $it + "# + ); + + assert_eq!(PathBuf::from(actual), *dirs.root()); + }) +} + +#[test] +fn file_system_change_to_home_directory() { + Playground::setup("cd_test_5", |dirs, _| { + let actual = nu!( + cwd: dirs.test(), + r#" + cd ~ + pwd | echo $it + "# + ); + + assert_eq!(PathBuf::from(actual), dirs::home_dir().unwrap()); + }) +} + +#[test] +fn filesystem_change_to_a_directory_containing_spaces() { + Playground::setup("cd_test_6", |dirs, sandbox| { + sandbox.mkdir("robalino turner katz"); + + let actual = nu!( + cwd: dirs.test(), + r#" + cd "robalino turner katz" + pwd | echo $it + "# + ); + + assert_eq!(PathBuf::from(actual), dirs.test().join("robalino turner katz")); + }) +} + +#[test] +fn filesystem_directory_not_found() { let actual = nu_error!( cwd: "tests/fixtures", "cd dir_that_does_not_exist" @@ -12,35 +110,3 @@ fn cd_directory_not_found() { assert!(actual.contains("dir_that_does_not_exist")); assert!(actual.contains("directory not found")); } - -#[test] -fn cd_back() { - Playground::setup("cd_test_back", |dirs, sandbox| { - sandbox - .mkdir("andres") - .mkdir("odin"); - - let odin = dirs.test().join("odin"); - let andres = dirs.test().join("andres"); - - nu!( - cwd: dirs.test(), - r#" - cd odin - mkdir a - cd ../andres - mkdir b - cd - - mkdir c - mkdir - - cd - - mkdir d - "# - ); - - assert!(odin.join("a").exists()); - assert!(andres.join("b").exists()); - assert!(odin.join("c").exists()); - assert!(odin.join("-").join("d").exists()); - }) -} diff --git a/tests/helpers/mod.rs b/tests/helpers/mod.rs index 6aa7cb67b9..1c2bfef0e0 100644 --- a/tests/helpers/mod.rs +++ b/tests/helpers/mod.rs @@ -227,8 +227,14 @@ impl Playground { playground_root.join(topic).display() )); + let root = + dunce::canonicalize(playground_root).expect(&format!( + "Couldn't canonicalize tests root path {}", + playground_root.display() + )); + let dirs = Dirs { - root: PathBuf::from(playground_root), + root, test, fixtures, }; From 77c2e4200ee3211b3e1f06edb2df53399e20578b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Sun, 8 Sep 2019 04:55:49 -0500 Subject: [PATCH 2/8] Filesystem cd refactor/cleanup. --- src/shell/filesystem_shell.rs | 54 +++++++++++------------------------ tests/command_cd_tests.rs | 27 ++++++++++++++---- 2 files changed, 39 insertions(+), 42 deletions(-) diff --git a/src/shell/filesystem_shell.rs b/src/shell/filesystem_shell.rs index 4a0d5b3f7d..221b088684 100644 --- a/src/shell/filesystem_shell.rs +++ b/src/shell/filesystem_shell.rs @@ -185,29 +185,20 @@ impl Shell for FilesystemShell { }, Some(v) => { let target = v.as_path()?; - let path = PathBuf::from(self.path()); - match dunce::canonicalize(path.join(&target).as_path()) { - Ok(p) => p, - Err(_) => { - let error = Err(ShellError::labeled_error( - "Can not change to directory", - "directory not found", - v.span().clone(), - )); - if let Some(t) = target.to_str() { - if t == "-" { - match dunce::canonicalize(PathBuf::from(self.last_path.clone()).as_path()) { - Ok(p) => p, - Err(_) => { - return error; - } - } - } else { - return error; - } - } else { - return error; + if PathBuf::from("-") == target { + PathBuf::from(&self.last_path) + } else { + let path = PathBuf::from(self.path()); + + match dunce::canonicalize(path.join(&target)) { + Ok(p) => p, + Err(_) => { + return Err(ShellError::labeled_error( + "Can not change to directory", + "directory not found", + v.span().clone(), + )) } } } @@ -215,23 +206,12 @@ impl Shell for FilesystemShell { }; let mut stream = VecDeque::new(); - match std::env::set_current_dir(&path) { - Ok(_) => {} - Err(_) => { - if let Some(directory) = args.nth(0) { - return Err(ShellError::labeled_error( - "Can not change to directory", - "directory not found", - directory.span(), - )); - } else { - return Err(ShellError::string("Can not change to directory")); - } - } - } - stream.push_back(ReturnSuccess::change_cwd( + + stream.push_back( + ReturnSuccess::change_cwd( path.to_string_lossy().to_string(), )); + Ok(stream.into()) } diff --git a/tests/command_cd_tests.rs b/tests/command_cd_tests.rs index c2d7329f37..ca066f660a 100644 --- a/tests/command_cd_tests.rs +++ b/tests/command_cd_tests.rs @@ -1,6 +1,6 @@ mod helpers; -use helpers::Playground; +use helpers::{Playground, Stub::*}; use std::path::PathBuf; #[test] @@ -53,9 +53,26 @@ fn filesystem_switch_back_to_previous_working_directory() { }) } +#[test] +fn filesytem_change_from_current_directory_using_relative_path_and_dash() { + Playground::setup("cd_test_4", |dirs, sandbox| { + sandbox.within("odin").mkdir("-"); // + + let actual = nu!( + cwd: dirs.test(), + r#" + cd odin/- + pwd | echo $it + "# + ); + + assert_eq!(PathBuf::from(actual), dirs.test().join("odin").join("-")); + }) +} + #[test] fn filesystem_change_current_directory_to_parent_directory() { - Playground::setup("cd_test_4", |dirs, _| { + Playground::setup("cd_test_5", |dirs, _| { let actual = nu!( cwd: dirs.test(), r#" @@ -70,7 +87,7 @@ fn filesystem_change_current_directory_to_parent_directory() { #[test] fn file_system_change_to_home_directory() { - Playground::setup("cd_test_5", |dirs, _| { + Playground::setup("cd_test_6", |dirs, _| { let actual = nu!( cwd: dirs.test(), r#" @@ -85,7 +102,7 @@ fn file_system_change_to_home_directory() { #[test] fn filesystem_change_to_a_directory_containing_spaces() { - Playground::setup("cd_test_6", |dirs, sandbox| { + Playground::setup("cd_test_7", |dirs, sandbox| { sandbox.mkdir("robalino turner katz"); let actual = nu!( @@ -109,4 +126,4 @@ fn filesystem_directory_not_found() { assert!(actual.contains("dir_that_does_not_exist")); assert!(actual.contains("directory not found")); -} +} \ No newline at end of file From f770409a6079dd3f616848b8486dfae4da59816a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Sun, 8 Sep 2019 05:15:55 -0500 Subject: [PATCH 3/8] cd '-' valueshell implementation and valueshell refactorings. --- src/shell/filesystem_shell.rs | 4 +- src/shell/value_shell.rs | 27 ++-- tests/command_cd_tests.rs | 243 +++++++++++++++++++++++++++++++++- 3 files changed, 258 insertions(+), 16 deletions(-) diff --git a/src/shell/filesystem_shell.rs b/src/shell/filesystem_shell.rs index 221b088684..16cbf513f8 100644 --- a/src/shell/filesystem_shell.rs +++ b/src/shell/filesystem_shell.rs @@ -15,7 +15,7 @@ use std::path::{Path, PathBuf}; pub struct FilesystemShell { pub(crate) path: String, - last_path: String, + pub(crate) last_path: String, completer: NuCompleter, hinter: HistoryHinter, } @@ -211,7 +211,7 @@ impl Shell for FilesystemShell { ReturnSuccess::change_cwd( path.to_string_lossy().to_string(), )); - + Ok(stream.into()) } diff --git a/src/shell/value_shell.rs b/src/shell/value_shell.rs index e14d5603a6..010c7ae08e 100644 --- a/src/shell/value_shell.rs +++ b/src/shell/value_shell.rs @@ -10,16 +10,24 @@ use crate::utils::ValueStructure; use std::ffi::OsStr; use std::path::{Path, PathBuf}; -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct ValueShell { pub(crate) path: String, + pub(crate) last_path: String, pub(crate) value: Tagged, } +impl std::fmt::Debug for ValueShell { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "ValueShell @ {}", self.path) + } +} + impl ValueShell { pub fn new(value: Tagged) -> ValueShell { ValueShell { path: "/".to_string(), + last_path: "/".to_string(), value, } } @@ -76,7 +84,7 @@ impl Shell for ValueShell { } fn homedir(&self) -> Option { - dirs::home_dir() + Some(PathBuf::from("/")) } fn ls(&self, args: EvaluatedWholeStreamCommandArgs) -> Result { @@ -126,6 +134,8 @@ impl Shell for ValueShell { if target == PathBuf::from("..") { cwd.pop(); + } else if target == PathBuf::from("-") { + cwd = PathBuf::from(&self.last_path); } else { match target.to_str() { Some(target) => match target.chars().nth(0) { @@ -200,19 +210,16 @@ impl Shell for ValueShell { } fn pwd(&self, args: EvaluatedWholeStreamCommandArgs) -> Result { - let path = PathBuf::from(&self.path()); - let mut stream = VecDeque::new(); - stream.push_back(ReturnSuccess::value( - Value::Primitive(Primitive::String(path.to_string_lossy().to_string())) - .simple_spanned(args.call_info.name_span), - )); - + stream.push_back(ReturnSuccess::value(Tagged::from_item( + Value::string(self.path()), + args.call_info.name_span, + ))); Ok(stream.into()) } fn set_path(&mut self, path: String) { - let _ = std::env::set_current_dir(&path); + self.last_path = self.path.clone(); self.path = path.clone(); } diff --git a/tests/command_cd_tests.rs b/tests/command_cd_tests.rs index ca066f660a..b9ad8ca12d 100644 --- a/tests/command_cd_tests.rs +++ b/tests/command_cd_tests.rs @@ -4,7 +4,7 @@ use helpers::{Playground, Stub::*}; use std::path::PathBuf; #[test] -fn filesytem_change_from_current_directory_using_relative_path() { +fn filesystem_change_from_current_directory_using_relative_path() { Playground::setup("cd_test_1", |dirs, _| { let actual = nu!( cwd: dirs.root(), @@ -56,7 +56,7 @@ fn filesystem_switch_back_to_previous_working_directory() { #[test] fn filesytem_change_from_current_directory_using_relative_path_and_dash() { Playground::setup("cd_test_4", |dirs, sandbox| { - sandbox.within("odin").mkdir("-"); // + sandbox.within("odin").mkdir("-"); let actual = nu!( cwd: dirs.test(), @@ -86,7 +86,7 @@ fn filesystem_change_current_directory_to_parent_directory() { } #[test] -fn file_system_change_to_home_directory() { +fn filesystem_change_to_home_directory() { Playground::setup("cd_test_6", |dirs, _| { let actual = nu!( cwd: dirs.test(), @@ -126,4 +126,239 @@ fn filesystem_directory_not_found() { assert!(actual.contains("dir_that_does_not_exist")); assert!(actual.contains("directory not found")); -} \ No newline at end of file +} + + +#[test] +fn valuesystem_change_from_current_path_using_relative_path() { + Playground::setup("cd_test_8", |dirs, sandbox| { + sandbox + .with_files(vec![FileWithContent( + "sample.toml", + r#" + [[bin]] + path = "src/plugins/turner.rs" + + [[bin]] + path = "src/plugins/robalino.rs" + + [[bin]] + path = "src/plugins/katz.rs" + "# + )]); + + let actual = nu!( + cwd: dirs.test(), + r#" + enter sample.toml + cd bin + pwd | echo $it + exit + "# + ); + + assert_eq!(PathBuf::from(actual), PathBuf::from("/bin")); + }) +} + +#[test] +fn valuesystem_change_from_current_path_using_absolute_path() { + Playground::setup("cd_test_9", |dirs, sandbox| { + sandbox + .with_files(vec![FileWithContent( + "sample.toml", + r#" + [dependencies] + turner-ts = "0.1.1" + robalino-tkd = "0.0.1" + katz-ember = "0.2.3" + + [[bin]] + path = "src/plugins/arepa.rs" + + [[bin]] + path = "src/plugins/bbq.rs" + "# + )]); + + let actual = nu!( + cwd: dirs.test(), + r#" + enter sample.toml + cd bin + cd /dependencies + pwd | echo $it + exit + "# + ); + + assert_eq!(PathBuf::from(actual), PathBuf::from("/dependencies")); + }) +} + +#[test] +fn valuesystem_switch_back_to_previous_working_path() { + Playground::setup("cd_test_10", |dirs, sandbox| { + sandbox + .with_files(vec![FileWithContent( + "sample.toml", + r#" + [dependencies] + turner-ts = "0.1.1" + robalino-tkd = "0.0.1" + katz-ember = "0.2.3" + odin-gf = "0.2.1" + + [[bin]] + path = "src/plugins/arepa.rs" + + [[bin]] + path = "src/plugins/bbq.rs" + "# + )]); + + let actual = nu!( + cwd: dirs.test(), + r#" + enter sample.toml + cd dependencies + cd /bin + cd - + pwd | echo $it + exit + "# + ); + + assert_eq!(PathBuf::from(actual), PathBuf::from("/dependencies")); + }) +} + +#[test] +fn valuesystem_change_from_current_path_using_relative_path_and_dash() { + Playground::setup("cd_test_11", |dirs, sandbox| { + sandbox + .with_files(vec![FileWithContent( + "sample.toml", + r#" + [package] + - = ["Yehuda Katz ", "Jonathan Turner ", "Andrés N. Robalino "] + + [[bin]] + path = "src/plugins/arepa.rs" + + [[bin]] + path = "src/plugins/bbq.rs" + "# + )]); + + let actual = nu!( + cwd: dirs.test(), + r#" + enter sample.toml + cd package/- + cd /bin + cd - + pwd | echo $it + exit + "# + ); + + assert_eq!(PathBuf::from(actual), PathBuf::from("/package/-")); + }) +} + + +#[test] +fn valuesystem_change_current_path_to_parent_path() { + Playground::setup("cd_test_12", |dirs, sandbox| { + sandbox + .with_files(vec![FileWithContent( + "sample.toml", + r#" + [package] + emberenios = ["Yehuda Katz ", "Jonathan Turner ", "Andrés N. Robalino "] + "# + )]); + + let actual = nu!( + cwd: dirs.test(), + r#" + enter sample.toml + cd package/emberenios + cd .. + pwd | echo $it + exit + "# + ); + + assert_eq!(PathBuf::from(actual), PathBuf::from("/package")); + }) +} + +#[test] +fn valuesystem_change_to_home_directory() { + Playground::setup("cd_test_13", |dirs, sandbox| { + sandbox + .with_files(vec![FileWithContent( + "sample.toml", + r#" + [paquete] + el = "pollo loco" + "# + )]); + + let actual = nu!( + cwd: dirs.test(), + r#" + enter sample.toml + cd paquete + cd ~ + pwd | echo $it + exit + "# + ); + + assert_eq!(PathBuf::from(actual), PathBuf::from("/")); + }) +} + +#[test] +fn valuesystem_change_to_a_path_containing_spaces() { + Playground::setup("cd_test_14", |dirs, sandbox| { + sandbox + .with_files(vec![FileWithContent( + "sample.toml", + r#" + ["pa que te"] + el = "pollo loco" + "# + )]); + + let actual = nu!( + cwd: dirs.test(), + r#" + enter sample.toml + cd "pa que te" + pwd | echo $it + exit + "# + ); + + assert_eq!(PathBuf::from(actual), PathBuf::from("/").join("pa que te")); + }) +} + +#[test] +fn valuesystem_path_not_found() { + let actual = nu_error!( + cwd: "tests/fixtures/formats", + r#" + enter cargo_sample.toml + cd im_a_path_that_does_not_exist + exit + "# + ); + + assert!(actual.contains("Can not change to path inside")); + assert!(actual.contains("No such path exists")); +} From 160bd7c535383c965f45fcc7d0d59572fcdf45df Mon Sep 17 00:00:00 2001 From: Milan Lesichkov Date: Sun, 8 Sep 2019 18:57:28 +0100 Subject: [PATCH 4/8] Spell check fixed --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e80a51e600..28f5c15656 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ A modern shell for the GitHub era # Status -This project has reached a minimum-viable product level of quality. While contributors dogfood it as their daily driver, it may be instable for some commands. Future releases will work fill out missing features and improve stability. Its design is also subject to change as it matures. +This project has reached a minimum-viable product level of quality. While contributors dogfood it as their daily driver, it may be unstable for some commands. Future releases will work fill out missing features and improve stability. Its design is also subject to change as it matures. Nu comes with a set of built-in commands (listed below). If a command is unknown, the command will shell-out and execute it (using cmd on Windows or bash on Linux and MacOS), correctly passing through stdin, stdout and stderr, so things like your daily git workflows and even `vim` will work just fine. From 24ba0d93c704719f719ce698ad69c75132210205 Mon Sep 17 00:00:00 2001 From: Vanessa Sochat Date: Sun, 8 Sep 2019 13:02:55 -0400 Subject: [PATCH 5/8] test building akin to azure-pipelines (without release) to hopefully shorten circleci builds Signed-off-by: Vanessa Sochat --- .circleci/config.yml | 16 +--------------- docker/Dockerfile | 1 + docker/Dockerfile.nu-base | 22 +++++++++++++++------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 80dd80017d..e1c665e444 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,15 +9,6 @@ version: 2.1 commands: - check_token: - description: Check that QUAY_TOKEN is provided in environment - steps: - - run: - if [[ -z "${QUAY_TOKEN}" ]]; then - echo "QUAY_TOKEN is undefined. Add to CircleCI environment to continue." - exit 1; - fi - pull_cache: description: Pulls Quay.io docker images usable for our cache steps: @@ -46,7 +37,6 @@ workflows: ignore: - master before_build: - - check_token - pull_cache after_build: - run: @@ -76,7 +66,6 @@ workflows: tags: only: /^v.*/ before_build: - - check_token - pull_cache after_build: - run: @@ -90,7 +79,6 @@ workflows: echo "Version for Docker tag is ${DOCKER_TAG}" docker tag quay.io/nushell/nu-base:latest quay.io/nushell/nu-base:${DOCKER_TAG} docker tag quay.io/nushell/nu:latest quay.io/nushell/nu:${DOCKER_TAG} - docker login -u="nushell+circleci" -p="${QUAY_TOKEN}" quay.io docker push quay.io/nushell/nu-base docker push quay.io/nushell/nu @@ -105,9 +93,8 @@ workflows: registry: quay.io tag: devel dockerfile: docker/Dockerfile.nu-base - extra_build_args: --cache-from=quay.io/nushell/nu-base:latest,quay.io/nushell/nu:latest + extra_build_args: --cache-from=quay.io/nushell/nu-base:latest,quay.io/nushell/nu:latest --build-arg RELEASE=true before_build: - - check_token - pull_cache filters: branches: @@ -120,6 +107,5 @@ workflows: - run: name: Publish Development Docker Tags command: | - docker login -u="nushell+circleci" -p="${QUAY_TOKEN}" quay.io docker push quay.io/nushell/nu-base:devel docker push quay.io/nushell/nu:devel diff --git a/docker/Dockerfile b/docker/Dockerfile index d8bc40f657..fa089e77d2 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -3,3 +3,4 @@ FROM quay.io/nushell/nu-base:${FROMTAG} as base FROM rust:1.37-slim COPY --from=base /usr/local/bin/nu /usr/local/bin/nu ENTRYPOINT ["nu"] +CMD ["-l", "info"] diff --git a/docker/Dockerfile.nu-base b/docker/Dockerfile.nu-base index b322efb5b2..faba0213a5 100644 --- a/docker/Dockerfile.nu-base +++ b/docker/Dockerfile.nu-base @@ -1,4 +1,4 @@ -FROM rust:1.37-slim +FROM ubuntu:16.04 # docker build -f docker/Dockerfile.nu-base -t nushell/nu-base . # docker run -it nushell/nu-base @@ -7,12 +7,20 @@ ENV DEBIAN_FRONTEND noninteractive RUN apt-get update && apt-get install -y libssl-dev \ libxcb-composite0-dev \ libx11-dev \ - pkg-config - -RUN USER=root cargo new --bin /code + pkg-config \ + curl +ARG RELEASE=false WORKDIR /code -ADD . /code -RUN cargo build --release && cargo run --release -RUN cp target/release/nu /usr/local/bin +COPY ./rust-toolchain ./rust-toolchain +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path --default-toolchain `cat rust-toolchain` +ENV PATH=/root/.cargo/bin:$PATH +COPY . /code +RUN echo "##vso[task.prependpath]/root/.cargo/bin" && \ + rustc -Vv && \ + if $RELEASE; then cargo build --release && cargo run --release; \ + cp target/release/nu /usr/local/bin; \ + else cargo build; \ + cp target/debug/nu /usr/local/bin; fi; ENTRYPOINT ["nu"] +CMD ["-l", "info"] From da6d6467f3145e37d0954d196119c8655e8f15b1 Mon Sep 17 00:00:00 2001 From: Vanessa Sochat Date: Sun, 8 Sep 2019 17:45:26 -0400 Subject: [PATCH 6/8] adding to circle config to test nightly builds Signed-off-by: Vanessa Sochat --- .circleci/config.yml | 58 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e1c665e444..dbc60e702f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,11 +10,15 @@ version: 2.1 commands: pull_cache: - description: Pulls Quay.io docker images usable for our cache + description: Pulls Quay.io docker images (latest) for our cache + parameters: + tag: + type: string + default: "devel" steps: - - run: docker pull quay.io/nushell/nu:latest - - run: docker pull quay.io/nushell/nu-base:latest - + - run: echo "Tag is << parameters.tag >>" + - run: docker pull quay.io/nushell/nu:<< parameters.tag >> + - run: docker pull quay.io/nushell/nu-base:<< parameters.tag >> orbs: # https://circleci.com/orbs/registry/orb/circleci/docker @@ -31,7 +35,7 @@ workflows: image: nushell/nu-base tag: latest dockerfile: docker/Dockerfile.nu-base - extra_build_args: --cache-from=quay.io/nushell/nu-base:latest,quay.io/nushell/nu:latest + extra_build_args: --cache-from=quay.io/nushell/nu-base:devel filters: branches: ignore: @@ -53,20 +57,21 @@ workflows: build_with_deploy: jobs: - # Deploy versioned and latest images on tags (releases) only. + # Deploy versioned and latest images on tags (releases) only - builds --release. - docker/publish: image: nushell/nu-base registry: quay.io tag: latest dockerfile: docker/Dockerfile.nu-base - extra_build_args: --cache-from=quay.io/nushell/nu-base:latest,quay.io/nushell/nu:latest + extra_build_args: --cache-from=quay.io/nushell/nu-base:latest,quay.io/nushell/nu:latest --build-arg RELEASE=true filters: branches: ignore: /.*/ tags: only: /^v.*/ before_build: - - pull_cache + - run: docker pull quay.io/nushell/nu:latest + - run: docker pull quay.io/nushell/nu-base:latest after_build: - run: name: Build Multistage (smaller) container @@ -83,7 +88,7 @@ workflows: docker push quay.io/nushell/nu - # publish devel to Docker Hub on merge to master + # publish devel to Docker Hub on merge to master (doesn't build --release) build_with_deploy_devel: jobs: @@ -93,7 +98,7 @@ workflows: registry: quay.io tag: devel dockerfile: docker/Dockerfile.nu-base - extra_build_args: --cache-from=quay.io/nushell/nu-base:latest,quay.io/nushell/nu:latest --build-arg RELEASE=true + extra_build_args: --cache-from=quay.io/nushell/nu-base:devel before_build: - pull_cache filters: @@ -109,3 +114,36 @@ workflows: command: | docker push quay.io/nushell/nu-base:devel docker push quay.io/nushell/nu:devel + + nightly: + jobs: + - docker/publish: + image: nushell/nu-base + registry: quay.io + tag: nightly + dockerfile: docker/Dockerfile.nu-base + extra_build_args: --cache-from=quay.io/nushell/nu-base:nightly --build-arg RELEASE=true + filters: + branches: + only: master + before_build: + - run: docker pull quay.io/nushell/nu:nightly + - run: docker pull quay.io/nushell/nu-base:nightly + after_build: + - run: + name: Build Multistage (smaller) container + command: | + docker build -f docker/Dockerfile -t quay.io/nushell/nu:nightly . + - run: + name: Publish Nightly Nushell Containers + command: | + docker push quay.io/nushell/nu-base:nightly + docker push quay.io/nushell/nu:nightly + + triggers: + - schedule: + cron: "0 22 * * *" + filters: + branches: + only: + - master From 1277bfe0fb256059232dbbfd565bd4ffa9b5c6c6 Mon Sep 17 00:00:00 2001 From: est31 Date: Mon, 9 Sep 2019 13:02:25 +0200 Subject: [PATCH 7/8] Fix setting configuration params Fixes #627 Fixes a regression caused by #579, specifically commit cc8872b4eec3f39896ccb11d9c25a30a79c04dd7 . The code was intended to perform a comparison between the wanted output type and "Tagged" in order to be able to provide a special-cased path for Tagged. When I wrote the code, I used "name" as a variable name and only later realized that it shadowed the "name" param to the function, so I renamed it to type_name, but forgot to change the comparison. This broke the special-casing, as the name param only contains the name of the struct without generics (like "Tagged"), while `std::any::type_name` (in the current implementation) contains the full paths of the struct including all generic params (like "nu::object::meta::Tagged"). --- src/parser/deserializer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser/deserializer.rs b/src/parser/deserializer.rs index 33a23189f1..d4d492966c 100644 --- a/src/parser/deserializer.rs +++ b/src/parser/deserializer.rs @@ -328,7 +328,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut ConfigDeserializer<'de> { let type_name = std::any::type_name::(); let tagged_val_name = std::any::type_name::>(); - if name == tagged_val_name { + if type_name == tagged_val_name { return visit::, _>(value.val, name, fields, visitor); } From 1d3483b59015d9cfe67de624cad0e8bbb600fe95 Mon Sep 17 00:00:00 2001 From: est31 Date: Mon, 9 Sep 2019 13:39:43 +0200 Subject: [PATCH 8/8] Add a test --- src/parser/deserializer.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/parser/deserializer.rs b/src/parser/deserializer.rs index d4d492966c..d5427766b5 100644 --- a/src/parser/deserializer.rs +++ b/src/parser/deserializer.rs @@ -467,3 +467,27 @@ impl<'a, 'de: 'a> de::SeqAccess<'de> for StructDeserializer<'a, 'de> { return Some(self.fields.len()); } } + +#[cfg(test)] +mod tests { + use super::*; + use std::any::type_name; + #[test] + fn check_type_name_properties() { + // This ensures that certain properties for the + // std::any::type_name function hold, that + // this code relies on. The type_name docs explicitly + // mention that the actual format of the output + // is unspecified and change is likely. + // This test makes sure that such change is detected + // by this test failing, and not things silently breaking. + // Specifically, we rely on this behaviour further above + // in the file to special case Tagged parsing. + let tuple = type_name::<()>(); + let tagged_tuple = type_name::>(); + let tagged_value = type_name::>(); + assert!(tuple != tagged_tuple); + assert!(tuple != tagged_value); + assert!(tagged_tuple != tagged_value); + } +}