Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/pr-only-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
on:
pull_request:
workflow_dispatch:
inputs:
pr_number:
description: 'Pull Request Number'
required: false
default: ''

name: PR-only CI

jobs:
cli_docs:
name: Check CLI docs
runs-on: ubuntu-latest
steps:
- name: Find Git ref
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
PR_NUMBER="${{ github.event.inputs.pr_number || null }}"
if test -n "${PR_NUMBER}"; then
GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )"
else
GIT_REF="${{ github.ref }}"
fi
echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV"
- name: Checkout sources
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_REF }}
- uses: dsherret/rust-toolchain-file@v1

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'PR-only CI' step
Uses Step
uses 'dsherret/rust-toolchain-file' with ref 'v1', not a pinned commit hash
- name: Checkout docs
uses: actions/checkout@v4
with:
repository: clockworklabs/spacetime-docs
ref: master
path: spacetime-docs
- name: Check for docs change
run: |
cargo run --features markdown-docs -p spacetimedb-cli > spacetime-docs/docs/cli-reference.md
cd spacetime-docs
# This is needed because our website doesn't render markdown quite properly.
# See the README in spacetime-docs for more details.
sed -i'' -E 's!^(##) `(.*)`$!\1 \2!' docs/cli-reference.md
sed -i'' -E 's!^(######) \*\*(.*)\*\*$!\1 <b>\2</b>!' docs/cli-reference.md
git status
if git diff --exit-code HEAD; then
echo "No docs changes detected"
else
echo "It looks like the CLI docs have changed:"
exit 1
fi
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ bytestring = { version = "1.2.0", features = ["serde"] }
cargo_metadata = "0.17.0"
chrono = { version = "0.4.24", default-features = false }
clap = { version = "4.2.4", features = ["derive", "wrap_help"] }
clap-markdown = "0.1.4"
colored = "2.0.0"
console = { version = "0.15.6" }
convert_case = "0.6.0"
Expand Down
4 changes: 4 additions & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ license-file = "LICENSE"
description = "A command line interface for SpacetimeDB"
rust-version.workspace = true

[features]
markdown-docs = []

[lib]
bench = false

Expand Down Expand Up @@ -70,6 +73,7 @@ walkdir.workspace = true
wasmbin.workspace = true
wasmtime.workspace = true
webbrowser.workspace = true
clap-markdown.workspace = true

[target.'cfg(windows)'.dependencies]
windows-sys = { workspace = true, features = ["Win32_System_Console"] }
Expand Down
9 changes: 9 additions & 0 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use spacetimedb_paths::{RootDir, SpacetimePaths};
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;

#[cfg(not(feature = "markdown-docs"))]
#[tokio::main]
async fn main() -> anyhow::Result<ExitCode> {
// Compute matches before loading the config, because `Config` has an observable `drop` method
Expand All @@ -31,6 +32,14 @@ async fn main() -> anyhow::Result<ExitCode> {
exec_subcommand(config, &paths, root_dir, cmd, subcommand_args).await
}

#[cfg(feature = "markdown-docs")]
#[tokio::main]
async fn main() -> anyhow::Result<ExitCode> {
let markdown = clap_markdown::help_markdown_command(&get_command());
println!("{}", markdown);
Ok(ExitCode::SUCCESS)
}

fn get_command() -> Command {
Command::new("spacetime")
.version(version::CLI_VERSION)
Expand Down
Loading