Skip to content

Commit

Permalink
Apply new clippy hints and remove old test logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mamcx committed Feb 4, 2025
1 parent ea63fb5 commit 2f53089
Show file tree
Hide file tree
Showing 93 changed files with 4,339 additions and 1,668 deletions.
72 changes: 0 additions & 72 deletions .github/workflows/linux-build.yml

This file was deleted.

57 changes: 0 additions & 57 deletions .github/workflows/macos-build.yml

This file was deleted.

70 changes: 70 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Package SpacetimeDB CLI

on:
push:
tags:
- '**'
branches:
- master
- release/*

jobs:
build-cli:
strategy:
fail-fast: false
matrix:
include:
- { name: x86_64 Linux, target: x86_64-unknown-linux-gnu, runner: bare-metal }
- { name: aarch64 Linux, target: aarch64-unknown-linux-gnu, runner: arm-runner }
- { name: aarch64 macOS, target: aarch64-apple-darwin, runner: macos-latest }
- { name: x86_64 macOS, target: x86_64-apple-darwin, runner: macos-latest }
- { name: x86_64 Windows, target: x86_64-pc-windows-msvc, runner: windows-latest }

name: Build CLI for ${{ matrix.name }}
runs-on: ${{ matrix.runner }}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Show arch
run: uname -a

- name: Install Rust
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 'Package SpacetimeDB CLI' step
Uses Step
uses 'dsherret/rust-toolchain-file' with ref 'v1', not a pinned commit hash

- name: Install rust target
run: rustup target add ${{ matrix.target }}

- name: Compile
run: |
cargo build --release --target ${{ matrix.target }} -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update
- name: Package (unix)
if: ${{ runner.os != 'Windows' }}
run: |
mkdir build
cd target/${{matrix.target}}/release
tar -czf ../../../build/spacetime-${{matrix.target}}.tar.gz spacetimedb-{cli,standalone,update}
- name: Package (windows)
if: ${{ runner.os == 'Windows' }}
run: |
mkdir build
cd target/${{matrix.target}}/release
7z a ../../../build/spacetime-${{matrix.target}}.zip spacetimedb-cli.exe spacetimedb-standalone.exe spacetimedb-update.exe
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch

- name: Upload to DO Spaces
uses: shallwefootball/s3-upload-action@master

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Package SpacetimeDB CLI' step
Uses Step
uses 'shallwefootball/s3-upload-action' with ref 'master', not a pinned commit hash
with:
aws_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
aws_bucket: ${{ vars.AWS_BUCKET }}
source_dir: build
endpoint: https://nyc3.digitaloceanspaces.com
destination_dir: ${{ steps.extract_branch.outputs.branch }}

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions Job or Workflow does not set permissions
41 changes: 0 additions & 41 deletions .github/workflows/windows-build.yml

This file was deleted.

5 changes: 3 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion crates/cli/src/common_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ pub fn yes() -> Arg {
.long("yes")
.short('y')
.action(SetTrue)
.help("Assume \"yes\" as answer to all prompts and run non-interactively")
.help("Run non-interactively wherever possible. This will answer \"yes\" to almost all prompts, but will sometimes answer \"no\" to preserve non-interactivity (e.g. when prompting whether to log in with spacetimedb.com).")
}
8 changes: 0 additions & 8 deletions crates/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,14 +820,6 @@ Update the server's fingerprint with:
pub fn spacetimedb_token(&self) -> Option<&String> {
self.home.spacetimedb_token.as_ref()
}

pub fn spacetimedb_token_or_error(&self) -> anyhow::Result<&String> {
if let Some(token) = self.spacetimedb_token() {
Ok(token)
} else {
Err(anyhow::anyhow!("No login token found. Please run `spacetime login`."))
}
}
}

#[cfg(test)]
Expand Down
5 changes: 4 additions & 1 deletion crates/cli/src/subcommands/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub fn cli() -> clap::Command {
.arg(Arg::new("arguments").help("arguments formatted as JSON").num_args(1..))
.arg(common_args::server().help("The nickname, host name or URL of the server hosting the database"))
.arg(common_args::anonymous())
.arg(common_args::yes())
.after_help("Run `spacetime help call` for more detailed information.\n")
}

Expand All @@ -38,6 +39,7 @@ pub async fn exec(mut config: Config, args: &ArgMatches) -> Result<(), Error> {
let reducer_name = args.get_one::<String>("reducer_name").unwrap();
let arguments = args.get_many::<String>("arguments");
let server = args.get_one::<String>("server").map(|s| s.as_ref());
let force = args.get_flag("force");

let anon_identity = args.get_flag("anon_identity");

Expand All @@ -49,14 +51,15 @@ pub async fn exec(mut config: Config, args: &ArgMatches) -> Result<(), Error> {
database_identity.clone(),
reducer_name
));
let auth_header = get_auth_header(&config, anon_identity)?;
let auth_header = get_auth_header(&mut config, anon_identity, server, !force).await?;
let builder = add_auth_header_opt(builder, &auth_header);
let describe_reducer = util::describe_reducer(
&mut config,
database_identity,
server.map(|x| x.to_string()),
reducer_name.clone(),
anon_identity,
!force,
)
.await?;

Expand Down
6 changes: 4 additions & 2 deletions crates/cli/src/subcommands/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@ pub fn cli() -> clap::Command {
.help("The name or identity of the database to delete"),
)
.arg(common_args::server().help("The nickname, host name or URL of the server hosting the database"))
.arg(common_args::yes())
.after_help("Run `spacetime help delete` for more detailed information.\n")
}

pub async fn exec(config: Config, args: &ArgMatches) -> Result<(), anyhow::Error> {
pub async fn exec(mut config: Config, args: &ArgMatches) -> Result<(), anyhow::Error> {
let server = args.get_one::<String>("server").map(|s| s.as_ref());
let database = args.get_one::<String>("database").unwrap();
let force = args.get_flag("force");

let identity = database_identity(&config, database, server).await?;

let builder = reqwest::Client::new().post(format!("{}/database/delete/{}", config.get_host_url(server)?, identity));
let auth_header = get_auth_header(&config, false)?;
let auth_header = get_auth_header(&mut config, false, server, !force).await?;
let builder = add_auth_header_opt(builder, &auth_header);
builder.send().await?.error_for_status()?;

Expand Down
6 changes: 4 additions & 2 deletions crates/cli/src/subcommands/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ pub fn cli() -> clap::Command {
)
.arg(common_args::anonymous())
.arg(common_args::server().help("The nickname, host name or URL of the server hosting the database"))
.arg(common_args::yes())
.after_help("Run `spacetime help describe` for more detailed information.\n")
}

pub async fn exec(config: Config, args: &ArgMatches) -> Result<(), anyhow::Error> {
pub async fn exec(mut config: Config, args: &ArgMatches) -> Result<(), anyhow::Error> {
let database = args.get_one::<String>("database").unwrap();
let entity_name = args.get_one::<String>("entity_name");
let entity_type = args.get_one::<String>("entity_type");
let server = args.get_one::<String>("server").map(|s| s.as_ref());
let force = args.get_flag("force");

let anon_identity = args.get_flag("anon_identity");

Expand All @@ -46,7 +48,7 @@ pub async fn exec(config: Config, args: &ArgMatches) -> Result<(), anyhow::Error
entity_name
),
});
let auth_header = get_auth_header(&config, anon_identity)?;
let auth_header = get_auth_header(&mut config, anon_identity, server, !force).await?;
let builder = add_auth_header_opt(builder, &auth_header);

let descr = builder.send().await?.error_for_status()?.text().await?;
Expand Down
Loading

0 comments on commit 2f53089

Please sign in to comment.