Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(env-collector): add .json support and add documentation #1046

Merged
merged 4 commits into from
Sep 9, 2024
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
2 changes: 1 addition & 1 deletion libs/env-collector/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "env-collector"
version = "0.1.0"
version = "0.1.1"
edition = "2021"

[dependencies]
Expand Down
60 changes: 60 additions & 0 deletions libs/env-collector/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Env collector
===

This is a simple tool to collect possible environment variables from `Settings` structure and place it to `README.md` file.

## Usage

1. Add `env-collector` to your `server` crate:
```toml
# Cargo.toml
[dependencies]
env-collector = { git = "https://github.com/blockscout/blockscout-rs", version = "0.1.1" }
```

2. In your `server` crate create new binary file called `check-envs.rs` with the following content:

```rust
// check-envs.rs
use <path_to_settings>::Settings;
use env_collector::run_env_collector_cli;

fn main() {
run_env_collector_cli::<Settings>(
"<SERVICE_NAME_PREFIX>",
"README.md",
"<PATH TO .TOML/.JSON EXAMPLE CONFIG>",
&["<ENV_PREFIX_TO_IGNORE>"],
);
}
```
3. In `README.md` file add special **anchors** lines to specify where to store the table with ENVs:

```markdown
## Envs

[anchor]: <> (anchors.envs.start)
[anchor]: <> (anchors.envs.end)
```

4. (Optional) In your `justfile` add new command to run `check-envs.rs`:

```just
# justfile
check-envs:
cargo run --bin check-envs
```

5. Run command `just check-envs` to generate ENVs table in `README.md` file.

6. Add github action to run this binary on every push to validate ENVs table in `README.md` file:
```yaml
[... other steps of `test` job ...]

- name: ENVs in doc tests
run: cargo run --bin check-envs
env:
VALIDATE_ONLY: true

[... other steps of `test` job ...]
```
Loading
Loading