Skip to content

Commit

Permalink
updated crawler
Browse files Browse the repository at this point in the history
  • Loading branch information
mario-eth committed Sep 16, 2023
1 parent d579c0d commit 7aeb9c5
Show file tree
Hide file tree
Showing 13 changed files with 251 additions and 20 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ crawler/target/
*.DS_Store*
package-lock.json
package.json
repositories.db
repositories.db
crawler/node_modules/
crawler/zipped/*
crawler/zipped/
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"rust-analyzer.linkedProjects": [
"./crawler/Cargo.toml"
]
],
"git.ignoreLimitWarning": true
}
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "soldeer"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
authors = ["m4rio"]
license = "MIT"
Expand Down
1 change: 1 addition & 0 deletions crawler/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.gitattributes
148 changes: 147 additions & 1 deletion crawler/Cargo.lock

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

3 changes: 2 additions & 1 deletion crawler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ serde_derive = "1.0.171"
serde_json = "1.0.1"
toml = "0.7.6"
zip = "0.6.6"
walkdir = "2.3.3"
walkdir = "2.3.3"
git2 = "0.17.2"
4 changes: 4 additions & 0 deletions crawler/npm_repositories.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@
"@prb/contracts",
"@prb/proxy",
"@prb/test",
"@gelatonetwork/relay-context",
"@axelar-network/axelar-cgp-solidity",
"@axelar-network/axelar-gmp-sdk-solidity",
"@axelar-network/interchain-token-service",
]
36 changes: 36 additions & 0 deletions crawler/push_to_git.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

remote_url="[email protected]:mario-eth/soldeer.git"
git_name="Soldeer CI"
git_email="[email protected]"


if [ -z "$1" ]; then
echo "Please provide a commit message as an argument."
exit 1
fi

if [ -z "$2" ]; then
echo "Please provide a key"
exit 1
fi


# Start ssh-agent and add your key
eval $(ssh-agent)
ssh-add "$2"

cd zipped && \
git lfs track "*.zip" && \
git init && \
(git remote get-url origin > /dev/null 2>&1 || git remote add origin "$remote_url") && \
git fetch origin && \
git config user.name "$git_name" && \
git config user.email "$git_email" && \
git checkout versions && \
git add . && \
git commit -m "$1" && \
git push -u origin versions

# Kill the ssh-agent after use
ssh-agent -k
22 changes: 15 additions & 7 deletions crawler/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use npm::LoadError;
use db::{ get_versions_for_repo_from_db, insert_version_into_db, Version };
use rusqlite::Error;
use chrono::Utc;
use manager::{ zip_version, push_to_repository };
use manager::{ zip_version, push_to_repository, clean };
fn main() {
let repositories: Vec<String> = load_repositories()
.map_err(|err: LoadError| {
Expand All @@ -28,16 +28,23 @@ fn main() {
})
.unwrap();

let mut index: usize = 0;
let versions_len: usize = versions.len();
for version in versions {
index = index + 1;
if existing_versions.contains(&version) {
continue;
}
retrieve_version(&repository, &version)
.map_err(|err| {
println!("{:?}", err);
})
.unwrap();
let version_to_insert = Version {
match retrieve_version(&repository, &version) {
Ok(_) => {}
Err(_) => {
if versions_len == index {
clean();
}
continue;
}
}
let version_to_insert: Version = Version {
repository: repository.clone(),
version: version.clone(),
last_updated: Utc::now(),
Expand All @@ -51,6 +58,7 @@ fn main() {
println!("{:?}", err);
})
.unwrap();
clean();
}
}
}
Loading

0 comments on commit 7aeb9c5

Please sign in to comment.