From 6ca829c52e3cb86652ec6e95cf0c834a7a54b515 Mon Sep 17 00:00:00 2001 From: Joe Bellus Date: Thu, 23 Jun 2022 00:41:01 -0400 Subject: [PATCH 01/15] Added drone configuration --- .drone.yml | 9 +++++ Cargo.lock | 102 ++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 82 insertions(+), 29 deletions(-) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..47cff1f --- /dev/null +++ b/.drone.yml @@ -0,0 +1,9 @@ +kind: pipeline +name: default + +steps: +- name: test + image: rust:1.30 + commands: + - cargo build --verbose --all + - cargo test --verbose --all \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index a668fc0..d3381b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,10 +59,20 @@ dependencies = [ ] [[package]] -name = "arkham" -version = "0.1.0" +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" dependencies = [ - "console", + "memchr", +] + +[[package]] +name = "arkham" +version = "0.1.1" +dependencies = [ + "crossterm", + "textwrap", ] [[package]] @@ -197,21 +207,6 @@ dependencies = [ "serde_yaml", ] -[[package]] -name = "console" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3993e6445baa160675931ec041a5e03ca84b9c6e32a056150d3aa2bdda0a1f45" -dependencies = [ - "encode_unicode", - "lazy_static", - "libc", - "regex", - "terminal_size", - "unicode-width", - "winapi", -] - [[package]] name = "crossbeam-channel" version = "0.5.1" @@ -232,18 +227,38 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "crossterm" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c85525306c4291d1b73ce93c8acf9c339f9b213aef6c1d85c3830cbf1c16325c" +dependencies = [ + "bitflags", + "crossterm_winapi", + "futures-core", + "libc", + "mio", + "parking_lot", + "signal-hook", + "signal-hook-mio", + "winapi", +] + +[[package]] +name = "crossterm_winapi" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ae1b35a484aa10e07fe0638d02301c5ad24de82d310ccbd2f3693da5f09bf1c" +dependencies = [ + "winapi", +] + [[package]] name = "dtoa" version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" -[[package]] -name = "encode_unicode" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" - [[package]] name = "event-listener" version = "2.5.1" @@ -579,6 +594,8 @@ version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" dependencies = [ + "aho-corasick", + "memchr", "regex-syntax", ] @@ -636,6 +653,17 @@ dependencies = [ "signal-hook-registry", ] +[[package]] +name = "signal-hook-mio" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" +dependencies = [ + "libc", + "mio", + "signal-hook", +] + [[package]] name = "signal-hook-registry" version = "1.4.0" @@ -657,6 +685,12 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" +[[package]] +name = "smawk" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" + [[package]] name = "socket2" version = "0.4.2" @@ -679,13 +713,14 @@ dependencies = [ ] [[package]] -name = "terminal_size" -version = "0.1.17" +name = "textwrap" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" +checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80" dependencies = [ - "libc", - "winapi", + "smawk", + "unicode-linebreak", + "unicode-width", ] [[package]] @@ -720,6 +755,15 @@ dependencies = [ "tokio", ] +[[package]] +name = "unicode-linebreak" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a52dcaab0c48d931f7cc8ef826fa51690a08e1ea55117ef26f89864f532383f" +dependencies = [ + "regex", +] + [[package]] name = "unicode-width" version = "0.1.9" -- 2.40.1 From 666dafb6af2a6e7364e6f2d0c6d0e65d1e1e1ada Mon Sep 17 00:00:00 2001 From: Joe Bellus Date: Thu, 23 Jun 2022 00:44:52 -0400 Subject: [PATCH 02/15] Updated to rust 1.6 and regenerated lock file --- .drone.yml | 2 +- Cargo.lock | 338 +++++++++++++++++++++++++++++++---------------------- 2 files changed, 201 insertions(+), 139 deletions(-) diff --git a/.drone.yml b/.drone.yml index 47cff1f..883ab99 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,7 +3,7 @@ name: default steps: - name: test - image: rust:1.30 + image: rust:1.60 commands: - cargo build --verbose --all - cargo test --verbose --all \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index d3381b8..d1c146c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,7 +19,7 @@ dependencies = [ "futures-util", "log", "once_cell", - "parking_lot", + "parking_lot 0.11.2", "pin-project-lite", "smallvec", "tokio", @@ -38,9 +38,9 @@ dependencies = [ [[package]] name = "actix-rt" -version = "2.4.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a0c218d0a17c120f10ee0c69c9f0c45d87319e8f66b1f065e8412b612fc3e24" +checksum = "7ea16c295198e958ef31930a6ef37d0fb64e9ca3b6116e6b93a8bdae96ee1000" dependencies = [ "actix-macros", "futures-core", @@ -88,9 +88,9 @@ dependencies = [ [[package]] name = "async-io" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a811e6a479f2439f0c04038796b5cfb3d2ad56c230e0f2d3f7b04d68cfee607b" +checksum = "e5e18f61464ae81cde0a23e713ae8fd299580c54d697a35820cfd0625b8b0e07" dependencies = [ "concurrent-queue", "futures-lite", @@ -107,9 +107,9 @@ dependencies = [ [[package]] name = "async-process" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83137067e3a2a6a06d67168e49e68a0957d215410473a740cea95a2425c0b7c6" +checksum = "cf2c06e30a24e8c78a3987d07f0930edf76ef35e027e7bdb063fccafdad1f60c" dependencies = [ "async-io", "blocking", @@ -124,9 +124,9 @@ dependencies = [ [[package]] name = "async-task" -version = "4.0.3" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0" +checksum = "30696a84d817107fc028e049980e09d5e140e8da8f1caeb17e8e950658a3cea9" [[package]] name = "atomic-waker" @@ -136,9 +136,9 @@ checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" [[package]] name = "autocfg" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bitflags" @@ -148,9 +148,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "blocking" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046e47d4b2d391b1f6f8b407b1deb8dee56c1852ccd868becf2710f601b5f427" +checksum = "c6ccb65d468978a086b69884437ded69a90faab3bbe6e67f242173ea728acccc" dependencies = [ "async-channel", "async-task", @@ -168,15 +168,15 @@ checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" [[package]] name = "cache-padded" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba" +checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" [[package]] name = "cc" -version = "1.0.72" +version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" [[package]] name = "cfg-if" @@ -209,9 +209,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.1" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +checksum = "4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c" dependencies = [ "cfg-if", "crossbeam-utils", @@ -219,12 +219,12 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.5" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +checksum = "8ff1f980957787286a554052d03c7aee98d99cc32e09f6d45f0a814133c87978" dependencies = [ "cfg-if", - "lazy_static", + "once_cell", ] [[package]] @@ -237,8 +237,8 @@ dependencies = [ "crossterm_winapi", "futures-core", "libc", - "mio", - "parking_lot", + "mio 0.7.14", + "parking_lot 0.11.2", "signal-hook", "signal-hook-mio", "winapi", @@ -253,17 +253,11 @@ dependencies = [ "winapi", ] -[[package]] -name = "dtoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" - [[package]] name = "event-listener" -version = "2.5.1" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" +checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71" [[package]] name = "expand_str" @@ -273,18 +267,18 @@ checksum = "f7bfbc9fbd454fca65e24c398c860da7bf0b76d0d4e62eb89e2e72d69e18a0e4" [[package]] name = "fastrand" -version = "1.5.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b394ed3d285a429378d3b384b9eb1285267e7df4b166df24b7a6939a04dc392e" +checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" dependencies = [ "instant", ] [[package]] name = "futures" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca" +checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" dependencies = [ "futures-channel", "futures-core", @@ -297,9 +291,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" +checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" dependencies = [ "futures-core", "futures-sink", @@ -307,15 +301,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" +checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" [[package]] name = "futures-executor" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c" +checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" dependencies = [ "futures-core", "futures-task", @@ -324,9 +318,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" +checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" [[package]] name = "futures-lite" @@ -345,12 +339,10 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb" +checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" dependencies = [ - "autocfg", - "proc-macro-hack", "proc-macro2", "quote", "syn", @@ -358,23 +350,22 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" +checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" [[package]] name = "futures-task" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" +checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" [[package]] name = "futures-util" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" +checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" dependencies = [ - "autocfg", "futures-channel", "futures-core", "futures-io", @@ -384,22 +375,20 @@ dependencies = [ "memchr", "pin-project-lite", "pin-utils", - "proc-macro-hack", - "proc-macro-nested", "slab", ] [[package]] name = "hashbrown" -version = "0.11.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3" [[package]] name = "indexmap" -version = "1.7.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ "autocfg", "hashbrown", @@ -414,17 +403,11 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" -version = "0.2.107" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbe5e23404da5b4f555ef85ebed98fb4083e55a00c317800bc2a50ede9f3d219" +checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" [[package]] name = "linked-hash-map" @@ -434,27 +417,28 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "lock_api" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" +checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" dependencies = [ + "autocfg", "scopeguard", ] [[package]] name = "log" -version = "0.4.14" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if", ] [[package]] name = "memchr" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "mio" @@ -469,6 +453,18 @@ dependencies = [ "winapi", ] +[[package]] +name = "mio" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys", +] + [[package]] name = "miow" version = "0.3.7" @@ -480,18 +476,18 @@ dependencies = [ [[package]] name = "ntapi" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" +checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" dependencies = [ "winapi", ] [[package]] name = "once_cell" -version = "1.8.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" [[package]] name = "parking" @@ -507,7 +503,17 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core", + "parking_lot_core 0.8.5", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.3", ] [[package]] @@ -525,10 +531,23 @@ dependencies = [ ] [[package]] -name = "pin-project-lite" -version = "0.2.7" +name = "parking_lot_core" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" +checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" [[package]] name = "pin-utils" @@ -549,50 +568,38 @@ dependencies = [ "winapi", ] -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - -[[package]] -name = "proc-macro-nested" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" - [[package]] name = "proc-macro2" -version = "1.0.32" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" +checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.10" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" +checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" -version = "0.2.10" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" dependencies = [ "bitflags", ] [[package]] name = "regex" -version = "1.5.4" +version = "1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" dependencies = [ "aho-corasick", "memchr", @@ -601,9 +608,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.25" +version = "0.6.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" + +[[package]] +name = "ryu" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" [[package]] name = "scopeguard" @@ -613,18 +626,18 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.130" +version = "1.0.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" +checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.130" +version = "1.0.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" +checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" dependencies = [ "proc-macro2", "quote", @@ -633,21 +646,21 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.8.21" +version = "0.8.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8c608a35705a5d3cdc9fbe403147647ff34b921f8e833e49306df898f9b20af" +checksum = "707d15895415db6628332b737c838b88c598522e4dc70647e59b72312924aebc" dependencies = [ - "dtoa", "indexmap", + "ryu", "serde", "yaml-rust", ] [[package]] name = "signal-hook" -version = "0.3.10" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c98891d737e271a2954825ef19e46bd16bdb98e2746f2eec4f7a4ef7946efd1" +checksum = "a253b5e89e2698464fc26b545c9edceb338e18a89effeeecfea192c3025be29d" dependencies = [ "libc", "signal-hook-registry", @@ -660,7 +673,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" dependencies = [ "libc", - "mio", + "mio 0.7.14", "signal-hook", ] @@ -675,15 +688,15 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" +checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" [[package]] name = "smallvec" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" [[package]] name = "smawk" @@ -693,9 +706,9 @@ checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" [[package]] name = "socket2" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" +checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" dependencies = [ "libc", "winapi", @@ -703,13 +716,13 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.81" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966" +checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] @@ -725,27 +738,27 @@ dependencies = [ [[package]] name = "tokio" -version = "1.13.0" +version = "1.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "588b2d10a336da58d877567cd8fb8a14b463e2104910f8132cd054b4b96e29ee" +checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439" dependencies = [ - "autocfg", "bytes", "libc", "memchr", - "mio", + "mio 0.8.4", "once_cell", - "parking_lot", + "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", + "socket2", "winapi", ] [[package]] name = "tokio-util" -version = "0.6.9" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e99e1983e5d376cd8eb4b66604d2e99e79f5bd988c3055891dcd8c9e2604cc0" +checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" dependencies = [ "bytes", "futures-core", @@ -755,6 +768,12 @@ dependencies = [ "tokio", ] +[[package]] +name = "unicode-ident" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" + [[package]] name = "unicode-linebreak" version = "0.1.2" @@ -770,18 +789,18 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" -[[package]] -name = "unicode-xid" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" - [[package]] name = "waker-fn" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "wepoll-ffi" version = "0.1.2" @@ -813,6 +832,49 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + [[package]] name = "yaml-rust" version = "0.4.5" -- 2.40.1 From 485df25fcaeb8ed73c2f9fa5b11a63d982ef0735 Mon Sep 17 00:00:00 2001 From: Joe Bellus Date: Sun, 25 Sep 2022 01:30:44 -0400 Subject: [PATCH 03/15] Full 2.0 refactor --- Cargo.lock | 195 ++++++---------- Cargo.toml | 8 +- conductor.yml | 28 +++ rustfmt.toml | 1 + src/definition.rs | 564 ++++++++++++++++++++++++++++++---------------- src/job.rs | 41 +++- src/main.rs | 50 ++-- src/runner.rs | 83 +++---- src/term.rs | 84 +++++++ 9 files changed, 656 insertions(+), 398 deletions(-) create mode 100644 conductor.yml create mode 100644 rustfmt.toml create mode 100644 src/term.rs diff --git a/Cargo.lock b/Cargo.lock index d1c146c..1e5a161 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,21 +59,19 @@ dependencies = [ ] [[package]] -name = "aho-corasick" -version = "0.7.18" +name = "ansi_term" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ - "memchr", + "winapi", ] [[package]] -name = "arkham" -version = "0.1.1" -dependencies = [ - "crossterm", - "textwrap", -] +name = "anyhow" +version = "1.0.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602" [[package]] name = "async-channel" @@ -199,10 +197,13 @@ version = "0.1.0" dependencies = [ "actix", "actix-rt", - "arkham", + "ansi_term", + "anyhow", "async-process", "expand_str", + "fake-tty", "futures", + "rand", "serde", "serde_yaml", ] @@ -227,32 +228,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "crossterm" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85525306c4291d1b73ce93c8acf9c339f9b213aef6c1d85c3830cbf1c16325c" -dependencies = [ - "bitflags", - "crossterm_winapi", - "futures-core", - "libc", - "mio 0.7.14", - "parking_lot 0.11.2", - "signal-hook", - "signal-hook-mio", - "winapi", -] - -[[package]] -name = "crossterm_winapi" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ae1b35a484aa10e07fe0638d02301c5ad24de82d310ccbd2f3693da5f09bf1c" -dependencies = [ - "winapi", -] - [[package]] name = "event-listener" version = "2.5.2" @@ -265,6 +240,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7bfbc9fbd454fca65e24c398c860da7bf0b76d0d4e62eb89e2e72d69e18a0e4" +[[package]] +name = "fake-tty" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa6c2a740a5d6940f90a0f13b5828440c2a7160bd1e235cf934d5df0e7a3e1ad" + [[package]] name = "fastrand" version = "1.7.0" @@ -378,6 +359,17 @@ dependencies = [ "slab", ] +[[package]] +name = "getrandom" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "hashbrown" version = "0.12.1" @@ -440,19 +432,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "mio" -version = "0.7.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" -dependencies = [ - "libc", - "log", - "miow", - "ntapi", - "winapi", -] - [[package]] name = "mio" version = "0.8.4" @@ -465,24 +444,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "miow" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" -dependencies = [ - "winapi", -] - -[[package]] -name = "ntapi" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" -dependencies = [ - "winapi", -] - [[package]] name = "once_cell" version = "1.12.0" @@ -568,6 +529,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "ppv-lite86" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + [[package]] name = "proc-macro2" version = "1.0.40" @@ -586,6 +553,36 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + [[package]] name = "redox_syscall" version = "0.2.13" @@ -595,23 +592,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "regex" -version = "1.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" - [[package]] name = "ryu" version = "1.0.10" @@ -666,17 +646,6 @@ dependencies = [ "signal-hook-registry", ] -[[package]] -name = "signal-hook-mio" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" -dependencies = [ - "libc", - "mio 0.7.14", - "signal-hook", -] - [[package]] name = "signal-hook-registry" version = "1.4.0" @@ -698,12 +667,6 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" -[[package]] -name = "smawk" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" - [[package]] name = "socket2" version = "0.4.4" @@ -725,17 +688,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "textwrap" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80" -dependencies = [ - "smawk", - "unicode-linebreak", - "unicode-width", -] - [[package]] name = "tokio" version = "1.19.2" @@ -745,7 +697,7 @@ dependencies = [ "bytes", "libc", "memchr", - "mio 0.8.4", + "mio", "once_cell", "parking_lot 0.12.1", "pin-project-lite", @@ -774,21 +726,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" -[[package]] -name = "unicode-linebreak" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a52dcaab0c48d931f7cc8ef826fa51690a08e1ea55117ef26f89864f532383f" -dependencies = [ - "regex", -] - -[[package]] -name = "unicode-width" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" - [[package]] name = "waker-fn" version = "1.1.0" diff --git a/Cargo.toml b/Cargo.toml index 1f7ac10..7d4912f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "conductor" version = "0.1.0" -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -13,6 +13,8 @@ actix = "0.12.0" actix-rt = "2.4.0" async-process = "1.3.0" futures = "0.3.17" -arkham = { path = "../arkham" } - +ansi_term = "0.12.1" +rand = "0.8.5" +anyhow = "1.0.65" +fake-tty = "0.3.1" diff --git a/conductor.yml b/conductor.yml new file mode 100644 index 0000000..fac6662 --- /dev/null +++ b/conductor.yml @@ -0,0 +1,28 @@ +groups: + main: + description: Main test group + components: + - ls + - currentdir + - envtest +components: + ls: + command: exa + tasks: + beforelist: + command: echo "before list" + currentdir: + command: pwd + envtest: + env: + FOO: one + command: "echo value: $FOO" + +tasks: + sleep: + command: echo "sleeping" + build-release: + command: cargo build --release + install: + before: build-release + command: cp target/release/conductor ~/.local/bin/ diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..5f22f2e --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +edition="2021" \ No newline at end of file diff --git a/src/definition.rs b/src/definition.rs index a89286a..1a129d9 100644 --- a/src/definition.rs +++ b/src/definition.rs @@ -1,30 +1,101 @@ use crate::job::{Job, Jobs}; +use rand::Rng; use serde::{Deserialize, Serialize}; use std::collections::HashMap; +#[derive(Serialize, Deserialize, Debug, Clone)] +#[serde(untagged)] +pub enum Command { + Single(String), + Multiple(Vec), +} + +impl Default for Command { + fn default() -> Self { + Self::Single(String::new()) + } +} + +impl From for Command { + fn from(source: String) -> Self { + Self::Single(source) + } +} + +impl From<&str> for Command { + fn from(source: &str) -> Self { + Self::Single(source.to_string()) + } +} + +impl std::fmt::Display for Command { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Single(v) => write!(f, "{}", &v), + Self::Multiple(v) => write!(f, "{}", &v.join(" && ")), + } + } +} + +#[derive(Serialize, Deserialize, Debug, Clone)] +#[serde(untagged)] +pub enum Dependencies { + Single(String), + Multiple(Vec), +} + +impl Dependencies { + pub fn to_vec(&self) -> Vec { + match self { + Dependencies::Single(v) => vec![v.clone()], + Dependencies::Multiple(v) => v.clone(), + } + } +} + +impl Default for Dependencies { + fn default() -> Self { + Self::Multiple(vec![]) + } +} + #[derive(Serialize, Deserialize, Default)] #[serde(default)] +/// Represents an entire configuration. This is deserialized from the complete conductor.yml file. pub struct Project { + /// The components that are defined within the project. This is stored as a map with the name of + /// of the component and its definition. pub components: HashMap, - pub groups: Vec, + /// The list of groups defined in the project. These groups are stored as a map with the name of + /// the group and its definition. + pub groups: HashMap, + /// A map of values that are populated into the environment for all components and tasks. + /// This value is inclusive with any environment variables defined in the individual task or + /// component. + /// + /// If the same value is defined here and within the task/component definition. The value + /// defined in the task/component will take priority. pub env: HashMap, - pub tasks: Vec, + /// The tasks defined inside project. This is stored as a map with the task name and task + /// definition + pub tasks: HashMap, } impl Project { + /// Retreive a list of jobs from the name of a task. This function expects the fully qualified + /// task name. For subcomponents that means component::task. + /// The jobs structure returned contains a seuqential execution list with all dependencies fn get_absolute_task(&self, name: &str) -> Option { self.tasks - .iter() - .find(|t| t.name == name) + .get(name) .map(|task| { - let job = self.build_project_task_job(task); + let job = self.build_project_task_job(name, task); let mut jobs = task .before + .to_vec() .iter() - .map(|name| self.get_absolute_task(name)) - .flatten() - .map(|jobs| jobs.to_vec()) - .flatten() + .flat_map(|name| self.get_absolute_task(name)) + .flat_map(|jobs| jobs.to_vec()) .collect::>(); jobs.push(job); Jobs::new(jobs) @@ -34,16 +105,16 @@ impl Project { component .tasks .iter() - .find(|t| format!("{}:{}", c_name, t.name) == name) - .map(|task| { - let job = self.build_component_task_job(c_name, component, task); + .find(|(t_name, _task)| format!("{}:{}", c_name, t_name) == name) + .map(|(t_name, task)| { + let job = + self.build_component_task_job(c_name, t_name, component, task); let mut jobs = task .before + .to_vec() .iter() - .map(|name| self.get_absolute_task(name)) - .flatten() - .map(|jobs| jobs.to_vec()) - .flatten() + .flat_map(|name| self.get_absolute_task(name)) + .flat_map(|jobs| jobs.to_vec()) .collect::>(); jobs.push(job); Jobs::new(jobs) @@ -52,48 +123,44 @@ impl Project { }) } + /// Retrieves a job based on a relative task definition. The task is found by the direct task name + /// and a component name separately. fn get_relative_task(&self, task_name: &str, component_name: &str) -> Option { if let Some(component) = self.components.get(component_name) { - component - .tasks - .iter() - .find(|t| t.name == task_name) - .map(|task| { - let job = self.build_component_task_job(component_name, component, task); - let mut jobs = task - .before - .iter() - .map(|name| self.get_by_name(name)) - .flatten() - .map(|jobs| jobs.to_vec()) - .flatten() - .collect::>(); - jobs.push(job); - Jobs::new(jobs) - }) + component.tasks.get(task_name).map(|task| { + let job = self.build_component_task_job(component_name, task_name, component, task); + let mut jobs = task + .before + .to_vec() + .iter() + .flat_map(|name| self.get_by_name(name)) + .flat_map(|jobs| jobs.to_vec()) + .collect::>(); + jobs.push(job); + Jobs::new(jobs) + }) } else { None } } + /// Retrieves a job based on a component definition fn get_component(&self, component_name: &str) -> Option { self.components.get(component_name).map(|c| { let component_job = self.build_component_job(component_name, c); let mut absolute_tasks = c .before + .to_vec() .iter() - .map(|name| self.get_absolute_task(name)) - .flatten() - .map(|jobs| jobs.to_vec()) - .flatten() + .flat_map(|name| self.get_absolute_task(name)) + .flat_map(|jobs| jobs.to_vec()) .collect::>(); let mut relative_tasks = c .before + .to_vec() .iter() - .map(|task_name| self.get_relative_task(task_name, &component_name)) - .flatten() - .map(|jobs| jobs.to_vec()) - .flatten() + .flat_map(|task_name| self.get_relative_task(task_name, component_name)) + .flat_map(|jobs| jobs.to_vec()) .collect::>(); absolute_tasks.append(&mut relative_tasks); @@ -102,39 +169,49 @@ impl Project { }) } + /// Retrieves a vector of jobs based on a group definition. + /// The return value is similar to `get_jobplan`, its is effectively a two-dimensional + /// array representing parallel and sequential jobs. fn get_group(&self, name: &str) -> Option> { - self.groups.iter().find(|g| g.name == name).map(|group| { + self.groups.get(name).map(|group| { group .components .iter() - .map(|name| self.get_by_name(&name)) - .flatten() + .flat_map(|name| self.get_by_name(name)) .collect() }) } + /// Converts a component definition to a job definition fn build_component_job(&self, name: &str, c: &Component) -> Job { let mut env = self.env.clone(); env.extend(c.env.clone()); Job { name: name.to_string(), + command: c.command.clone(), + color: c.color, + path: c.path.clone().unwrap_or_else(|| String::from(".")), env, ..Job::default() } } - fn build_project_task_job(&self, task: &TaskDefinition) -> Job { + /// Converts a root level task definition to a job definition + fn build_project_task_job(&self, name: &str, task: &TaskDefinition) -> Job { let mut env = self.env.clone(); env.extend(task.env.clone()); Job { - name: task.name.clone(), - ..Job::default() + env, + name: name.to_string(), + ..Job::from(task) } } + /// Converts a component level task definition to a job definition fn build_component_task_job( &self, - cmp_name: &str, + component_name: &str, + task_name: &str, component: &Component, task: &TaskDefinition, ) -> Job { @@ -142,77 +219,120 @@ impl Project { env.extend(component.env.clone()); env.extend(task.env.clone()); Job { - name: format!("{}:{}", cmp_name.to_string(), task.name.clone()), env, - ..Job::default() + name: format!("{}:{}", component_name, task_name), + ..Job::from(task) } } + /// Returns a list of jobs for an object by name. This name could be a task or component and + /// the jobs returned will be the matched item with all of its dependencies pub fn get_by_name(&self, name: &str) -> Option { self.get_component(name) .or_else(|| self.get_absolute_task(name)) - .or_else(|| { - self.get_group(name).map(|v| { - v.iter() - .map(|jobs| jobs.to_vec()) - .flatten() - .collect::>() - .into() - }) - }) } - pub fn from_str(s: &str) -> Self { - serde_yaml::from_str(s).unwrap() + /// Returns a vector of jobs for an object by name. This name could be a task, component, or + /// or group. The vector contains jobs that can be run in parallel. The individual jobs are run + /// in sequence. + pub fn get_runplan(&self, name: &str) -> Option> { + self.get_by_name(name) + .map(|i| vec![i]) + .or_else(|| self.get_group(name)) + } + + /// Load a project from a yaml string + pub fn load_str(s: &str) -> anyhow::Result { + Ok(serde_yaml::from_str(s)?) } } -#[derive(Serialize, Deserialize, Default)] +/// Groups are used to define a series of components that can be ran in parallel. +#[derive(Serialize, Deserialize, Default, Clone)] #[serde(default)] pub struct Group { - name: String, - components: Vec, + /// A list of component names to run when the group is launched + pub components: Vec, + /// A description for the group that is displayed in the task list + pub description: Option, } -#[derive(Serialize, Deserialize)] +/// A component represents a long running task. +/// In general, these are things that need to be kept alive during the +/// the operation. +#[derive(Serialize, Deserialize, Clone)] #[serde(default)] pub struct Component { + /// A description for the component that is displayed in the task list + pub description: Option, + /// A map of environment settings that are set before launching the component pub env: HashMap, - pub command: String, + /// The command(s) to execute when the component is launched + pub command: Command, + /// The working path the commands are executed in. This can be relative to the conductor.yaml pub path: Option, - pub retry: bool, + /// If true the component will be relaunched after it exits pub keep_alive: bool, + /// The number of seconds to wait before relaunching the component pub retry_delay: u64, - pub before: Vec, - pub tasks: Vec, + /// The tasks that should be ran before the component's commands + pub before: Dependencies, + /// A map of component level tasks. Tasks can be placed under the component for orgnaizational purposes. + /// They can be ran and referenced from anywhere using an absolute namespace: component::task + pub tasks: HashMap, + /// The color to use for the component name in the terminal output from the command. + pub color: (u8, u8, u8), } impl Default for Component { fn default() -> Self { + let mut rng = rand::thread_rng(); + Self { + description: None, env: HashMap::new(), - command: String::new(), + command: Command::default(), path: None, - retry: false, keep_alive: true, retry_delay: 2, - before: vec![], - tasks: vec![], + before: Dependencies::default(), + tasks: HashMap::new(), + color: ( + rng.gen_range(100..255), + rng.gen_range(100..255), + rng.gen_range(100..255), + ), } } } -#[derive(Serialize, Deserialize, Default)] +/// Tasks are short lived jobs that can be used to perform +/// utility tasks or to setup a component. +#[derive(Serialize, Deserialize, Default, Clone)] #[serde(default)] pub struct TaskDefinition { + pub description: String, + /// A map of environment variables that are provided before running the task pub env: HashMap, - pub name: String, - pub command: String, + /// The command(s) to execute when the task is launched + pub command: Command, + /// The path to execute the task commands from. This can be relative from the conductor.yaml pub path: Option, - pub retry: bool, - pub keep_alive: bool, - pub retry_delay: u64, - pub before: Vec, + /// Other tasks that should be ran before running the task's command + pub before: Dependencies, +} + +impl From<&TaskDefinition> for Job { + fn from(source: &TaskDefinition) -> Self { + Self { + env: source.env.clone(), + command: source.command.clone(), + retry: false, + keep_alive: false, + retry_delay: 0, + ..Default::default() + } + } } #[cfg(test)] @@ -221,12 +341,13 @@ mod tests { #[test] fn component_by_name() { - let project = Project::from_str( + let project = Project::load_str( r#" - components: - test-component: {} - "#, - ); + components: + test-component: {} + "#, + ) + .unwrap(); let jobs = project.get_by_name("test-component").unwrap(); assert_eq!(jobs.len(), 1); @@ -234,12 +355,14 @@ mod tests { #[test] fn project_task() { - let project = Project::from_str( + let project = Project::load_str( r#" - tasks: - - name: task1 - "#, - ); + tasks: + task1: + command: pwd + "#, + ) + .unwrap(); let jobs = project.get_by_name("task1").unwrap(); assert_eq!(jobs.len(), 1); @@ -247,14 +370,16 @@ mod tests { #[test] fn component_task() { - let project = Project::from_str( + let project = Project::load_str( r#" - components: - c1: - tasks: - - name: task1 - "#, - ); + components: + c1: + tasks: + task1: + command: pwd + "#, + ) + .unwrap(); let jobs = project.get_by_name("c1:task1").unwrap(); assert_eq!(jobs.len(), 1); @@ -262,16 +387,17 @@ mod tests { #[test] fn component_dependent_absolute_component_task() { - let project = Project::from_str( + let project = Project::load_str( r#" - components: - main-cmp: - before: - - main-cmp:sub-task - tasks: - - name: sub-task - "#, - ); + components: + main-cmp: + before: main-cmp:sub-task + tasks: + sub-task: + command: pwd + "#, + ) + .unwrap(); let jobs = project.get_by_name("main-cmp").unwrap(); assert_eq!(jobs.len(), 2); @@ -280,16 +406,18 @@ mod tests { #[test] fn component_dependent_relative() { - let project = Project::from_str( + let project = Project::load_str( r#" - components: - main-cmp: - before: - - sub-task - tasks: - - name: sub-task - "#, - ); + components: + main-cmp: + before: + - sub-task + tasks: + sub-task: + command: pwd + "#, + ) + .unwrap(); let jobs = project.get_by_name("main-cmp").unwrap(); assert_eq!(jobs.len(), 2); @@ -298,29 +426,33 @@ mod tests { #[test] fn complicated_dependencies() { - let project = Project::from_str( + let project = Project::load_str( r#" - components: - ui: - before: - - build-ui - tasks: - - name: build-ui - server: - before: - - setup - tasks: - - name: setup - - name: build - before: - - server:setup - tasks: - - name: build - before: - - ui:build-ui - - server:build - "#, - ); + components: + ui: + before: + - build-ui + tasks: + build-ui: + command: pwd + server: + before: + - setup + tasks: + setup: + command: pwd + build: + command: pwd + before: + - server:setup + tasks: + build: + before: + - ui:build-ui + - server:build + "#, + ) + .unwrap(); let jobs = project.get_by_name("build").unwrap(); assert_eq!(jobs.get(0).unwrap().name, "ui:build-ui"); @@ -332,17 +464,18 @@ mod tests { #[test] fn component_env() { - let project = Project::from_str( + let project = Project::load_str( r#" - env: - foo: one - sub: two - components: - main-cmp: - env: - sub: three - "#, - ); + env: + foo: one + sub: two + components: + main-cmp: + env: + sub: three + "#, + ) + .unwrap(); let jobs = project.get_by_name("main-cmp").unwrap(); let job = jobs.first().unwrap(); @@ -352,24 +485,25 @@ mod tests { #[test] fn task_env() { - let project = Project::from_str( + let project = Project::load_str( r#" - env: - root: ten - foo: one - sub: two - components: - main-cmp: - env: - sub: three - tasks: - - name: t - env: - foo: four - "#, - ); + env: + root: ten + foo: one + sub: two + components: + main-cmp: + env: + sub: three + tasks: + subtask: + env: + foo: four + "#, + ) + .unwrap(); - let jobs = project.get_by_name("main-cmp:t").unwrap(); + let jobs = project.get_by_name("main-cmp:subtask").unwrap(); let job = jobs.first().unwrap(); assert_eq!(job.env.get("foo"), Some(&String::from("four"))); assert_eq!(job.env.get("sub"), Some(&String::from("three"))); @@ -378,40 +512,76 @@ mod tests { #[test] fn group() { - let project = Project::from_str( + let project = Project::load_str( r#" - groups: - - name: all - components: - - ui - - server - components: - ui: - before: - - build-ui - tasks: - - name: build-ui - server: - before: - - setup - tasks: - - name: setup - - name: build - before: - - server:setup - tasks: - - name: build - before: - - ui:build-ui - - server:build - "#, - ); - let jobs = project.get_by_name("all").unwrap(); - println!("{:?}", jobs); - assert_eq!(jobs.get(0).unwrap().name, "ui:build-ui"); - assert_eq!(jobs.get(1).unwrap().name, "ui"); - assert_eq!(jobs.get(2).unwrap().name, "server:setup"); - assert_eq!(jobs.get(3).unwrap().name, "server"); - assert_eq!(jobs.len(), 4); + groups: + all: + components: + - ui + - server + components: + ui: + before: + - build-ui + tasks: + build-ui: + command: pwd + server: + before: + - setup + tasks: + setup: + command: pwd + build: + command: pwd + before: + - server:setup + tasks: + build: + before: + - ui:build-ui + - server:build + "#, + ) + .unwrap(); + let plan = project.get_runplan("all").unwrap(); + assert_eq!(plan[0][0].name, "ui:build-ui"); + assert_eq!(plan[0][1].name, "ui"); + assert_eq!(plan[1][0].name, "server:setup"); + assert_eq!(plan[1][1].name, "server"); + assert_eq!(plan.len(), 2); + assert_eq!(plan[0].len(), 2); + assert_eq!(plan[1].len(), 2); + } + + #[test] + pub fn shorthand_single_command() { + let project = Project::load_str( + r#" + components: + test: + command: pwd + "#, + ) + .unwrap(); + let jobs = project.get_by_name("test").unwrap(); + assert_eq!(jobs[0].command.to_string(), String::from("pwd")); + } + + #[test] + pub fn multiple_commands() { + let project = Project::load_str( + r#" + components: + test: + command: + - sleep 1 + - pwd + + "#, + ) + .unwrap(); + let jobs = project.get_by_name("test").unwrap(); + assert_eq!(jobs[0].command.to_string(), String::from("sleep 1 && pwd")); } } diff --git a/src/job.rs b/src/job.rs index a17d36d..8a3dd62 100644 --- a/src/job.rs +++ b/src/job.rs @@ -1,10 +1,13 @@ use actix::Message; +use rand::Rng; use std::{ collections::HashMap, ops::{Deref, DerefMut}, }; -#[derive(Clone, Message)] +use crate::definition::Command; + +#[derive(Clone, Message, Debug)] #[rtype(result = "()")] pub struct Jobs(Vec); @@ -12,16 +15,13 @@ impl Jobs { pub fn new(tasks: Vec) -> Self { Self(tasks) } -} -impl std::fmt::Debug for Jobs { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("Jobs") - .field( - "list", - &self.iter().map(|j| j.name.clone()).collect::>(), - ) - .finish() + pub fn pop_front(&mut self) -> Option { + if self.0.is_empty() { + None + } else { + Some(self.0.remove(0)) + } } } @@ -39,6 +39,15 @@ impl DerefMut for Jobs { } } +impl std::ops::Add for Jobs { + type Output = Jobs; + + fn add(mut self, mut rhs: Self) -> Self::Output { + self.0.append(&mut rhs.0); + self + } +} + impl From> for Jobs { fn from(fr: Vec) -> Self { Jobs::new(fr) @@ -49,24 +58,32 @@ impl From> for Jobs { #[rtype(result = "()")] pub struct Job { pub name: String, - pub command: String, + pub command: Command, pub path: String, pub env: HashMap, pub retry: bool, pub keep_alive: bool, pub retry_delay: u64, + pub color: (u8, u8, u8), } impl Default for Job { fn default() -> Self { + let mut rng = rand::thread_rng(); + Job { name: "Unnamed".to_string(), - command: "".to_string(), + command: "".into(), path: ".".to_string(), env: HashMap::new(), retry: true, keep_alive: true, retry_delay: 2, + color: ( + rng.gen_range(100..255), + rng.gen_range(100..255), + rng.gen_range(100..255), + ), } } } diff --git a/src/main.rs b/src/main.rs index f222c94..cb33480 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,4 @@ use crate::definition::Project; -use actix::prelude::*; -use arkham::{App, Command}; use runner::Manager; use std::env; use std::path::{Path, PathBuf}; @@ -8,29 +6,47 @@ use std::path::{Path, PathBuf}; mod definition; mod job; mod runner; +mod term; #[actix_rt::main] async fn main() { - let project = Project::from_str( - r#" - components: - - name: ls - commands: - - ls - - name: currentdir - commands: - - pwd - "#, - ); - let jobs = project.get_by_name("ls").unwrap(); - let manager = Manager::new().start(); - manager.do_send(jobs); + if let Err(e) = run().await { + term::main_error(e); + } +} - find_config("conductor.yml"); +pub async fn run() -> anyhow::Result<()> { + let cfg_path = find_config("conductor.yml").unwrap(); + + std::env::set_current_dir(cfg_path.parent().unwrap())?; + + let config_str = std::fs::read_to_string(cfg_path).unwrap(); + let project = Project::load_str(&config_str).unwrap(); + + let args = std::env::args(); + + if args.len() == 1 { + term::help_text(&project); + return Ok(()); + } + + let plan = args.into_iter().skip(1).fold(vec![], |mut plan, arg| { + if let Some(mut j) = project.get_runplan(&arg) { + plan.append(&mut j) + } + plan + }); + + if plan.is_empty() { + return Err(anyhow::anyhow!("No tasks to run")); + } + + plan.into_iter().for_each(Manager::jobs); actix_rt::signal::ctrl_c() .await .expect("failed to listen for event"); + Ok(()) } fn find_config(config: &str) -> Option { diff --git a/src/runner.rs b/src/runner.rs index 0df7f0e..326e854 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -3,10 +3,12 @@ use std::collections::HashMap; use std::process::exit; use std::process::Stdio; use std::time::Duration; +use std::time::Instant; use actix::prelude::*; +use futures::AsyncReadExt; -use async_process::Child; +use super::term; use async_process::Command; use futures::io::AsyncBufReadExt; use futures::io::BufReader; @@ -14,10 +16,10 @@ use futures::io::BufReader; #[derive(Clone, Message, Debug)] #[rtype(result = "()")] pub enum Event { - StartedTask(i64, String), - Output(i64, String, String), - Error(i64, String, String), - FinishedTask(i64, String), + StartedTask(i64, Job), + Output(i64, Job, String), + Error(i64, Job, String), + FinishedTask(i64, Job, f64), Completed(i64), } @@ -26,8 +28,8 @@ pub struct Runner { pub id: i64, pub tasks: Jobs, pub manager: Recipient, - child: Option, pub current_job: Option, + pub current_job_start: Instant, } impl Runner { @@ -37,7 +39,7 @@ impl Runner { manager, id, current_job: None, - child: None, + current_job_start: Instant::now(), } } } @@ -46,7 +48,7 @@ impl Actor for Runner { type Context = Context; fn started(&mut self, ctx: &mut Self::Context) { - if let Some(task) = self.tasks.pop() { + if let Some(task) = self.tasks.pop_front() { ctx.notify(task); } else { ctx.stop(); @@ -58,13 +60,16 @@ impl Handler for Runner { type Result = (); fn handle(&mut self, job: Job, ctx: &mut Self::Context) -> Self::Result { self.current_job = Some(job.clone()); + self.current_job_start = Instant::now(); let _ = self .manager - .do_send(Event::StartedTask(self.id, job.name.clone())); + .do_send(Event::StartedTask(self.id, job.clone())); let mut child = Command::new("sh") .arg("-c") - .arg(&job.command) + .arg(&job.command.to_string()) + .envs(&job.env) + .current_dir(&job.path) .stdout(Stdio::piped()) .stderr(Stdio::piped()) .spawn() @@ -74,7 +79,11 @@ impl Handler for Runner { .stdout .take() .expect("child did not have a handle to stdout"); - let reader = BufReader::new(stdout).lines(); + let stderr = child + .stderr + .take() + .expect("child did not have a handle to stdout"); + ctx.add_stream(BufReader::new(stdout.chain(stderr)).lines()); let fut = async move { child .status() @@ -84,40 +93,31 @@ impl Handler for Runner { let fut = actix::fut::wrap_future::<_, Self>(fut).map(move |status, _, ctx| { if job.keep_alive && status.code() == Some(0) { let delay = Duration::from_secs(job.retry_delay); - arkham::vox::header(format!("Restarting {} in {}s", job.name, delay.as_secs())); + term::header(&job.name, &format!("Restarting in {}s", delay.as_secs())); ctx.notify_later(job, delay); } }); ctx.spawn(fut); - ctx.add_stream(reader); } } impl StreamHandler> for Runner { fn handle(&mut self, item: Result, _: &mut Self::Context) { - let ev = match item { - Ok(v) => Event::Output( - self.id, - self.current_job - .as_ref() - .map(|i| i.name.clone()) - .unwrap_or_else(|| String::from("UNKNOWN")), - v, - ), - Err(e) => Event::Error( - self.id, - self.current_job.as_ref().unwrap().name.clone(), - e.to_string(), - ), - }; - let _ = self.manager.do_send(ev); + if let Some(ref job) = self.current_job { + let ev = match item { + Ok(v) => Event::Output(self.id, job.clone(), v), + Err(e) => Event::Error(self.id, job.clone(), e.to_string()), + }; + let _ = self.manager.do_send(ev); + } } fn finished(&mut self, ctx: &mut Self::Context) { let _ = self.manager.do_send(Event::FinishedTask( self.id, - self.current_job.as_ref().unwrap().name.clone(), + self.current_job.clone().unwrap_or_default(), + self.current_job_start.elapsed().as_secs_f64(), )); if let Some(task) = self.tasks.pop() { self.current_job = None; @@ -141,11 +141,14 @@ pub struct Manager { } impl Manager { - pub fn new() -> Self { - Self::default() + pub fn jobs(jobs: Jobs) { + Self::from_registry().do_send(jobs); } } +impl Supervised for Manager {} +impl SystemService for Manager {} + impl Actor for Manager { type Context = Context; } @@ -155,17 +158,17 @@ impl Handler for Manager { fn handle(&mut self, msg: Event, ctx: &mut Self::Context) -> Self::Result { match msg { - Event::StartedTask(_, name) => { - arkham::vox::header(format!("{} - Started", name)); + Event::StartedTask(_, job) => { + term::header(job.name, "Started"); } - Event::Output(_, name, v) => { - println!("[{}] {}", name, v) + Event::Output(_, job, v) => { + term::output(job.name, job.color, v); } - Event::Error(_, v, name) => { - println!("[{}] Error: {}", name, v); + Event::Error(_, job, v) => { + println!("[{}: {}]", job.name, v); } - Event::FinishedTask(_, name) => { - arkham::vox::header(format!("{} - Finished", name)); + Event::FinishedTask(_, job, time) => { + term::header(job.name, &format!("Finished ({:.2}s)", time)); } Event::Completed(id) => { self.runners.remove(&id); diff --git a/src/term.rs b/src/term.rs new file mode 100644 index 0000000..2eafe3d --- /dev/null +++ b/src/term.rs @@ -0,0 +1,84 @@ +use std::{collections::HashMap, fmt::Display}; + +use ansi_term::Color; + +use crate::definition::{Group, Project}; + +pub fn header>(name: T, msg: &str) { + let text = format!(" - --=[ {: <20} {: >20} ]=-- -", name.into(), msg); + println!("{}", Color::White.bold().paint(text)); +} + +pub fn main_error(error: T) { + println!("{}\n{}", Color::Red.bold().paint("Error:"), error); +} + +pub fn output(name: T, color: (u8, u8, u8), value: T) { + let n = Color::RGB(color.0, color.1, color.2).paint(format!("{}", name)); + println!("[{}] - {}", n, value); +} + +pub fn help_text(project: &Project) { + println!( + "{} {}", + Color::White.paint("Conductor"), + Color::White.dimmed().paint(env!("CARGO_PKG_VERSION")) + ); + item_list(project); +} + +pub fn item_list(project: &Project) { + println!("\n{}", ansi_term::Color::White.bold().paint("GROUPS")); + if project.groups.is_empty() { + println!("{}", Color::White.dimmed().paint("no groups defined")); + } else { + for (name, group) in sort_map(&project.groups).iter() { + print_group(name, group); + } + } + + println!("\n{}", ansi_term::Color::White.bold().paint("COMPONENTS")); + if project.components.is_empty() { + println!("{}", Color::White.dimmed().paint("no components defined")); + } else { + for (name, _component) in sort_map(&project.components).iter() { + println!("{}", name); + } + } + + println!("\n{}", ansi_term::Color::White.bold().paint("TASKS")); + if project.tasks.is_empty() && project.components.values().all(|c| c.tasks.is_empty()) { + println!("{}", Color::White.dimmed().paint("no tasks defined")); + } else { + for (name, _tasks) in sort_map(&project.tasks).iter() { + println!("{}", name); + } + for (c_name, component) in sort_map(&project.components).iter() { + for (t_name, _tasks) in sort_map(&component.tasks).iter() { + println!("{}:{}", c_name, t_name); + } + } + } +} + +fn sort_map(map: &HashMap) -> Vec<(String, V)> +where + V: Clone, +{ + let mut items: Vec<(String, V)> = map.iter().map(|v| (v.0.clone(), v.1.clone())).collect(); + items.sort_by_key(|i| i.0.clone()); + items +} + +fn print_group(name: &str, group: &Group) { + if let Some(ref desc) = group.description { + println!("{: <31}{}", name, desc); + } else { + println!( + "{: <31}{}: {}", + name, + Color::White.bold().paint("components"), + group.components.join(",") + ); + } +} -- 2.40.1 From 2cd8486aedf69449bccc7e9fe66d3a2f386d9118 Mon Sep 17 00:00:00 2001 From: Joe Bellus Date: Sun, 25 Sep 2022 02:57:10 -0400 Subject: [PATCH 04/15] Added deploy stage --- .drone.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 883ab99..0b181dd 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,7 +3,20 @@ name: default steps: - name: test - image: rust:1.60 + image: rust:latest commands: - cargo build --verbose --all - - cargo test --verbose --all \ No newline at end of file + - cargo test --verbose --all + +- deploy: + image: rust:latest + commands: + - cargo build --release + - ./mc alias set fivesigma https://objects.5sigma.io $MINIOID $MINIOSECRET + - ./mc cp target/release/conductor fivesigma/public/conductor + # when: + # event: + # - promote + # target: + # - staging + # - production -- 2.40.1 From c86cdcb0b17f699fe1c96a242ff962da9487b56d Mon Sep 17 00:00:00 2001 From: Joe Bellus Date: Sun, 25 Sep 2022 02:57:36 -0400 Subject: [PATCH 05/15] Added stage name --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 0b181dd..4610c81 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,7 +8,7 @@ steps: - cargo build --verbose --all - cargo test --verbose --all -- deploy: +- name: deploy: image: rust:latest commands: - cargo build --release -- 2.40.1 From 1774796466eef31f8c26e30bb933f3d779bfaf64 Mon Sep 17 00:00:00 2001 From: Joe Bellus Date: Sun, 25 Sep 2022 02:58:04 -0400 Subject: [PATCH 06/15] typo correction --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 4610c81..feaba96 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,7 +8,7 @@ steps: - cargo build --verbose --all - cargo test --verbose --all -- name: deploy: +- name: deploy image: rust:latest commands: - cargo build --release -- 2.40.1 From a16c7d042d23d6ecde3542ec52194c6393bf680e Mon Sep 17 00:00:00 2001 From: Joe Bellus Date: Sun, 25 Sep 2022 03:03:16 -0400 Subject: [PATCH 07/15] Added mc download and clippy --- .drone.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index feaba96..e2462fd 100644 --- a/.drone.yml +++ b/.drone.yml @@ -5,15 +5,19 @@ steps: - name: test image: rust:latest commands: - - cargo build --verbose --all - - cargo test --verbose --all + - cargo install clippy + - cargo clippy + - cargo test --all - name: deploy image: rust:latest commands: - cargo build --release + - tar cvzf conductor.tar.gz target/release/conductor + - wget https://dl.min.io/client/mc/release/linux-amd64/mc + - chmod +x mc - ./mc alias set fivesigma https://objects.5sigma.io $MINIOID $MINIOSECRET - - ./mc cp target/release/conductor fivesigma/public/conductor + - ./mc cp conductor.tar.gz fivesigma/public/conductor.tar.gz # when: # event: # - promote -- 2.40.1 From 8ef56f4ec4fbdb66e1cabd67b766cc6c777e640f Mon Sep 17 00:00:00 2001 From: Joe Bellus Date: Sun, 25 Sep 2022 03:05:39 -0400 Subject: [PATCH 08/15] Updated clippy install --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index e2462fd..9d31dc0 100644 --- a/.drone.yml +++ b/.drone.yml @@ -5,7 +5,7 @@ steps: - name: test image: rust:latest commands: - - cargo install clippy + - rustup component add clippy - cargo clippy - cargo test --all -- 2.40.1 From 876a41892cf73f3f31e5d8ffaa795874f9ebd952 Mon Sep 17 00:00:00 2001 From: Joe Bellus Date: Sun, 25 Sep 2022 03:09:40 -0400 Subject: [PATCH 09/15] Deploy now set to promotion --- .drone.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.drone.yml b/.drone.yml index 9d31dc0..6874ea9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -18,9 +18,9 @@ steps: - chmod +x mc - ./mc alias set fivesigma https://objects.5sigma.io $MINIOID $MINIOSECRET - ./mc cp conductor.tar.gz fivesigma/public/conductor.tar.gz - # when: - # event: - # - promote - # target: - # - staging - # - production + when: + event: + - promote + target: + - staging + - production -- 2.40.1 From a8f6d26b5c30fc74df931e8611fb9a29e7f155ce Mon Sep 17 00:00:00 2001 From: Joe Bellus Date: Sun, 25 Sep 2022 13:26:16 -0400 Subject: [PATCH 10/15] Added -C to tar --- .drone.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.drone.yml b/.drone.yml index 6874ea9..337172a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -13,14 +13,14 @@ steps: image: rust:latest commands: - cargo build --release - - tar cvzf conductor.tar.gz target/release/conductor + - tar cvzf -C conductor.tar.gz target/release/conductor - wget https://dl.min.io/client/mc/release/linux-amd64/mc - chmod +x mc - ./mc alias set fivesigma https://objects.5sigma.io $MINIOID $MINIOSECRET - ./mc cp conductor.tar.gz fivesigma/public/conductor.tar.gz - when: - event: - - promote - target: - - staging - - production + # when: + # event: + # - promote + # target: + # - staging + # - production -- 2.40.1 From 9715231d158b45f28d32c7d3817690f1e5d3426f Mon Sep 17 00:00:00 2001 From: Joe Bellus Date: Sun, 25 Sep 2022 13:32:42 -0400 Subject: [PATCH 11/15] Changed tar command --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 337172a..4522974 100644 --- a/.drone.yml +++ b/.drone.yml @@ -13,7 +13,7 @@ steps: image: rust:latest commands: - cargo build --release - - tar cvzf -C conductor.tar.gz target/release/conductor + - tar cvzf conductor.tar.gz -C target/release/conductor conductor - wget https://dl.min.io/client/mc/release/linux-amd64/mc - chmod +x mc - ./mc alias set fivesigma https://objects.5sigma.io $MINIOID $MINIOSECRET -- 2.40.1 From e112eb7c4fb76c717d8c808e985e92f47af677c5 Mon Sep 17 00:00:00 2001 From: Joe Bellus Date: Sun, 25 Sep 2022 13:36:30 -0400 Subject: [PATCH 12/15] Changed tar command --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 4522974..b49f95f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -13,7 +13,7 @@ steps: image: rust:latest commands: - cargo build --release - - tar cvzf conductor.tar.gz -C target/release/conductor conductor + - tar cvzf conductor.tar.gz -C target/release conductor - wget https://dl.min.io/client/mc/release/linux-amd64/mc - chmod +x mc - ./mc alias set fivesigma https://objects.5sigma.io $MINIOID $MINIOSECRET -- 2.40.1 From 1fbba62f8ee643cfc9c0481c08c27783c3154d4c Mon Sep 17 00:00:00 2001 From: Joe Bellus Date: Sun, 25 Sep 2022 13:44:06 -0400 Subject: [PATCH 13/15] Added error handling for no config --- src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index cb33480..851c5aa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,8 @@ async fn main() { } pub async fn run() -> anyhow::Result<()> { - let cfg_path = find_config("conductor.yml").unwrap(); + let cfg_path = find_config("conductor.yml") + .ok_or_else(|| anyhow::anyhow!("No config file found. Create a conductor.yml.\nSee http://conductor.5sigma.io/articles/config"))?; std::env::set_current_dir(cfg_path.parent().unwrap())?; -- 2.40.1 From 22eaca4148afa87b851af8f584da20e04bd8ea62 Mon Sep 17 00:00:00 2001 From: Joe Bellus Date: Sun, 25 Sep 2022 13:54:12 -0400 Subject: [PATCH 14/15] Error handling --- .drone.yml | 12 ++++++------ src/main.rs | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.drone.yml b/.drone.yml index b49f95f..0395bb9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -18,9 +18,9 @@ steps: - chmod +x mc - ./mc alias set fivesigma https://objects.5sigma.io $MINIOID $MINIOSECRET - ./mc cp conductor.tar.gz fivesigma/public/conductor.tar.gz - # when: - # event: - # - promote - # target: - # - staging - # - production + when: + event: + - promote + target: + - staging + - production diff --git a/src/main.rs b/src/main.rs index 851c5aa..97255c8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,8 +21,8 @@ pub async fn run() -> anyhow::Result<()> { std::env::set_current_dir(cfg_path.parent().unwrap())?; - let config_str = std::fs::read_to_string(cfg_path).unwrap(); - let project = Project::load_str(&config_str).unwrap(); + let config_str = std::fs::read_to_string(cfg_path)?; + let project = Project::load_str(&config_str)?; let args = std::env::args(); -- 2.40.1 From f229302eaa0eb8539253297da3317d0e58675b0c Mon Sep 17 00:00:00 2001 From: Joe Bellus Date: Sun, 25 Sep 2022 13:59:03 -0400 Subject: [PATCH 15/15] Ticked version to 2.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e5a161..3dffffb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -193,7 +193,7 @@ dependencies = [ [[package]] name = "conductor" -version = "0.1.0" +version = "2.0.0" dependencies = [ "actix", "actix-rt", diff --git a/Cargo.toml b/Cargo.toml index 7d4912f..4f48522 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "conductor" -version = "0.1.0" +version = "2.0.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -- 2.40.1