From 4aa622b48b96c86634ad5e7a2d144dc502d60395 Mon Sep 17 00:00:00 2001 From: Chris Chou Date: Wed, 3 Jan 2024 19:31:09 +1300 Subject: [PATCH] feat[#7]: update ci workflow to build and test --- .github/workflows/ci.yml | 2 +- src/hooks/init.rs | 6 +--- src/hooks/src.rs | 2 +- src/utils/config.rs | 73 ++++++++++++++++++++++------------------ src/utils/pipeline.rs | 2 +- src/utils/script.rs | 4 +-- 6 files changed, 45 insertions(+), 44 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e0dc05..6e5d62f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -181,7 +181,7 @@ jobs: # # Build package # pwsh ./install/windows/choco/update.ps1 # env: - # STARSHIP_VERSION: v1.2.3 + # ORBITER_VERSION: v0.5.0 - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 diff --git a/src/hooks/init.rs b/src/hooks/init.rs index 121642d..dcaa21d 100644 --- a/src/hooks/init.rs +++ b/src/hooks/init.rs @@ -1,8 +1,4 @@ -use crate::utils::{ - config::{ShellSpecificCommand, SupportedShellSpecificCommand}, - script::*, - shells::SupportedShell, -}; +use crate::utils::{config::ShellSpecificCommand, script::*, shells::SupportedShell}; pub fn init( current_shell: &SupportedShell, diff --git a/src/hooks/src.rs b/src/hooks/src.rs index f1c4fb8..0870b8b 100644 --- a/src/hooks/src.rs +++ b/src/hooks/src.rs @@ -3,7 +3,7 @@ use glob::glob; use std::fs; use crate::utils::{ - config::{ShellSpecificSourceTarget, SourceTarget, SupportedShellSpecificSourceTarget}, + config::{ShellSpecificSourceTarget, SourceTarget}, shells::SupportedShell, }; diff --git a/src/utils/config.rs b/src/utils/config.rs index f558834..6e3dd57 100644 --- a/src/utils/config.rs +++ b/src/utils/config.rs @@ -128,7 +128,6 @@ pub struct SupportedShellSpecificSourceTarget { pub wincmd: Option, } - #[derive(Debug, PartialEq, Serialize, Deserialize)] #[serde(untagged)] pub enum ShellSpecificSourceTarget { @@ -136,7 +135,6 @@ pub enum ShellSpecificSourceTarget { ShellSpecific(SupportedShellSpecificSourceTarget), } - #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct SupportedShellSpecificEvaluatable { pub sh: Option, @@ -154,7 +152,6 @@ pub enum ShellSpecificEvaluatable { ShellSpecific(SupportedShellSpecificEvaluatable), } - #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct Payload { // The `string_or_struct` function delegates deserialization to a type's @@ -232,11 +229,15 @@ mod parse_tests { resource: AdaptiveResource::Standard(Resource::Location("https://download.mozilla.org/?product=firefox-devedition-latest-ssl&os=linux64&lang=en-US".to_string())), install: Some(ShellSpecificCommand::ShellSpecific(SupportedShellSpecificCommand{ sh:Some( OSSpecificCommand::OSSpecific( SupportedOSSpecificCommand{ - macos: Some("./GitAhead*.sh --include-subdir".to_string()), - linux: None, windows: None}, - )), - zsh: None, bash: None, fish: None, powershell: None, wincmd: None} - ), + macos: Some("./GitAhead*.sh --include-subdir".to_string()), + linux: None, windows: None} + )), + zsh: None, + bash: None, + fish: None, + powershell: None, + wincmd: None + }), ), update: None, src: None, @@ -281,13 +282,20 @@ mod parse_tests { from_release: None, binary_pattern: None, })), - install: Some(ShellSpecificCommand::ShellSpecific(SupportedShellSpecificCommand{ - sh: Some(OSSpecificCommand::OSSpecific( SupportedOSSpecificCommand{ - macos: Some("./GitAhead*.sh --include-subdir".to_string()), - linux: None, windows: None }) - ), - zsh: None, bash: None, fish: None, powershell: None, wincmd: None - })), + install: Some(ShellSpecificCommand::ShellSpecific( + SupportedShellSpecificCommand { + sh: Some(OSSpecificCommand::OSSpecific(SupportedOSSpecificCommand { + macos: Some("./GitAhead*.sh --include-subdir".to_string()), + linux: None, + windows: None, + })), + zsh: None, + bash: None, + fish: None, + powershell: None, + wincmd: None, + }, + )), update: None, src: None, extract: None, @@ -320,9 +328,9 @@ mod parse_tests { let actual_resource = &actual.first().unwrap().resource; if let AdaptiveResource::Standard(res) = actual_resource { if let Resource::Repo(rel) = res { - return assert_eq!(rel.binary_pattern.as_ref().unwrap(), expected) + return assert_eq!(rel.binary_pattern.as_ref().unwrap(), expected); } - } + } panic!("No binary_pattern") } @@ -346,15 +354,7 @@ mod parse_tests { let actual: Vec = parse(config).unwrap(); let expected = "*.tar.gz"; - assert_eq!( - actual - .first() - .unwrap() - .extract - .as_ref() - .unwrap(), - expected - ) + assert_eq!(actual.first().unwrap().extract.as_ref().unwrap(), expected) } #[test] @@ -428,13 +428,20 @@ mod from_reader_tests { from_release: None, binary_pattern: None, })), - install:Some(ShellSpecificCommand::ShellSpecific( SupportedShellSpecificCommand { - sh: Some(OSSpecificCommand::OSSpecific( SupportedOSSpecificCommand { - macos: Some("./GitAhead*.sh --include-subdir".to_string()), - linux: None, windows: None, - })), - zsh: None, bash: None, fish: None, powershell: None, wincmd: None, - })), + install: Some(ShellSpecificCommand::ShellSpecific( + SupportedShellSpecificCommand { + sh: Some(OSSpecificCommand::OSSpecific(SupportedOSSpecificCommand { + macos: Some("./GitAhead*.sh --include-subdir".to_string()), + linux: None, + windows: None, + })), + zsh: None, + bash: None, + fish: None, + powershell: None, + wincmd: None, + }, + )), update: None, src: None, extract: None, diff --git a/src/utils/pipeline.rs b/src/utils/pipeline.rs index b6d5760..c75f6d0 100644 --- a/src/utils/pipeline.rs +++ b/src/utils/pipeline.rs @@ -131,7 +131,7 @@ pub fn update_payload(payload: &Payload) -> Result<(), Box