Skip to content

Commit 4cf44b0

Browse files
committed
feat: Update ghastoolkit + pack installing
1 parent 1a22f94 commit 4cf44b0

File tree

4 files changed

+26
-18
lines changed

4 files changed

+26
-18
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ glob = "0.3"
2525
ghactions = { version = "^0.16", features = ["dotenvy", "log", "generate", "octocrab", "toolcache-all"] }
2626
ghactions-core = { version = "^0.16" }
2727

28-
ghastoolkit = { version = "^0.10", features = ["toolcache"] }
28+
ghastoolkit = { version = "^0.11", features = ["toolcache"] }
29+
# ghastoolkit = { path = "../ghastoolkit-rs/core/", features = ["toolcache"] }
2930

3031
# GitHub API
3132
octocrab = "^0.44"

src/action.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,19 +175,28 @@ impl Action {
175175
log::debug!("Installing pack `{pack}`");
176176

177177
let qlpack = CodeQLPack::try_from(pack.clone())?;
178-
log::info!("QLPack :: {qlpack:?}");
179178

180-
if pack.starts_with("./") {
181-
qlpack
182-
.install(codeql)
183-
.await
184-
.context(format!("Failed to install pack `{pack}`"))?;
179+
if !qlpack.is_installed().await {
180+
log::info!(
181+
"QLPack `{}` is not installed, installing it now",
182+
qlpack.full_name()
183+
);
184+
if pack.starts_with("./") {
185+
qlpack
186+
.install(codeql)
187+
.await
188+
.context(format!("Failed to install pack `{pack}`"))?;
189+
} else {
190+
codeql
191+
.pack(&qlpack)
192+
.download()
193+
.await
194+
.context(format!("Failed to download pack `{pack}`"))?;
195+
}
185196
} else {
186-
qlpack
187-
.download(codeql)
188-
.await
189-
.context(format!("Failed to download pack `{pack}`"))?;
197+
log::info!("QLPack `{}` is already installed", qlpack.full_name());
190198
}
199+
log::info!("QLPack :: {qlpack:#?}");
191200
}
192201
Ok(())
193202
}

src/main.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ use anyhow::{Context, Result};
44
use ghactions::{ActionTrait, group, groupend};
55
use ghactions_core::RepositoryReference;
66
use ghastoolkit::codeql::database::queries::CodeQLQueries;
7-
use ghastoolkit::{CodeQL, CodeQLDatabase, CodeQLExtractor};
7+
use ghastoolkit::prelude::*;
88
use log::{debug, info};
99

1010
mod action;
1111
mod extractors;
1212

13-
use action::Action;
14-
15-
use self::action::{AUTHORS, BANNER, VERSION};
13+
use action::{AUTHORS, Action, BANNER, VERSION};
1614

1715
#[tokio::main]
1816
async fn main() -> Result<()> {
@@ -100,7 +98,7 @@ async fn main() -> Result<()> {
10098
log::info!("No languages provided, using all available languages");
10199
}
102100

103-
log::info!("CodeQL :: {codeql:?}");
101+
log::info!("CodeQL :: {codeql:#?}");
104102

105103
groupend!();
106104

0 commit comments

Comments
 (0)