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
6 changes: 2 additions & 4 deletions .github/workflows/stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,8 @@ jobs:
if: steps.swapfile.outcome == 'success'
run: RUST_BACKTRACE=1 cargo test --no-run --locked --workspace --all-features --jobs $JOBS

- name: ENVs in documentation
run: cargo run --bin env-docs-generation
env:
VALIDATE_ONLY: true
- name: Verify ENVs in README.md
run: cargo run --bin env-docs-generation -- --validate-only

- name: Unit tests
run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --all-features --lib --bins --jobs $JOBS -- --nocapture
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/user-ops-indexer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ jobs:
with:
working-directory: user-ops-indexer

- name: Build
id: build
run: RUST_BACKTRACE=1 cargo test --no-run --locked --workspace --all-features

- name: Verify ENVs in README.md
run: cargo run --bin env-docs-generation -- --validate-only

- name: Unit tests
run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --all-features --lib --bins -- --nocapture
if: success() || failure()
Expand Down Expand Up @@ -92,4 +99,4 @@ jobs:
service_name: 'user-ops-indexer'
swagger_path: 'user-ops-indexer/user-ops-indexer-proto/swagger/user-ops-indexer.swagger.yaml'
secrets:
api_token_github: ${{ secrets.BLOCKSCOUT_BOT_TOKEN }}
api_token_github: ${{ secrets.BLOCKSCOUT_BOT_TOKEN }}
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.3.0"
version = "0.3.1"
edition = "2021"

[dependencies]
Expand Down
40 changes: 25 additions & 15 deletions libs/env-collector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,24 @@ This is a simple tool to collect possible environment variables from `Settings`
```rust
// check-envs.rs
use <path_to_settings>::Settings;
use env_collector::{run_env_collector_cli, PrefixFilter};
use env_collector::{run_env_collector_cli, EnvCollectorSettingsBuilder, PrefixFilter};

fn main() {
run_env_collector_cli::<Settings>(
"<SERVICE_NAME_PREFIX>",
"README.md",
"<PATH TO .TOML/.JSON EXAMPLE CONFIG>",
PrefixFilter::blacklist(&["<ENV_PREFIX_TO_IGNORE>"]),
Some("some_postfix"),
EnvCollectorSettingsBuilder::default()
.service_name("<SERVICE_NAME_PREFIX>")
.markdown_path("README.md")
.config_path("<PATH TO .TOML/.JSON EXAMPLE CONFIG>")
.vars_filter(PrefixFilter::blacklist(&[
"<ENV_PREFIX_TO_IGNORE>",
"<SERVICE_NAME>__SERVER",
"<SERVICE_NAME>__JAEGER",
"<SERVICE_NAME>__METRICS",
"<SERVICE_NAME>__TRACING"
]))
.anchor_postfix(Some("some_postfix".to_string()))
.build()
.expect("failed to build env collector settings"),
);
}
```
Expand All @@ -37,24 +46,25 @@ This is a simple tool to collect possible environment variables from `Settings`
[anchor]: <> (anchors.envs.end.some_postfix)
```

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

```just
# justfile
check-envs:
cargo run --bin check-envs
check-envs *args:
cargo run --bin env-docs-generation -- --validate-only {{args}}

generate-envs *args:
cargo run --bin env-docs-generation -- {{args}}
```

5. Run command `just check-envs` to generate ENVs table in `README.md` file.
5. Run command `just generate-envs` (or `cargo run --bin env-docs-generation`) 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
- name: Verify ENVs in README
run: cargo run --bin check-envs -- --validate-only

[... other steps of `test` job ...]
```
```
1 change: 1 addition & 0 deletions libs/env-collector/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ impl Envs {
if !ignore_defaults {
entry.default_value = value.default_value;
}
entry.required = value.required;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ fn main() {
.vars_filter(PrefixFilter::blacklist(&[
"{{CRATE_NAME}}__SERVER",
"{{CRATE_NAME}}__JAEGER",
"{{CRATE_NAME}}__METRICS",
"{{CRATE_NAME}}__TRACING"
]))
.build()
.expect("failed to build env collector settings"),
Expand Down
4 changes: 2 additions & 2 deletions stats/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 stats/env-docs-generation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ version = "0.1.0"
edition = "2024"

[dependencies]
env-collector = { git = "https://github.com/blockscout/blockscout-rs", rev = "431b6bafe498d7a8b1bb1495d92a0bda7f05d006" } # latest main
env-collector = { git = "https://github.com/blockscout/blockscout-rs", rev = "1e9d3c8a06f82626525217f6c2c51c1368868cd8" } # latest almost merged PR version
stats-server = { path = "../stats-server" }
2 changes: 1 addition & 1 deletion stats/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ start-postgres-and-build-tests:
echo "finished postgres wait"

check-envs:
VALIDATE_ONLY=true cargo run --bin env-docs-generation
cargo run --bin env-docs-generation -- --validate-only

generate-envs:
cargo run --bin env-docs-generation
Expand Down
Loading
Loading