mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-06 07:26:43 -04:00
CI - Move simple jobs into cargo ci (#4871)
# Description of Changes Migrate these checks into `cargo ci`: - Check that packages are publishable - Docs test - TypeScript - Tests # API and ABI breaking changes None. CI only. # Expected complexity level and risk 2 # Testing - [ ] CI passes --------- Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
This commit is contained in:
+33
-96
@@ -342,24 +342,8 @@ jobs:
|
||||
- uses: dsherret/rust-toolchain-file@v1
|
||||
- name: Set default rust toolchain
|
||||
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
|
||||
- name: Set up Python env
|
||||
run: |
|
||||
test -d venv || python3 -m venv venv
|
||||
venv/bin/pip3 install argparse toml
|
||||
- name: Run checks
|
||||
run: |
|
||||
set -ueo pipefail
|
||||
FAILED=0
|
||||
ROOTS=(spacetimedb spacetimedb-sdk)
|
||||
CRATES=$(venv/bin/python3 tools/find-publish-list.py --recursive --directories --quiet "${ROOTS[@]}")
|
||||
for crate_dir in $CRATES; do
|
||||
if ! venv/bin/python3 tools/crate-publish-checks.py "${crate_dir}"; then
|
||||
FAILED=$(( $FAILED + 1 ))
|
||||
fi
|
||||
done
|
||||
if [ $FAILED -gt 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
run: cargo ci publish-checks
|
||||
|
||||
update:
|
||||
name: Test spacetimedb-update flow (${{ matrix.target }})
|
||||
@@ -1160,13 +1144,12 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: docs
|
||||
run: pnpm install
|
||||
- uses: dsherret/rust-toolchain-file@v1
|
||||
- name: Set default rust toolchain
|
||||
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
|
||||
|
||||
- name: Docusaurus build
|
||||
working-directory: docs
|
||||
run: pnpm build
|
||||
run: cargo ci docs
|
||||
|
||||
typescript-test:
|
||||
name: TypeScript - Tests
|
||||
@@ -1198,14 +1181,6 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Build module library and SDK
|
||||
working-directory: crates/bindings-typescript
|
||||
run: pnpm build
|
||||
|
||||
- name: Run module library and SDK tests
|
||||
working-directory: crates/bindings-typescript
|
||||
run: pnpm test
|
||||
|
||||
# - name: Extract SpacetimeDB branch name from file
|
||||
# id: extract-branch
|
||||
# run: |
|
||||
@@ -1245,76 +1220,38 @@ jobs:
|
||||
save-if: false
|
||||
prefix-key: v1
|
||||
|
||||
# This step shouldn't be needed, but somehow we end up with caches that are missing librusty_v8.a.
|
||||
# ChatGPT suspects that this could be due to different build invocations using the same target dir,
|
||||
# and this makes sense to me because we only see it in this job where we mix `cargo build -p` with
|
||||
# `cargo build --manifest-path` (which apparently build different dependency trees).
|
||||
# However, we've been unable to fix it so... /shrug
|
||||
- name: Check v8 outputs
|
||||
run: |
|
||||
find "${CARGO_TARGET_DIR}"/ -type f | grep '[/_]v8' || true
|
||||
if ! [ -f "${CARGO_TARGET_DIR}"/debug/gn_out/obj/librusty_v8.a ]; then
|
||||
echo "Could not find v8 output file librusty_v8.a; rebuilding manually."
|
||||
cargo clean -p v8 || true
|
||||
cargo build -p v8
|
||||
fi
|
||||
if ! [ -f "${CARGO_TARGET_DIR}"/release/gn_out/obj/librusty_v8.a ]; then
|
||||
echo "Could not find v8 output file librusty_v8.a; rebuilding manually."
|
||||
cargo clean --release -p v8 || true
|
||||
cargo build --release -p v8
|
||||
fi
|
||||
|
||||
- name: Install SpacetimeDB CLI from the local checkout
|
||||
run: |
|
||||
export CARGO_HOME="$HOME/.cargo"
|
||||
echo "$CARGO_HOME/bin" >> "$GITHUB_PATH"
|
||||
cargo install --force --path crates/cli --locked --message-format=short
|
||||
cargo install --force --path crates/standalone --locked --message-format=short
|
||||
# Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
|
||||
ln -sf $CARGO_HOME/bin/spacetimedb-cli $CARGO_HOME/bin/spacetime
|
||||
# Clear any existing information
|
||||
spacetime server clear -y
|
||||
|
||||
- name: Generate client bindings
|
||||
working-directory: templates/chat-react-ts
|
||||
run: |
|
||||
pnpm generate
|
||||
|
||||
- name: Check for changes
|
||||
working-directory: templates/chat-react-ts
|
||||
run: |
|
||||
"${GITHUB_WORKSPACE}"/tools/check-diff.sh src/module_bindings || {
|
||||
echo "Error: Bindings are dirty. Please generate bindings again and commit them to this branch."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# - name: Start SpacetimeDB
|
||||
# # This step shouldn't be needed, but somehow we end up with caches that are missing librusty_v8.a.
|
||||
# # ChatGPT suspects that this could be due to different build invocations using the same target dir,
|
||||
# # and this makes sense to me because we only see it in this job where we mix `cargo build -p` with
|
||||
# # `cargo build --manifest-path` (which apparently build different dependency trees).
|
||||
# # However, we've been unable to fix it so... /shrug
|
||||
# - name: Check v8 outputs
|
||||
# run: |
|
||||
# spacetime start &
|
||||
# disown
|
||||
# find "${CARGO_TARGET_DIR}"/ -type f | grep '[/_]v8' || true
|
||||
# if ! [ -f "${CARGO_TARGET_DIR}"/debug/gn_out/obj/librusty_v8.a ]; then
|
||||
# echo "Could not find v8 output file librusty_v8.a; rebuilding manually."
|
||||
# cargo clean -p v8 || true
|
||||
# cargo build -p v8
|
||||
# fi
|
||||
# if ! [ -f "${CARGO_TARGET_DIR}"/release/gn_out/obj/librusty_v8.a ]; then
|
||||
# echo "Could not find v8 output file librusty_v8.a; rebuilding manually."
|
||||
# cargo clean --release -p v8 || true
|
||||
# cargo build --release -p v8
|
||||
# fi
|
||||
|
||||
# - name: Publish module to SpacetimeDB
|
||||
# working-directory: SpacetimeDB/templates/quickstart-chat-typescript/spacetimedb
|
||||
# - name: Install SpacetimeDB CLI from the local checkout
|
||||
# run: |
|
||||
# spacetime logout && spacetime login --server-issued-login local
|
||||
# spacetime publish -s local quickstart-chat -c -y
|
||||
# export CARGO_HOME="$HOME/.cargo"
|
||||
# echo "$CARGO_HOME/bin" >> "$GITHUB_PATH"
|
||||
# cargo install --force --path crates/cli --locked --message-format=short
|
||||
# cargo install --force --path crates/standalone --locked --message-format=short
|
||||
# # Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
|
||||
# ln -sf $CARGO_HOME/bin/spacetimedb-cli $CARGO_HOME/bin/spacetime
|
||||
# # Clear any existing information
|
||||
# spacetime server clear -y
|
||||
|
||||
# - name: Publish module to SpacetimeDB
|
||||
# working-directory: SpacetimeDB/templates/quickstart-chat-typescript/spacetimedb
|
||||
# run: |
|
||||
# spacetime logs quickstart-chat
|
||||
|
||||
- name: Check that quickstart-chat builds
|
||||
working-directory: templates/chat-react-ts
|
||||
run: pnpm build
|
||||
|
||||
- name: Check that templates build
|
||||
working-directory: templates/
|
||||
run: pnpm -r --filter "./**" run build
|
||||
|
||||
- name: Check that subdirectories build
|
||||
working-directory: crates/bindings-typescript
|
||||
run: pnpm -r --filter "./**" run build
|
||||
- name: Run TypeScript tests
|
||||
run: cargo ci typescript-test
|
||||
|
||||
# - name: Run quickstart-chat tests
|
||||
# working-directory: examples/quickstart-chat
|
||||
|
||||
@@ -195,6 +195,39 @@ Usage: global-json-policy
|
||||
|
||||
- `--help`: Print help
|
||||
|
||||
### `publish-checks`
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
Usage: publish-checks
|
||||
```
|
||||
|
||||
**Options:**
|
||||
|
||||
- `--help`: Print help
|
||||
|
||||
### `typescript-test`
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
Usage: typescript-test
|
||||
```
|
||||
|
||||
**Options:**
|
||||
|
||||
- `--help`: Print help
|
||||
|
||||
### `docs`
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
Usage: docs
|
||||
```
|
||||
|
||||
**Options:**
|
||||
|
||||
- `--help`: Print help
|
||||
|
||||
### `help`
|
||||
|
||||
**Usage:**
|
||||
|
||||
@@ -272,6 +272,12 @@ enum CiCmd {
|
||||
|
||||
/// Verify that any non-root global.json files are symlinks to the root global.json.
|
||||
GlobalJsonPolicy,
|
||||
/// Checks that publishable crates satisfy publish constraints.
|
||||
PublishChecks,
|
||||
/// Runs TypeScript workspace tests and template build checks.
|
||||
TypescriptTest,
|
||||
/// Builds the docs site.
|
||||
Docs,
|
||||
}
|
||||
|
||||
fn run_all_clap_subcommands(skips: &[String]) -> Result<()> {
|
||||
@@ -378,6 +384,65 @@ fn run_dlls() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_publish_checks() -> Result<()> {
|
||||
cmd!("bash", "-lc", "test -d venv || python3 -m venv venv").run()?;
|
||||
cmd!("venv/bin/pip3", "install", "argparse", "toml").run()?;
|
||||
|
||||
let crates = cmd!(
|
||||
"venv/bin/python3",
|
||||
"tools/find-publish-list.py",
|
||||
"--recursive",
|
||||
"--directories",
|
||||
"--quiet",
|
||||
"spacetimedb",
|
||||
"spacetimedb-sdk"
|
||||
)
|
||||
.read()?;
|
||||
|
||||
let mut failed = Vec::new();
|
||||
for crate_dir in crates.split_whitespace() {
|
||||
if let Err(err) = cmd!("venv/bin/python3", "tools/crate-publish-checks.py", crate_dir).run() {
|
||||
eprintln!("crate publish checks failed for {crate_dir}: {err}");
|
||||
failed.push(crate_dir.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
if !failed.is_empty() {
|
||||
bail!("crate publish checks failed for: {}", failed.join(", "));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_typescript_tests() -> Result<()> {
|
||||
cmd!("pnpm", "build").dir("crates/bindings-typescript").run()?;
|
||||
cmd!("pnpm", "test").dir("crates/bindings-typescript").run()?;
|
||||
cmd!("pnpm", "generate").dir("templates/chat-react-ts").run()?;
|
||||
let diff_status = cmd!(
|
||||
"bash",
|
||||
"tools/check-diff.sh",
|
||||
"templates/chat-react-ts/src/module_bindings"
|
||||
)
|
||||
.run()?;
|
||||
if !diff_status.status.success() {
|
||||
bail!("Bindings are dirty. Please generate bindings again and commit them to this branch.");
|
||||
}
|
||||
cmd!("pnpm", "build").dir("templates/chat-react-ts").run()?;
|
||||
cmd!("pnpm", "-r", "--filter", "./**", "run", "build")
|
||||
.dir("templates")
|
||||
.run()?;
|
||||
cmd!("pnpm", "-r", "--filter", "./**", "run", "build")
|
||||
.dir("crates/bindings-typescript")
|
||||
.run()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_docs_build() -> Result<()> {
|
||||
cmd!("pnpm", "install").dir("docs").run()?;
|
||||
cmd!("pnpm", "build").dir("docs").run()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
env_logger::init();
|
||||
|
||||
@@ -638,6 +703,18 @@ fn main() -> Result<()> {
|
||||
check_global_json_policy()?;
|
||||
}
|
||||
|
||||
Some(CiCmd::PublishChecks) => {
|
||||
run_publish_checks()?;
|
||||
}
|
||||
|
||||
Some(CiCmd::TypescriptTest) => {
|
||||
run_typescript_tests()?;
|
||||
}
|
||||
|
||||
Some(CiCmd::Docs) => {
|
||||
run_docs_build()?;
|
||||
}
|
||||
|
||||
None => run_all_clap_subcommands(&cli.skip)?,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user