From 895ed58f157989f4df6dd86cfe22e616ead981a2 Mon Sep 17 00:00:00 2001 From: Mohsin Zaidi <2236875+smrz2001@users.noreply.github.com> Date: Thu, 17 Aug 2023 19:22:23 -0400 Subject: [PATCH] feat: add license, readme, ceramic urls envar --- .github/workflows/publish.yml | 2 +- .github/workflows/rust.yml | 2 +- Cargo.lock | 180 ++++++++++++++++++++++++++++++++++ Cargo.toml | 2 + Dockerfile | 1 - LICENSE-APACHE | 5 + LICENSE-MIT | 19 ++++ Makefile | 8 +- README.md | 22 +++++ env/.env | 1 + src/api/mod.rs | 30 ++++-- 11 files changed, 259 insertions(+), 13 deletions(-) create mode 100644 LICENSE-APACHE create mode 100644 LICENSE-MIT create mode 100644 README.md create mode 100644 env/.env diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c553efb8..9c4d9c95 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,7 +2,7 @@ name: Publish Docker Image on: push: - branches: [ "main" ] + branches: [ "main", "feat/initial" ] jobs: publish: diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 7f6a2b14..fa5051a3 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -26,7 +26,7 @@ jobs: # default: "v0-rust" prefix-key: "v2" - name: Build - run: make release + run: make build - name: Check fmt run: make check-fmt - name: Check clippy diff --git a/Cargo.lock b/Cargo.lock index b71ec6f8..100b3980 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,12 +11,125 @@ dependencies = [ "memchr", ] +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + +[[package]] +name = "futures" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" + +[[package]] +name = "futures-executor" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" + +[[package]] +name = "futures-macro" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.29", +] + +[[package]] +name = "futures-sink" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" + +[[package]] +name = "futures-task" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" + +[[package]] +name = "futures-timer" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" + +[[package]] +name = "futures-util" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "lazy_static" version = "1.4.0" @@ -72,6 +185,12 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "proc-macro2" version = "1.0.66" @@ -134,14 +253,66 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +[[package]] +name = "relative-path" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c707298afce11da2efef2f600116fa93ffa7a032b5d7b628aa17711ec81383ca" + +[[package]] +name = "rstest" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97eeab2f3c0a199bc4be135c36c924b6590b88c377d416494288c14f2db30199" +dependencies = [ + "futures", + "futures-timer", + "rstest_macros", + "rustc_version", +] + +[[package]] +name = "rstest_macros" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d428f8247852f894ee1be110b375111b586d4fa431f6c46e64ba5a0dcccbe605" +dependencies = [ + "cfg-if", + "glob", + "proc-macro2", + "quote", + "regex", + "relative-path", + "rustc_version", + "syn 2.0.29", + "unicode-ident", +] + [[package]] name = "rust-ceramic-migration-tests" version = "0.1.0" dependencies = [ + "dotenvy", + "rstest", "tracing", "tracing-test", ] +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "semver" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" + [[package]] name = "sharded-slab" version = "0.1.4" @@ -151,6 +322,15 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "slab" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +dependencies = [ + "autocfg", +] + [[package]] name = "smallvec" version = "1.11.0" diff --git a/Cargo.toml b/Cargo.toml index 97600c7f..f7918135 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,5 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] +dotenvy = "0.15.7" +rstest = "0.18.2" tracing = "0.1" tracing-test = "0.2" diff --git a/Dockerfile b/Dockerfile index 8438f501..c39f6603 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,5 @@ FROM ubuntu:latest as tester COPY --from=builder /home/builder/rust-ceramic-migration-tests/rust-ceramic-migration-tests /usr/bin ENV RUST_BACKTRACE=1 -ENV CERAMIC_URLS="" ENTRYPOINT ["/usr/bin/rust-ceramic-migration-tests"] diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 00000000..749aa1ec --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/Makefile b/Makefile index 6b658265..0fbebb15 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,9 @@ .PHONY: all all: check-fmt check-clippy test +.PHONY: build +build: release + .PHONY: release release: $(eval BIN=$(shell sh -c "RUSTFLAGS='-D warnings' cargo test --no-run --locked --release -q --message-format=json | jq -r 'select(.executable != null) | .executable'")) @@ -19,10 +22,7 @@ debug: .PHONY: test test: - # Test with default features - cargo test --locked - # Test with all features - cargo test --locked --all-features + cargo test --locked --all-features -- --nocapture .PHONY: check-fmt check-fmt: diff --git a/README.md b/README.md new file mode 100644 index 00000000..fc42d707 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# Rust Ceramic Migration Tests + +Tests needed to verify the migration from [Kubo](https://github.com/ceramicnetwork/go-ipfs-daemon) to +[rust-ceramic](https://github.com/3box/rust-ceramic) when used with +[Ceramic](https://github.com/ceramicnetwork/js-ceramic) nodes. + +## Contributing + +We are happy to accept small and large contributions, feel free to make a suggestion or submit a pull request. + +Use the provided `Makefile` for basic actions to ensure your changes are ready for CI. + + $ make build + $ make check-clippy + $ make check-fmt + +Using the makefile is not necessary during your development cycle, feel free to use the relevant cargo commands +directly. However, running `make` before publishing a PR will provide a good signal if your PR will pass CI. + +## License + +Fully open source and dual-licensed under MIT and Apache 2. diff --git a/env/.env b/env/.env new file mode 100644 index 00000000..3bc1183d --- /dev/null +++ b/env/.env @@ -0,0 +1 @@ +CERAMIC_URLS=https://ceramic-private-dev.3boxlabs.com,https://ceramic-dev.3boxlabs.com diff --git a/src/api/mod.rs b/src/api/mod.rs index 777361d7..12ba0ecc 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -1,16 +1,34 @@ #[cfg(test)] pub mod tests { + use std::env; + use std::path::Path; + + use rstest::{fixture, rstest}; use tracing_test::traced_test; - #[test] + const CERAMIC_URLS: &str = "CERAMIC_URLS"; + + #[fixture] + #[once] + fn initialize() { + dotenvy::from_path(Path::new("env/.env")).expect("Could not find .env file"); + } + + fn print_ceramic_urls() { + println!("{:?}", env::var(CERAMIC_URLS).unwrap_or_default()); + } + + #[rstest] #[traced_test] - fn test_1() { - println!("Hello world!"); + fn test_1(_initialize: ()) { + println!("Hello Ceramic!"); + print_ceramic_urls(); } - #[test] + #[rstest] #[traced_test] - fn test_2() { - println!("Goodbye world!"); + fn test_2(_initialize: ()) { + println!("Goodbye Ceramic!"); + print_ceramic_urls(); } }