Skip to content

Commit

Permalink
deploy pg service for Rust CI
Browse files Browse the repository at this point in the history
Signed-off-by: zenghua <[email protected]>
  • Loading branch information
zenghua committed Oct 31, 2023
1 parent f74abd0 commit 2f2d60f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,27 @@ env:
jobs:
rust_ci:
runs-on: ubuntu-latest
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:14.5
# Provide the password for postgres
env:
POSTGRES_PASSWORD: lakesoul_test
POSTGRES_USER: lakesoul_test
POSTGRES_DB: lakesoul_test
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--name lakesoul-test-pg
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432

steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
Expand Down
6 changes: 3 additions & 3 deletions rust/lakesoul-metadata/src/metadata_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ impl MetaDataClient {
let config_map = config.split('\n').filter_map(|property| {
property.find('=').map(|idx| property.split_at(idx + 1))
}).collect::<HashMap<_, _>>();
let url = Url::parse(&config_map.get("lakesoul.pg.url=").expect("")[5..]).unwrap();
let url = Url::parse(&config_map.get("lakesoul.pg.url=").unwrap_or("jdbc:postgresql://127.0.0.1:5432/lakesoul_test?stringtype=unspecified")[5..]).unwrap();
Self::from_config(
format!(
"host={} port={} dbname={} user={} password={}",
url.host_str().unwrap(),
url.port().unwrap(),
url.path_segments().unwrap().next().unwrap(),
config_map.get("lakesoul.pg.username=").unwrap(),
config_map.get("lakesoul.pg.password=").unwrap())
config_map.get("lakesoul.pg.username=").unwrap_or("lakesoul_test"),
config_map.get("lakesoul.pg.password=").unwrap_or("lakesoul_test"))
)
}

Expand Down

0 comments on commit 2f2d60f

Please sign in to comment.