Skip to content

Commit ef1979f

Browse files
committed
refactor: Improve logging and update extractor path handling
1 parent f24de29 commit ef1979f

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/extractors.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ use std::{os::unix::fs::PermissionsExt, path::PathBuf};
66

77
async fn fetch_releases(client: &octocrab::Octocrab, repository: &Repository) -> Result<Release> {
88
let release = if let Some(rel) = &repository.reference {
9+
log::info!("Fetching release by tag: {}", rel);
910
client
1011
.repos(repository.owner.clone(), repository.name.clone())
1112
.releases()
1213
.get_by_tag(&rel)
1314
.await?
1415
} else {
16+
log::info!("Fetching latest release",);
1517
// Get Latest Release
1618
client
1719
.repos(repository.owner.clone(), repository.name.clone())
@@ -20,7 +22,7 @@ async fn fetch_releases(client: &octocrab::Octocrab, repository: &Repository) ->
2022
.await?
2123
};
2224

23-
log::debug!("Release :: {} - {:?}", release.tag_name, release.created_at);
25+
log::info!("Release :: {} - {:?}", release.tag_name, release.created_at);
2426

2527
Ok(release)
2628
}

src/main.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ async fn main() -> Result<()> {
1818

1919
debug!("Action :: {action:?}");
2020

21-
let client = action.octocrab()?;
21+
// Use a client without a token to not use Action' token which will fail
22+
// as the token won't have access to the CodeQL repository.
23+
let octocrab = action.octocrab_without_token()?;
2224

2325
let cwd = action
2426
.working_directory()
@@ -37,10 +39,6 @@ async fn main() -> Result<()> {
3739
log::debug!("CodeQL :: {codeql:?}");
3840

3941
if !codeql.is_installed().await {
40-
// Use a client without a token to not use Action' token which will fail
41-
// as the token won't have access to the CodeQL repository.
42-
let octocrab = action.octocrab_without_token()?;
43-
4442
let codeql_version = action.codeql_version();
4543
log::info!("CodeQL not installed, installing `{codeql_version}`...");
4644
codeql
@@ -62,18 +60,24 @@ async fn main() -> Result<()> {
6260
.extractor_repository()
6361
.context("Failed to get extractor repository")?;
6462

65-
let extractor_path = cwd.join(".codeql").join("extractors");
63+
let extractor_path = codeql_dir.join("extractors");
6664
if !extractor_path.exists() {
67-
std::fs::create_dir(&extractor_path)
65+
std::fs::create_dir_all(&extractor_path)
6866
.with_context(|| format!("Failed to create directory {extractor_path:?}"))?;
6967
info!("Created Extractor Directory :: {extractor_path:?}");
7068
}
7169

7270
let mut extractors: Vec<(CodeQLExtractor, RepositoryReference)> = Vec::new();
7371

7472
for extractor_repo in extractor_repos.iter() {
73+
log::info!(
74+
"Fetching extractor from repository: {} / {}",
75+
extractor_repo.owner,
76+
extractor_repo.name
77+
);
78+
7579
let extractor_path = extractors::fetch_extractor(
76-
&client,
80+
&octocrab,
7781
extractor_repo,
7882
action.attestation(),
7983
&extractor_path,

0 commit comments

Comments
 (0)