Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix output issue #34

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/common/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ export function getPidFilePath(): string {
}

export function getOutputDir(): string {
return WORKSPACE
? path.join(WORKSPACE, RESULTS_DIR_NAME)
: path.join(__dirname, "..", "..", RESULTS_DIR_NAME);
return WORKSPACE || process.cwd();
}

export function mockCoreForLocalTesting(): void {
Expand Down
2 changes: 0 additions & 2 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ async function runKnoxctlScan(): Promise<void> {
const scanCommand: string[] = ["knoxctl", "scan"];
const outputDir = path.join(getOutputDir(), "knoxctl-results");

scanCommand.push("--output", outputDir);

for (const option of knoxctlOptions) {
let value: boolean | string;

Expand Down
13 changes: 11 additions & 2 deletions src/post/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,19 @@ async function run(): Promise<void> {

// Increase wait time and add file system sync
await new Promise((resolve) => setTimeout(resolve, 15000));
fs.readdirSync(getOutputDir()); // Force a file system sync

const outputDir = getOutputDir();
log(`Output directory: ${outputDir}`);
log("Contents of output directory:");
const files = fs.readdirSync(outputDir);
for (const file of files) {
if (file.startsWith("knoxctl_scan_")) {
log(`- ${file}`);
}
}

await processResults();

const outputDir = getOutputDir();
await uploadArtifacts(outputDir);

if (IS_GITHUB_ACTIONS) {
Expand All @@ -241,6 +249,7 @@ async function uploadArtifacts(outputDir: string): Promise<void> {
const artifactName = "knoxctl-scan-results";
const files = fs
.readdirSync(outputDir)
.filter((file) => file.startsWith("knoxctl_scan_"))
.map((file) => path.join(outputDir, file));

log(`Uploading ${files.length} files as artifacts`);
Expand Down
Loading