Skip to content

Commit

Permalink
Merge pull request #856 from blockscout/ll/scoutcloud-use-env-collector
Browse files Browse the repository at this point in the history
[SCOUTCLOUD] Add env-collector
  • Loading branch information
sevenzing authored May 8, 2024
2 parents 9f7dffc + 60d1760 commit 7af10d2
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 49 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/scoutcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ jobs:
cache-on-failure: true
workspaces: scoutcloud -> target

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

- name: Unit tests
run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --all-features --lib --bins -- --nocapture
if: success() || failure()
Expand Down
87 changes: 51 additions & 36 deletions scoutcloud/Cargo.lock

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

3 changes: 3 additions & 0 deletions scoutcloud/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ members = [
"scoutcloud-migration",
"scoutcloud-proto",
]

[workspace.dependencies]
blockscout-service-launcher = "0.11.1"
25 changes: 24 additions & 1 deletion scoutcloud/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ Scoutcloud Service
Scoutcloud provides API to deploy and manage blockscout instances.
It tracks amount of time each instance is running and charges user for it.

## Envs

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

| Variable | Required | Description | Default value |
|-----------------------------------------|----------|-----------------------------------------------------|----------------|
| `SCOUTCLOUD__DATABASE__CONNECT__URL` | true | URL for connecting to the database. | |
| `SCOUTCLOUD__GITHUB__OWNER` | true | GitHub owner or organization name. | |
| `SCOUTCLOUD__GITHUB__REPO` | true | GitHub repository name. | |
| `SCOUTCLOUD__GITHUB__TOKEN` | true | GitHub personal access token for authentication. | |
| `SCOUTCLOUD__DATABASE__CREATE_DATABASE` | | Whether to create the database if it doesn't exist. | `false` |
| `SCOUTCLOUD__DATABASE__RUN_MIGRATIONS` | | Whether to run database migrations. | `false` |
| `SCOUTCLOUD__GITHUB__BRANCH` | | GitHub branch name | `main` |
| `SCOUTCLOUD__METRICS__ADDR` | | Address for metrics collection. | `0.0.0.0:6060` |
| `SCOUTCLOUD__METRICS__ENABLED` | | Whether metrics collection is enabled. | `false` |
| `SCOUTCLOUD__METRICS__ROUTE` | | Route for metrics collection API. | `/metrics` |
| `SCOUTCLOUD__TRACING__ENABLED` | | Whether tracing is enabled. | `true` |
| `SCOUTCLOUD__TRACING__FORMAT` | | Format for tracing. `default`/`json` | `default` |

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

## Dev

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

## Troubleshooting
Expand All @@ -33,4 +56,4 @@ just run

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

For now you can only change in `Cargo.lock`
For now you can only change in `Cargo.lock`
3 changes: 2 additions & 1 deletion scoutcloud/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ insert-test-data:
insert into auth_tokens(user_id) values (1); select token_value from auth_tokens;\
insert into balance_changes(user_id, amount) values (1, 100);"


check-envs:
cargo run --bin check-envs
6 changes: 3 additions & 3 deletions scoutcloud/scoutcloud/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ scoutcloud-proto = { path = "../scoutcloud-proto" }
scoutcloud-migration = { path = "../scoutcloud-migration" }
actix-web = "4.2"
async-trait = "0.1"
blockscout-service-launcher = { version = "0.10.2", features = [ "database-0_12" ] }
blockscout-service-launcher = { workspace = true, features = [ "database-0_12", "env-collector"] }
config = "0.13"
tonic = "0.8"
chrono = "0.4.35"
Expand All @@ -50,11 +50,11 @@ fang = { version = "0.11.0-rc1", features = [


[dev-dependencies]
blockscout-service-launcher = { version = "0.10.2", features = [
blockscout-service-launcher = { workspace = true, features = [
"test-database", "database-0_12", "test-server"
] }
pretty_assertions = "1.3"
serial_test = "3.1.1"
scoutcloud-migration = {path = "../scoutcloud-migration"}
pretty_assertions = "1.3"
reqwest = { version = "0.11", features = ["json"]}

9 changes: 9 additions & 0 deletions scoutcloud/scoutcloud/config/example.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[database.connect]
url = "postgres://postgres:postgres@localhost:5432/postgres"

[github]
token = "your_github_token"
owner = "blockscout"
repo = "autodeploy"


11 changes: 11 additions & 0 deletions scoutcloud/scoutcloud/src/bin/check-envs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use blockscout_service_launcher::env_collector::run_env_collector_cli;
use scoutcloud::server::Settings;

fn main() {
run_env_collector_cli::<Settings>(
"SCOUTCLOUD",
"README.md",
"scoutcloud/config/example.toml",
&["SCOUTCLOUD__SERVER", "SCOUTCLOUD__JAEGER"],
);
}
2 changes: 1 addition & 1 deletion scoutcloud/scoutcloud/src/bin/github-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ async fn main() -> Result<(), anyhow::Error> {
settings.github.token,
settings.github.owner,
settings.github.repo,
Some("main".to_string()),
"main".to_string(),
None,
)?;

Expand Down
Loading

0 comments on commit 7af10d2

Please sign in to comment.