diff --git a/.github/workflows/book.yml b/.github/workflows/book.yml deleted file mode 100644 index 6ed6b252..00000000 --- a/.github/workflows/book.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Book -on: - push: - branches: - - main - -jobs: - deploy: - runs-on: ubuntu-latest - permissions: - contents: write # To push a branch - pages: write # To push to a GitHub Pages site - id-token: write # To update the deployment status - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - uses: dtolnay/rust-toolchain@stable - - - uses: taiki-e/install-action@v2 - with: - tool: mdbook,mdbook-linkcheck,mdbook-admonish - - - name: Build Book - run: mdbook build - - - name: Setup Pages - uses: actions/configure-pages@v2 - - - name: Upload artifact - uses: actions/upload-pages-artifact@v1 - with: - # Upload entire repository - path: 'book/html' - - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v1 \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ebde2d7b..166c84e2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,58 +1,203 @@ +# Copyright 2022-2023, axodotdev +# SPDX-License-Identifier: MIT or Apache-2.0 +# +# CI that: +# +# * checks for a Git Tag that looks like a release +# * builds artifacts with cargo-dist (archives, installers, hashes) +# * uploads those artifacts to temporary workflow zip +# * on success, uploads the artifacts to a Github Release™ +# +# Note that the Github Release™ will be created with a generated +# title/body based on your changelogs. name: Release permissions: contents: write +# This task will run whenever you push a git tag that looks like a version +# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc. +# Various formats will be parsed into a VERSION and an optional PACKAGE_NAME, where +# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION +# must be a Cargo-style SemVer Version (must have at least major.minor.patch). +# +# If PACKAGE_NAME is specified, then the release will be for that +# package (erroring out if it doesn't have the given version or isn't cargo-dist-able). +# +# If PACKAGE_NAME isn't specified, then the release will be for all +# (cargo-dist-able) packages in the workspace with that version (this mode is +# intended for workspaces with only one dist-able package, or with all dist-able +# packages versioned/released in lockstep). +# +# If you push multiple tags at once, separate instances of this workflow will +# spin up, creating an independent Github Release™ for each one. However Github +# will hard limit this to 3 tags per commit, as it will assume more tags is a +# mistake. +# +# If there's a prerelease-style suffix to the version, then the Github Release™ +# will be marked as a prerelease. on: push: tags: - - v[0-9]+.* - -env: - RUSTFLAGS: -D warnings --cfg tokio_unstable - CARGO_TERM_COLOR: always + - '**[0-9]+.[0-9]+.[0-9]+*' + pull_request: jobs: - create-release: + # Run 'cargo dist plan' to determine what tasks we need to do + plan: runs-on: ubuntu-latest + outputs: + val: ${{ steps.plan.outputs.manifest }} + tag: ${{ !github.event.pull_request && github.ref_name || '' }} + tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }} + publishing: ${{ !github.event.pull_request }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v3 - - uses: taiki-e/create-gh-release-action@v1 + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Install cargo-dist + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.4.0/cargo-dist-installer.sh | sh" + - id: plan + run: | + cargo dist plan ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }} --output-format=json > dist-manifest.json + echo "cargo dist plan ran successfully" + cat dist-manifest.json + echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT" + - name: "Upload dist-manifest.json" + uses: actions/upload-artifact@v3 with: - token: ${{ secrets.GITHUB_TOKEN }} + name: artifacts + path: dist-manifest.json - upload-assets: + # Build and packages all the platform-specific things + upload-local-artifacts: + # Let the initial task tell us to not run (currently very blunt) + needs: plan + if: ${{ fromJson(needs.plan.outputs.val).releases != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }} strategy: - matrix: - include: - - target: x86_64-apple-darwin - os: macos-latest - - target: aarch64-apple-darwin - os: macos-latest - - target: x86_64-unknown-linux-gnu - os: ubuntu-latest - - target: aarch64-unknown-linux-gnu - os: ubuntu-latest - runs-on: ${{ matrix.os }} + fail-fast: false + # Target platforms/runners are computed by cargo-dist in create-release. + # Each member of the matrix has the following arguments: + # + # - runner: the github runner + # - dist-args: cli flags to pass to cargo dist + # - install-dist: expression to run to install cargo-dist on the runner + # + # Typically there will be: + # - 1 "global" task that builds universal installers + # - N "local" tasks that build each platform's binaries and platform-specific installers + matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }} + runs-on: ${{ matrix.runner }} env: - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + submodules: recursive + - uses: swatinem/rust-cache@v2 + - name: Install cargo-dist + run: ${{ matrix.install_dist }} + - name: Install dependencies + run: | + ${{ matrix.packages_install }} + - name: Build artifacts + run: | + # Actually do builds and make zips and whatnot + cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json + echo "cargo dist ran successfully" + - id: cargo-dist + name: Post-build + # We force bash here just because github makes it really hard to get values up + # to "real" actions without writing to env-vars, and writing to env-vars has + # inconsistent syntax between shell and powershell. + shell: bash + run: | + # Parse out what we just built and upload it to the Github Release™ + echo "paths<> "$GITHUB_OUTPUT" + jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" - - uses: rui314/setup-mold@v1 + cp dist-manifest.json "$BUILD_MANIFEST_NAME" + - name: "Upload artifacts" + uses: actions/upload-artifact@v3 + with: + name: artifacts + path: | + ${{ steps.cargo-dist.outputs.paths }} + ${{ env.BUILD_MANIFEST_NAME }} - - uses: taiki-e/setup-cross-toolchain-action@v1 + # Build and package all the platform-agnostic(ish) things + upload-global-artifacts: + needs: [plan, upload-local-artifacts] + runs-on: "ubuntu-20.04" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 with: - target: ${{ matrix.target }} - if: startsWith(matrix.os, 'ubuntu') + submodules: recursive + - name: Install cargo-dist + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.4.0/cargo-dist-installer.sh | sh" + # Get all the local artifacts for the global tasks to use (for e.g. checksums) + - name: Fetch local artifacts + uses: actions/download-artifact@v3 + with: + name: artifacts + path: target/distrib/ + - id: cargo-dist + shell: bash + run: | + cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json + echo "cargo dist ran successfully" - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.3 + # Parse out what we just built and upload it to the Github Release™ + echo "paths<> "$GITHUB_OUTPUT" + jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" + - name: "Upload artifacts" + uses: actions/upload-artifact@v3 + with: + name: artifacts + path: ${{ steps.cargo-dist.outputs.paths }} - - uses: taiki-e/upload-rust-binary-action@v1 + should-publish: + needs: + - plan + - upload-local-artifacts + - upload-global-artifacts + if: ${{ needs.plan.outputs.publishing == 'true' }} + runs-on: ubuntu-latest + steps: + - name: print tag + run: echo "ok we're publishing!" + + # Create a Github Release with all the results once everything is done + publish-release: + needs: [plan, should-publish] + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: "Download artifacts" + uses: actions/download-artifact@v3 + with: + name: artifacts + path: artifacts + - name: Cleanup + run: | + # Remove the granular manifests + rm artifacts/*-dist-manifest.json + - name: Create Release + uses: ncipollo/release-action@v1 with: - bin: corrosion - archive: "corrosion-$target" - target: ${{ matrix.target }} - token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + tag: ${{ needs.plan.outputs.tag }} + name: ${{ fromJson(needs.plan.outputs.val).announcement_title }} + body: ${{ fromJson(needs.plan.outputs.val).announcement_github_body }} + prerelease: ${{ fromJson(needs.plan.outputs.val).announcement_is_prerelease }} + artifacts: "artifacts/*" diff --git a/.github/workflows/web.yml b/.github/workflows/web.yml new file mode 100644 index 00000000..0cc8d35b --- /dev/null +++ b/.github/workflows/web.yml @@ -0,0 +1,75 @@ +# Workflow to build your docs with oranda (and mdbook) +# and deploy them to Github Pages +name: Web + +# We're going to push to the gh-pages branch, so we need that permission +permissions: + contents: write + +# What situations do we want to build docs in? +# All of these work independently and can be removed / commented out +# if you don't want oranda/mdbook running in that situation +on: + # Check that a PR didn't break docs! + # + # Note that the "Deploy to Github Pages" step won't run in this mode, + # so this won't have any side-effects. But it will tell you if a PR + # completely broke oranda/mdbook. Sadly we don't provide previews (yet)! + pull_request: + + # Whenever a workflow called "Release" completes, update the docs! + # + # If you're using cargo-dist, this is recommended, as it will ensure that + # oranda always sees the latest release right when it's available. Note + # however that Github's UI is wonky when you use workflow_run, and won't + # show this workflow as part of any commit. You have to go to the "actions" + # tab for your repo to see this one running (the gh-pages deploy will also + # only show up there). + workflow_run: + workflows: ["Release"] + types: + - completed + +# Alright, let's do it! +jobs: + web: + name: Build and deploy site and docs + runs-on: ubuntu-latest + steps: + # Setup + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: dtolnay/rust-toolchain@stable + - uses: swatinem/rust-cache@v2 + + # Install mdbook plugins + - name: Install mdbook plugins + run: | + cargo install --locked mdbook-admonish@1.13.1 + cargo install --locked mdbook-linkcheck@0.7.7 + + # Install and run oranda (and mdbook) + # This will write all output to ./public/ (including copying mdbook's output to there) + - name: Install and run oranda + run: | + curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/oranda/releases/latest/download/oranda-installer.sh | sh + oranda build + + # Deploy to our gh-pages branch (making it if it doesn't exist) + # the "public" dir that oranda made above will become the root dir + # of this branch. + # + # Note that once the gh-pages branch exists, you must + # go into repo's settings > pages and set "deploy from branch: gh-pages" + # the other defaults work fine. + - name: Deploy to Github Pages + uses: JamesIves/github-pages-deploy-action@v4.4.1 + # ONLY if we're on main (so no PRs or feature branches allowed!) + if: ${{ github.ref == 'refs/heads/main' }} + with: + branch: gh-pages + # Gotta tell the action where to find oranda's output + folder: /public + token: ${{ secrets.GITHUB_TOKEN }} + single-commit: true \ No newline at end of file diff --git a/.gitignore b/.gitignore index 17860e72..aee3bde5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ /schema /config.toml /data -/book \ No newline at end of file +/public \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 0e77143a..e218a350 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -106,4 +106,23 @@ codegen-units = 16 [profile.test.package.backtrace] # backtraces are super expensive to compute in development, # always optimize that crate -opt-level = 2 \ No newline at end of file +opt-level = 2 + + +# The profile that 'cargo dist' will build with +[profile.dist] +inherits = "release" +lto = "thin" + +# Config for 'cargo dist' +[workspace.metadata.dist] +# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax) +cargo-dist-version = "0.4.0" +# CI backends to support +ci = ["github"] +# The installers to generate for each app +installers = ["shell"] +# Target platforms to build apps for (Rust target-triple syntax) +targets = ["x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "aarch64-apple-darwin", "x86_64-apple-darwin"] +# Publish jobs to run in CI +pr-run-mode = "plan" diff --git a/book.toml b/book.toml index 40fc647c..3cc3978e 100644 --- a/book.toml +++ b/book.toml @@ -10,6 +10,4 @@ command = "mdbook-admonish" assets_version = "3.0.0" # do not edit: managed by `mdbook-admonish install` [output.html] -additional-css = ["./doc/mdbook-admonish.css"] - -[output.linkcheck] +additional-css = ["./doc/mdbook-admonish.css"] \ No newline at end of file diff --git a/crates/backoff/Cargo.toml b/crates/backoff/Cargo.toml index fa9dce37..a147ba08 100644 --- a/crates/backoff/Cargo.toml +++ b/crates/backoff/Cargo.toml @@ -3,6 +3,7 @@ name = "backoff" version = "0.1.0" authors = ["Jerome Gravel-Niquet "] edition = "2021" +repository = "https://github.com/superfly/corrosion" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/consul-client/Cargo.toml b/crates/consul-client/Cargo.toml index 0c7b5d55..1741b67d 100644 --- a/crates/consul-client/Cargo.toml +++ b/crates/consul-client/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0-alpha.0" edition = "2021" description = "Consul client" license = "MIT" +repository = "https://github.com/superfly/corrosion" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/corro-admin/Cargo.toml b/crates/corro-admin/Cargo.toml index 8acdee86..9e69403c 100644 --- a/crates/corro-admin/Cargo.toml +++ b/crates/corro-admin/Cargo.toml @@ -2,6 +2,7 @@ name = "corro-admin" version = "0.1.0" edition = "2021" +repository = "https://github.com/superfly/corrosion" [dependencies] camino = { workspace = true } diff --git a/crates/corro-agent/Cargo.toml b/crates/corro-agent/Cargo.toml index eb70a346..c63aafb5 100644 --- a/crates/corro-agent/Cargo.toml +++ b/crates/corro-agent/Cargo.toml @@ -2,6 +2,7 @@ name = "corro-agent" version = "0.1.0" edition = "2021" +repository = "https://github.com/superfly/corrosion" [dependencies] arc-swap = { workspace = true } diff --git a/crates/corro-api-types/Cargo.toml b/crates/corro-api-types/Cargo.toml index 9bf05601..02d9fd4d 100644 --- a/crates/corro-api-types/Cargo.toml +++ b/crates/corro-api-types/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0-alpha.1" edition = "2021" description = "common API types for corrosion" license = "MIT" +repository = "https://github.com/superfly/corrosion" [dependencies] async-trait = { workspace = true } diff --git a/crates/corro-client/Cargo.toml b/crates/corro-client/Cargo.toml index 30e8a075..0b8dde1f 100644 --- a/crates/corro-client/Cargo.toml +++ b/crates/corro-client/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0-alpha.1" edition = "2021" description = "client to interact with corrosion" license = "MIT" +repository = "https://github.com/superfly/corrosion" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/corro-pg/Cargo.toml b/crates/corro-pg/Cargo.toml index 72a73b8c..526e9824 100644 --- a/crates/corro-pg/Cargo.toml +++ b/crates/corro-pg/Cargo.toml @@ -2,6 +2,7 @@ name = "corro-pg" version = "0.1.0" edition = "2021" +repository = "https://github.com/superfly/corrosion" [dependencies] bytes = { workspace = true } diff --git a/crates/corro-tests/Cargo.toml b/crates/corro-tests/Cargo.toml index f22a93d1..cba785bc 100644 --- a/crates/corro-tests/Cargo.toml +++ b/crates/corro-tests/Cargo.toml @@ -2,6 +2,7 @@ name = "corro-tests" version = "0.1.0" edition = "2021" +repository = "https://github.com/superfly/corrosion" [dependencies] corro-agent = { path = "../corro-agent" } diff --git a/crates/corro-tpl/Cargo.toml b/crates/corro-tpl/Cargo.toml index e43cff7f..a2b5a74b 100644 --- a/crates/corro-tpl/Cargo.toml +++ b/crates/corro-tpl/Cargo.toml @@ -2,6 +2,7 @@ name = "corro-tpl" version = "0.1.0" edition = "2021" +repository = "https://github.com/superfly/corrosion" [dependencies] compact_str = { workspace = true } diff --git a/crates/corro-types/Cargo.toml b/crates/corro-types/Cargo.toml index cd9bec9a..ab0b65ea 100644 --- a/crates/corro-types/Cargo.toml +++ b/crates/corro-types/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0-alpha.1" edition = "2021" description = "common types for corrosion" license = "MIT" +repository = "https://github.com/superfly/corrosion" [dependencies] arc-swap = { workspace = true } diff --git a/crates/corrosion/Cargo.toml b/crates/corrosion/Cargo.toml index 28ff4d0e..be2a1666 100644 --- a/crates/corrosion/Cargo.toml +++ b/crates/corrosion/Cargo.toml @@ -2,6 +2,7 @@ name = "corrosion" version = "0.1.0" edition = "2021" +repository = "https://github.com/superfly/corrosion" [dependencies] build-info = { workspace = true } diff --git a/crates/spawn/Cargo.toml b/crates/spawn/Cargo.toml index daba20e1..d1496dfe 100644 --- a/crates/spawn/Cargo.toml +++ b/crates/spawn/Cargo.toml @@ -2,6 +2,7 @@ name = "spawn" version = "0.1.0" edition = "2021" +repository = "https://github.com/superfly/corrosion" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/sqlite-pool/Cargo.toml b/crates/sqlite-pool/Cargo.toml index e48c8387..2fce9f8c 100644 --- a/crates/sqlite-pool/Cargo.toml +++ b/crates/sqlite-pool/Cargo.toml @@ -2,6 +2,7 @@ name = "sqlite-pool" version = "0.1.0" edition = "2021" +repository = "https://github.com/superfly/corrosion" [dependencies] rusqlite = { workspace = true } diff --git a/crates/sqlite3-restore/Cargo.toml b/crates/sqlite3-restore/Cargo.toml index e45928cc..9b2d67db 100644 --- a/crates/sqlite3-restore/Cargo.toml +++ b/crates/sqlite3-restore/Cargo.toml @@ -2,6 +2,7 @@ name = "sqlite3-restore" version = "0.1.0" edition = "2021" +repository = "https://github.com/superfly/corrosion" [dependencies] nix = "*" diff --git a/crates/tripwire/Cargo.toml b/crates/tripwire/Cargo.toml index 21454671..567889a6 100644 --- a/crates/tripwire/Cargo.toml +++ b/crates/tripwire/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0-alpha.0" edition = "2021" description = "makes futures pre-emptible" license = "MIT" +repository = "https://github.com/superfly/corrosion" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/doc/crdts.md b/doc/crdts.md index ff5b6f5d..eece606f 100644 --- a/doc/crdts.md +++ b/doc/crdts.md @@ -4,7 +4,9 @@ [About CRDTs](https://crdt.tech/#:~:text=Conflict%2Dfree%20Replicated%20Data%20Types%20(CRDTs)%20are%20used%20in,merged%20into%20a%20consistent%20state.) -> Conflict-free Replicated Data Types (CRDTs) are used in systems with optimistic replication, where they take care of conflict resolution. CRDTs ensure that, no matter what data modifications are made on different replicas, the data can always be merged into a consistent state. This merge is performed automatically by the CRDT, without requiring any special conflict resolution code or user intervention. +```admonish +Conflict-free Replicated Data Types (CRDTs) are used in systems with optimistic replication, where they take care of conflict resolution. CRDTs ensure that, no matter what data modifications are made on different replicas, the data can always be merged into a consistent state. This merge is performed automatically by the CRDT, without requiring any special conflict resolution code or user intervention. +``` ## cr-sqlite diff --git a/oranda.json b/oranda.json new file mode 100644 index 00000000..5ba2bbed --- /dev/null +++ b/oranda.json @@ -0,0 +1,20 @@ +{ + "workspace": { + "name": "Corrosion" + }, + "project": { + "name": "Corrosion", + "readme_path": "./README.md" + }, + "marketing": {}, + "styles": { + "theme": "dark" + }, + "components": { + "changelog": true, + "mdbook": { + "path": "./" + }, + "artifacts": {} + } +} \ No newline at end of file