Skip to content

Commit 7af10d2

Browse files
authored
Merge pull request #856 from blockscout/ll/scoutcloud-use-env-collector
[SCOUTCLOUD] Add env-collector
2 parents 9f7dffc + 60d1760 commit 7af10d2

File tree

11 files changed

+121
-49
lines changed

11 files changed

+121
-49
lines changed

.github/workflows/scoutcloud.yml

+5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ jobs:
6161
cache-on-failure: true
6262
workspaces: scoutcloud -> target
6363

64+
- name: ENVs in doc tests
65+
run: cargo run --bin check-envs
66+
env:
67+
VALIDATE_ONLY: true
68+
6469
- name: Unit tests
6570
run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --all-features --lib --bins -- --nocapture
6671
if: success() || failure()

scoutcloud/Cargo.lock

+51-36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scoutcloud/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ members = [
66
"scoutcloud-migration",
77
"scoutcloud-proto",
88
]
9+
10+
[workspace.dependencies]
11+
blockscout-service-launcher = "0.11.1"

scoutcloud/README.md

+24-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@ Scoutcloud Service
44
Scoutcloud provides API to deploy and manage blockscout instances.
55
It tracks amount of time each instance is running and charges user for it.
66

7+
## Envs
8+
9+
[anchor]: <> (anchors.envs.start)
10+
11+
| Variable | Required | Description | Default value |
12+
|-----------------------------------------|----------|-----------------------------------------------------|----------------|
13+
| `SCOUTCLOUD__DATABASE__CONNECT__URL` | true | URL for connecting to the database. | |
14+
| `SCOUTCLOUD__GITHUB__OWNER` | true | GitHub owner or organization name. | |
15+
| `SCOUTCLOUD__GITHUB__REPO` | true | GitHub repository name. | |
16+
| `SCOUTCLOUD__GITHUB__TOKEN` | true | GitHub personal access token for authentication. | |
17+
| `SCOUTCLOUD__DATABASE__CREATE_DATABASE` | | Whether to create the database if it doesn't exist. | `false` |
18+
| `SCOUTCLOUD__DATABASE__RUN_MIGRATIONS` | | Whether to run database migrations. | `false` |
19+
| `SCOUTCLOUD__GITHUB__BRANCH` | | GitHub branch name | `main` |
20+
| `SCOUTCLOUD__METRICS__ADDR` | | Address for metrics collection. | `0.0.0.0:6060` |
21+
| `SCOUTCLOUD__METRICS__ENABLED` | | Whether metrics collection is enabled. | `false` |
22+
| `SCOUTCLOUD__METRICS__ROUTE` | | Route for metrics collection API. | `/metrics` |
23+
| `SCOUTCLOUD__TRACING__ENABLED` | | Whether tracing is enabled. | `true` |
24+
| `SCOUTCLOUD__TRACING__FORMAT` | | Format for tracing. `default`/`json` | `default` |
25+
26+
[anchor]: <> (anchors.envs.end)
27+
728
## Dev
829

930
+ Install [just](https://github.com/casey/just) cli. Just is like make but better.
@@ -21,6 +42,8 @@ just start-postgres
2142
+ Now you ready to start API server! Just run it:
2243
```bash
2344
just run
45+
# or if you want to export envs from .env file
46+
dotenv -e .env -- just run
2447
```
2548

2649
## Troubleshooting
@@ -33,4 +56,4 @@ just run
3356

3457
To fix this error you need to change tonic version of `tonic` in `blockscout-service-launcer` to `0.8`
3558

36-
For now you can only change in `Cargo.lock`
59+
For now you can only change in `Cargo.lock`

scoutcloud/justfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,5 @@ insert-test-data:
8686
insert into auth_tokens(user_id) values (1); select token_value from auth_tokens;\
8787
insert into balance_changes(user_id, amount) values (1, 100);"
8888

89-
89+
check-envs:
90+
cargo run --bin check-envs

scoutcloud/scoutcloud/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ scoutcloud-proto = { path = "../scoutcloud-proto" }
2828
scoutcloud-migration = { path = "../scoutcloud-migration" }
2929
actix-web = "4.2"
3030
async-trait = "0.1"
31-
blockscout-service-launcher = { version = "0.10.2", features = [ "database-0_12" ] }
31+
blockscout-service-launcher = { workspace = true, features = [ "database-0_12", "env-collector"] }
3232
config = "0.13"
3333
tonic = "0.8"
3434
chrono = "0.4.35"
@@ -50,11 +50,11 @@ fang = { version = "0.11.0-rc1", features = [
5050

5151

5252
[dev-dependencies]
53-
blockscout-service-launcher = { version = "0.10.2", features = [
53+
blockscout-service-launcher = { workspace = true, features = [
5454
"test-database", "database-0_12", "test-server"
5555
] }
56+
pretty_assertions = "1.3"
5657
serial_test = "3.1.1"
5758
scoutcloud-migration = {path = "../scoutcloud-migration"}
58-
pretty_assertions = "1.3"
5959
reqwest = { version = "0.11", features = ["json"]}
6060

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[database.connect]
2+
url = "postgres://postgres:postgres@localhost:5432/postgres"
3+
4+
[github]
5+
token = "your_github_token"
6+
owner = "blockscout"
7+
repo = "autodeploy"
8+
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use blockscout_service_launcher::env_collector::run_env_collector_cli;
2+
use scoutcloud::server::Settings;
3+
4+
fn main() {
5+
run_env_collector_cli::<Settings>(
6+
"SCOUTCLOUD",
7+
"README.md",
8+
"scoutcloud/config/example.toml",
9+
&["SCOUTCLOUD__SERVER", "SCOUTCLOUD__JAEGER"],
10+
);
11+
}

scoutcloud/scoutcloud/src/bin/github-test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ async fn main() -> Result<(), anyhow::Error> {
88
settings.github.token,
99
settings.github.owner,
1010
settings.github.repo,
11-
Some("main".to_string()),
11+
"main".to_string(),
1212
None,
1313
)?;
1414

0 commit comments

Comments
 (0)