From 91517ca4019b28abe97e242009622d9d0549c723 Mon Sep 17 00:00:00 2001 From: John Cairns Date: Tue, 19 Dec 2023 17:17:07 -0600 Subject: [PATCH] 6: introduce pages and workflow modules --- .dockerignore | 7 ++- .github/workflows/github-pages.yml | 79 ++++++++++++++++++++++++++++++ .gitignore | 1 + CONTRIBUTING.md | 62 +++++++++++++++++++++++ Cargo.lock | 12 +++++ Cargo.toml | 5 +- README.md | 28 +++++++++++ inbox/Cargo.toml | 8 +++ inbox/src/lib.rs | 14 ++++++ messaging/Cargo.toml | 8 +++ messaging/src/lib.rs | 14 ++++++ registry/Cargo.toml | 8 +++ registry/src/lib.rs | 14 ++++++ 13 files changed, 255 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/github-pages.yml create mode 100644 CONTRIBUTING.md create mode 100644 inbox/Cargo.toml create mode 100644 inbox/src/lib.rs create mode 100644 messaging/Cargo.toml create mode 100644 messaging/src/lib.rs create mode 100644 registry/Cargo.toml create mode 100644 registry/src/lib.rs diff --git a/.dockerignore b/.dockerignore index 81c7945..3a2fe39 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,3 @@ -**/target/** -**/node_modules -**/.build/** -**/build/** \ No newline at end of file +/target +_site +.DS_Store diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml new file mode 100644 index 0000000..9850cbc --- /dev/null +++ b/.github/workflows/github-pages.yml @@ -0,0 +1,79 @@ +name: GitHub Pages + +on: + push: + branches: ["main"] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow one concurrent deployment +concurrency: + group: "github-pages" + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Setup Pages + uses: actions/configure-pages@v2 + - uses: actions/setup-python@v2 + + - name: "Cache" + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + ./target/${{ matrix.target }} + key: ${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }} + + - name: Install rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + target: ${{ matrix.target }} + + - name: Run tests + run: | + cargo test + id: test + + - name: Invoke cargo doc + run: | + rm -rf ./_site + cargo doc --lib --no-deps + rm -f target/doc/.lock + cp -r target/doc _site + echo "" > _site/index.html + echo "Taking care of pedantic permissions requirements required by GitHub Pages" + chmod -R +rX _site + id: docgen + + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v3 diff --git a/.gitignore b/.gitignore index 0592392..3a2fe39 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target +_site .DS_Store diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..59b504c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,62 @@ +# Contributing to xps-contract + +We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's: + +- Reporting a bug +- Discussing the current state of the code +- Submitting a fix +- Proposing new features +- Becoming a maintainer + +## We Develop with Github + +We use GitHub to host code, to track issues and feature requests, as well as accept pull requests. + +## We Use [Github Flow](https://guides.github.com/introduction/flow/index.html), So All Code Changes Happen Through Pull Requests + +Pull requests are the best way to propose changes to the codebase (we use [Github Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests: + +1. Fork the repo and create your branch from `master`. +2. If you've added code that should be tested, add tests. +3. If you've changed APIs, update the documentation. +4. Ensure the test suite passes. +5. Make sure your code lints. +6. Issue that pull request! + +## Any Contributions You Make Will Be Under the [Software License](LICENSE.md) Used in this Project + +In short, when you submit code changes, your submissions are understood to be under the same [license](LICENSE.md) that covers the project. Feel free to contact the maintainers if that's a concern. + +## Report Bugs Using Github's [Issues](https://github.com/xmtp/xps-contract/issues) + +We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/xmtp/xps-contract/issues); it's that easy! + +## Write Bug Reports With Detail, Background, and Sample Code + +**Great Bug Reports** tend to have: + +- A quick summary and/or background +- Steps to reproduce + - Be specific! + - Give sample code if you can. +- What you expected would happen +- What actually happens +- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work) + +People _love_ thorough bug reports. + +## Use a Consistent Coding Style + +- Solidity Language [Style Guide](https://docs.soliditylang.org/en/latest/style-guide.html) + +## Extremely high bar for unit test coverage + +- This project requires full test coverage for all changes + +## License + +By contributing, you agree that your contributions will be licensed as MIT open source. + +## References + +This document was adapted from the open-source contribution guidelines for [Facebook's Draft](https://github.com/facebook/draft-js). diff --git a/Cargo.lock b/Cargo.lock index faea802..5febd06 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -503,6 +503,10 @@ dependencies = [ "tokio-io-timeout", ] +[[package]] +name = "inbox" +version = "0.1.0" + [[package]] name = "indexmap" version = "1.9.3" @@ -574,6 +578,10 @@ version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +[[package]] +name = "messaging" +version = "0.1.0" + [[package]] name = "mime" version = "0.3.17" @@ -835,6 +843,10 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "registry" +version = "0.1.0" + [[package]] name = "rustc-demangle" version = "0.1.23" diff --git a/Cargo.toml b/Cargo.toml index 03cb172..dae845e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,10 @@ [workspace] members = [ -"xps-gateway" +"xps-gateway", +"messaging", +"inbox", +"registry", ] exclude = [ ] diff --git a/README.md b/README.md index 0aa4b10..d8dbd48 100644 --- a/README.md +++ b/README.md @@ -1 +1,29 @@ +## XMTP Postal Service (XPS) Gateway + ![XPS](xps.png) + +This *postal service* gateway implements the XMTP transport for registration, inbox and conversations. + +## Quick Start (Development) + +- [READ THE DOCS](https://xmtp.github.io/xps-gateway) + +### Dev Containers Development + +This contract supports containerized development. From Visual Studio Code Dev Containers extension + +`Reopen in Container` + +or + +Command line build using docker + +```bash +$ docker build . -t xps-contract:1 +``` + +## Testing (command line) + +```bash +$ cargo test +``` diff --git a/inbox/Cargo.toml b/inbox/Cargo.toml new file mode 100644 index 0000000..0192726 --- /dev/null +++ b/inbox/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "inbox" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/inbox/src/lib.rs b/inbox/src/lib.rs new file mode 100644 index 0000000..7d12d9a --- /dev/null +++ b/inbox/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/messaging/Cargo.toml b/messaging/Cargo.toml new file mode 100644 index 0000000..a2e3d86 --- /dev/null +++ b/messaging/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "messaging" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/messaging/src/lib.rs b/messaging/src/lib.rs new file mode 100644 index 0000000..7d12d9a --- /dev/null +++ b/messaging/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/registry/Cargo.toml b/registry/Cargo.toml new file mode 100644 index 0000000..89c58fc --- /dev/null +++ b/registry/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "registry" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/registry/src/lib.rs b/registry/src/lib.rs new file mode 100644 index 0000000..7d12d9a --- /dev/null +++ b/registry/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +}