Skip to content

Commit

Permalink
Ingestion flow worked out
Browse files Browse the repository at this point in the history
  • Loading branch information
brianreicher committed Oct 10, 2023
1 parent 7b826b4 commit 8268d98
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 25 deletions.
94 changes: 80 additions & 14 deletions .github/workflows/ingestion.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Ingestion

name: API

on:
push:
branches:
Expand All @@ -8,27 +10,91 @@ on:
branches:
- main

env:
CARGO_TERM_COLOR: always
MANIFEST_PATH: --manifest-path ingestion/Cargo.toml

jobs:
build:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: ${{ env.MANIFEST_PATH }}

fmt:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt

- name: Set up JDK 11
uses: actions/setup-java@v2
- uses: actions-rs/cargo@v1
with:
java-version: 11
distribution: "temurin"
command: fmt
args: ${{ env.MANIFEST_PATH }} --all -- --check

- name: Set up Scala
uses: olafurpg/setup-scala@v13
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: ${{ env.MANIFEST_PATH }} --all-targets --all-features -- -D warnings

- name: Run Tests
working-directory: ingestion
run: sbt test
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v1
with:
key: ${{ runner.os }}-check
- uses: actions-rs/cargo@v1
with:
command: check
args: ${{ env.MANIFEST_PATH }}
env:
RUSTFLAGS: -D warnings

- name: Upload Dependency Graph
uses: scalacenter/sbt-dependency-submission@ab086b50c947c9774b70f39fc7f6e20ca2706c91
coverage:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: cargo install cargo-tarpaulin
- uses: actions-rs/cargo@v1
with:
working-directory: ingestion
command: tarpaulin
args: ${{ env.MANIFEST_PATH }} --verbose --workspace
2 changes: 1 addition & 1 deletion .metals/metals.lock.db
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#FileLock
#Mon Oct 09 15:38:57 EDT 2023
#Tue Oct 10 09:45:31 EDT 2023
hostName=localhost
id=18b15f323aa867ddcf2644b78a3028f68fadaed9c7f
method=file
Expand Down
Binary file removed .metals/metals.mv.db
Binary file not shown.
1 change: 0 additions & 1 deletion .scala-build/.bloop/project_bd2c96d2de-test.json

This file was deleted.

1 change: 0 additions & 1 deletion .scala-build/.bloop/project_bd2c96d2de.json

This file was deleted.

1 change: 0 additions & 1 deletion ingestion/src/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ impl GitHubDownloader {
pub async fn download_git_zips(
&self,
urls: Vec<&str>,
repo_name: &str,
) -> Result<(), Box<dyn Error>> {
for url in urls {
let response = self.client.get(url).send().await?;
Expand Down
17 changes: 10 additions & 7 deletions ingestion/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
use ingestion::mongo_utils::MongoDriver;
use dpw
use ingestion::downloader::GitHubDownloader;


#[tokio::main]
async fn main() -> std::io::Result<()> {
let mongo: MongoDriver = MongoDriver::new("localhost", 8080, "turbine");
mongo.connect().await?;

// create/connect if exists, and flush
mongo.create_collection("github_data").await?;
mongo.flush_collection("github_data").await?;
let collection = "github_data"
mongo.create_collection(collection).await?;
mongo.flush_collection(collection).await?;

// set remote urls and download
// set download links and ingest
let urls = vec!["https://github.com/user/repo/raw/master/file1.zip", "https://github.com/user/repo/raw/master/file2.zip"];
github_downloader.download_git_zips(urls, "my_repo").await?;


let downloader: GithubDownloader = GithubDownloader::new(mongo, collection);
downloader.download_git_zips(urls).await?;
Ok(())
}
5 changes: 5 additions & 0 deletions ingestion/tests/ingestion/ing_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#[tokio::test]
async fn mongo_connection() {

assert_eq!(Some(0), Some(0));
}
1 change: 1 addition & 0 deletions ingestion/tests/ingestion/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod ing_tests;

0 comments on commit 8268d98

Please sign in to comment.