Skip to content

Commit 13399b4

Browse files
committed
feat: Add logging for extractor archive size and improve CodeQL installation error handling
1 parent c7bed12 commit 13399b4

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,7 @@ RUN apt-get update && \
3131
apt-get clean && \
3232
rm -rf /var/lib/apt/lists/*
3333

34+
# Install the CodeQL extension for GitHub CLI
35+
RUN gh extensions install github/gh-codeql
36+
3437
ENTRYPOINT [ "codeql-extractor-action" ]

src/extractors.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ pub async fn fetch_extractor(
8686
}
8787
};
8888

89+
// Get and log the size of the extractor archive
90+
if let Ok(metadata) = std::fs::metadata(&extractor_archive) {
91+
let size_bytes = metadata.len();
92+
let size_mb = size_bytes as f64 / 1_048_576.0; // Convert to MB (1 MB = 1,048,576 bytes)
93+
log::info!("Extractor archive size: {:.2} MB ({} bytes)", size_mb, size_bytes);
94+
} else {
95+
log::warn!("Unable to get size information for the extractor archive");
96+
}
97+
8998
if attest {
9099
log::info!("Attesting asset {extractor_tarball:?}");
91100

src/main.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,18 @@ async fn main() -> Result<()> {
4141
if !codeql.is_installed().await {
4242
let codeql_version = action.codeql_version();
4343
log::info!("CodeQL not installed, installing `{codeql_version}`...");
44-
codeql
45-
.install(&octocrab, codeql_version)
46-
.await
47-
.context("Failed to install CodeQL")?;
44+
45+
if let Err(error) = codeql.install(&octocrab, codeql_version).await {
46+
log::warn!("Failed to install CodeQL: {error:?}");
47+
log::info!("Attempting to install CodeQL using GitHub CLI...");
48+
49+
tokio::process::Command::new("gh")
50+
.args(&["codeql", "set-version", codeql_version.into()])
51+
.status()
52+
.await
53+
.context("Failed to execute `gh codeql install` command")?;
54+
}
55+
4856
log::info!("CodeQL installed");
4957
} else {
5058
log::info!("CodeQL already installed");

0 commit comments

Comments
 (0)