Skip to content

Commit

Permalink
Backport 0.4 fix sql fmt (#136)
Browse files Browse the repository at this point in the history
* fix sql fmt (#134)

* fix sql fmt

* version fix

* Doc lint fixes

* Bump versions

* Update docs

* Enable CI

---------

Co-authored-by: David Braden <neonphog@gmail.com>
  • Loading branch information
ThetaSinner and neonphog authored Oct 11, 2024
1 parent 6a84ed4 commit 7002ef7
Show file tree
Hide file tree
Showing 21 changed files with 86 additions and 72 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ on:
push:
branches:
- main
- release-0.4.x
pull_request:
branches:
- main
- release-0.4.x
jobs:
release-build:
name: Release Build
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ on:
push:
branches:
- main
- release-0.4.x
pull_request:
branches:
- main
- release-0.4.x
jobs:
static-analysis:
name: Static Analysis
Expand Down Expand Up @@ -37,4 +39,4 @@ jobs:
args: cargo-readme

- name: Make Static
run: make static
run: CHK_SQL_FMT=1 make static
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ on:
push:
branches:
- main
- release-0.4.x
pull_request:
branches:
- main
- release-0.4.x
jobs:
test:
name: Test
Expand Down
22 changes: 6 additions & 16 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ futures = "0.3.28"
# determinism of the strict client/server version checks
hc_seed_bundle = { version = "=0.2.4", path = "./crates/hc_seed_bundle" }
# lair_keystore_api must be pinned to enable strict version checks
lair_keystore_api = { version = "=0.4.5", path = "./crates/lair_keystore_api" }
lair_keystore_api = { version = "=0.4.6", path = "./crates/lair_keystore_api" }
lru = "0.12.3"
nanoid = "0.4.0"
one_err = "0.0.8"
Expand All @@ -33,7 +33,7 @@ serde_bytes = "0.11.9"
serde_json = "1"
serde_yaml = "0.9.21"
sodoken = "=0.0.11"
sqlformat = "0.2.1"
sqlformat = "=0.2.6"
structopt = "0.3.26"
sysinfo = "0.30.12"
tempdir = "0.3.7"
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ License: MIT OR Apache-2.0

### `lair-keystore --help`
```text
lair_keystore 0.4.5
lair_keystore 0.4.6
secret lair private keystore
USAGE:
Expand Down Expand Up @@ -74,7 +74,7 @@ SUBCOMMANDS:
```
### `lair-keystore init --help`
```text
lair-keystore-init 0.4.5
lair-keystore-init 0.4.6
Set up a new lair private keystore.
USAGE:
Expand All @@ -92,7 +92,7 @@ FLAGS:
```
### `lair-keystore url --help`
```text
lair-keystore-url 0.4.5
lair-keystore-url 0.4.6
Print the connection_url for a configured lair-keystore
server to stdout and exit.
Expand All @@ -106,7 +106,7 @@ FLAGS:
```
### `lair-keystore import-seed --help`
```text
lair-keystore-import-seed 0.4.5
lair-keystore-import-seed 0.4.6
Load a seed bundle into this lair-keystore instance.
Note, this operation requires capturing the pid_file,
make sure you do not have a lair-server running.
Expand Down Expand Up @@ -143,7 +143,7 @@ ARGS:
```
### `lair-keystore server --help`
```text
lair-keystore-server 0.4.5
lair-keystore-server 0.4.6
Run a lair keystore server instance. Note you must
have initialized a config file first with
'lair-keystore init'.
Expand Down
20 changes: 10 additions & 10 deletions crates/hc_seed_bundle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ SeedBundle parsing and generation library.
#### Rationale

- Applications like Holochain have different requirements than classic
blockchain systems in terms of key management. Namely there is no need
for read-only or hardened wallets (Holochain handles these concepts
through capabilities and membranes).
blockchain systems in terms of key management. Namely there is no need
for read-only or hardened wallets (Holochain handles these concepts
through capabilities and membranes).
- Applications like Holochain still have need of hierarchy and determinism
in key (or in this case seed) derivation.
in key (or in this case seed) derivation.
- Since we're using libsodium for hashing, signature, and encryption
algorithms, let's use it for derivation as well.
algorithms, let's use it for derivation as well.
- To be psychologically compatible with the
[Bitcoin "HD Wallet" spec](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki),
we will do away with the "context" part of sodium KDF by always setting
it to `b"SeedBndl"` and focusing on the `subkey_id` and can declare a
chain of subsequent derivations of a 32 byte seed in the form
`m/68/1/65/8` where we apply `subkey_id`s 68, 1, 65, then 8 in turn.
[Bitcoin "HD Wallet" spec](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki),
we will do away with the "context" part of sodium KDF by always setting
it to `b"SeedBndl"` and focusing on the `subkey_id` and can declare a
chain of subsequent derivations of a 32 byte seed in the form
`m/68/1/65/8` where we apply `subkey_id`s 68, 1, 65, then 8 in turn.

#### hcSeedBundle Encoding Spec

Expand Down
20 changes: 10 additions & 10 deletions crates/hc_seed_bundle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
//! ### Rationale
//!
//! - Applications like Holochain have different requirements than classic
//! blockchain systems in terms of key management. Namely there is no need
//! for read-only or hardened wallets (Holochain handles these concepts
//! through capabilities and membranes).
//! blockchain systems in terms of key management. Namely there is no need
//! for read-only or hardened wallets (Holochain handles these concepts
//! through capabilities and membranes).
//! - Applications like Holochain still have need of hierarchy and determinism
//! in key (or in this case seed) derivation.
//! in key (or in this case seed) derivation.
//! - Since we're using libsodium for hashing, signature, and encryption
//! algorithms, let's use it for derivation as well.
//! algorithms, let's use it for derivation as well.
//! - To be psychologically compatible with the
//! [Bitcoin "HD Wallet" spec](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki),
//! we will do away with the "context" part of sodium KDF by always setting
//! it to `b"SeedBndl"` and focusing on the `subkey_id` and can declare a
//! chain of subsequent derivations of a 32 byte seed in the form
//! `m/68/1/65/8` where we apply `subkey_id`s 68, 1, 65, then 8 in turn.
//! [Bitcoin "HD Wallet" spec](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki),
//! we will do away with the "context" part of sodium KDF by always setting
//! it to `b"SeedBndl"` and focusing on the `subkey_id` and can declare a
//! chain of subsequent derivations of a 32 byte seed in the form
//! `m/68/1/65/8` where we apply `subkey_id`s 68, 1, 65, then 8 in turn.
//!
//! ### hcSeedBundle Encoding Spec
//!
Expand Down
2 changes: 1 addition & 1 deletion crates/lair_keystore/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lair_keystore"
version = "0.4.5"
version = "0.4.6"
description = "secret lair private keystore"
license = "MIT OR Apache-2.0"
repository = "https://github.com/holochain/lair"
Expand Down
10 changes: 5 additions & 5 deletions crates/lair_keystore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ License: MIT OR Apache-2.0

### `lair-keystore --help`
```text
lair_keystore 0.4.5
lair_keystore 0.4.6
secret lair private keystore
USAGE:
Expand Down Expand Up @@ -74,7 +74,7 @@ SUBCOMMANDS:
```
### `lair-keystore init --help`
```text
lair-keystore-init 0.4.5
lair-keystore-init 0.4.6
Set up a new lair private keystore.
USAGE:
Expand All @@ -92,7 +92,7 @@ FLAGS:
```
### `lair-keystore url --help`
```text
lair-keystore-url 0.4.5
lair-keystore-url 0.4.6
Print the connection_url for a configured lair-keystore
server to stdout and exit.
Expand All @@ -106,7 +106,7 @@ FLAGS:
```
### `lair-keystore import-seed --help`
```text
lair-keystore-import-seed 0.4.5
lair-keystore-import-seed 0.4.6
Load a seed bundle into this lair-keystore instance.
Note, this operation requires capturing the pid_file,
make sure you do not have a lair-server running.
Expand Down Expand Up @@ -143,7 +143,7 @@ ARGS:
```
### `lair-keystore server --help`
```text
lair-keystore-server 0.4.5
lair-keystore-server 0.4.6
Run a lair keystore server instance. Note you must
have initialized a config file first with
'lair-keystore init'.
Expand Down
16 changes: 14 additions & 2 deletions crates/lair_keystore/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
const SQL_DIR: &str = "./src/sql";
const CHK_SQL_FMT: Option<&str> = option_env!("CHK_SQL_FMT");
const FIX_SQL_FMT: Option<&str> = option_env!("FIX_SQL_FMT");

fn chk_sql_fmt() -> bool {
if let Some(csf) = CHK_SQL_FMT {
!csf.is_empty()
} else {
false
}
}

fn fix_sql_fmt() -> bool {
if let Some(fsf) = FIX_SQL_FMT {
!fsf.is_empty()
Expand Down Expand Up @@ -54,7 +64,7 @@ fn check_fmt(path: &std::path::Path) {
let opt = sqlformat::FormatOptions {
indent: sqlformat::Indent::Spaces(2),
uppercase: true,
lines_between_queries: 1,
lines_between_queries: 2,
};

let fmt_sql =
Expand All @@ -70,15 +80,17 @@ fn check_fmt(path: &std::path::Path) {
path.to_string_lossy()
);
}
} else {
} else if chk_sql_fmt() {
panic_on_diff(path, src_sql, fmt_sql);
}
}

fn main() {
lair_keystore_api::internal::build::build_ver();

println!("cargo:rerun-if-env-changed=CHK_SQL_FMT");
println!("cargo:rerun-if-env-changed=FIX_SQL_FMT");

for sql in find_sql(std::path::Path::new(SQL_DIR)) {
check_fmt(&sql);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/lair_keystore/src/docs/help.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### `lair-keystore --help`
```text
lair_keystore 0.4.5
lair_keystore 0.4.6
secret lair private keystore
USAGE:
Expand Down
2 changes: 1 addition & 1 deletion crates/lair_keystore/src/docs/import-seed-help.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### `lair-keystore import-seed --help`
```text
lair-keystore-import-seed 0.4.5
lair-keystore-import-seed 0.4.6
Load a seed bundle into this lair-keystore instance.
Note, this operation requires capturing the pid_file,
make sure you do not have a lair-server running.
Expand Down
2 changes: 1 addition & 1 deletion crates/lair_keystore/src/docs/init-help.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### `lair-keystore init --help`
```text
lair-keystore-init 0.4.5
lair-keystore-init 0.4.6
Set up a new lair private keystore.
USAGE:
Expand Down
2 changes: 1 addition & 1 deletion crates/lair_keystore/src/docs/server-help.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### `lair-keystore server --help`
```text
lair-keystore-server 0.4.5
lair-keystore-server 0.4.6
Run a lair keystore server instance. Note you must
have initialized a config file first with
'lair-keystore init'.
Expand Down
2 changes: 1 addition & 1 deletion crates/lair_keystore/src/docs/url-help.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### `lair-keystore url --help`
```text
lair-keystore-url 0.4.5
lair-keystore-url 0.4.6
Print the connection_url for a configured lair-keystore
server to stdout and exit.
Expand Down
Loading

0 comments on commit 7002ef7

Please sign in to comment.