Skip to content

Commit c4d23d1

Browse files
committed
Actions: dont fail if no JS/TS code was found
1 parent a1a9626 commit c4d23d1

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,13 +489,15 @@ public int run() throws IOException {
489489
diagnosticsToClose.forEach(DiagnosticWriter::close);
490490
}
491491

492-
if (!hasSeenCode()) {
492+
// Fail extraction is no relevant files were found.
493+
if (!seenFiles || !hasSeenCode() && !EnvironmentVariables.isActionsExtractor()) {
493494
if (seenFiles) {
494495
warn("Only found JavaScript or TypeScript files that were empty or contained syntax errors.");
495496
} else {
496497
warn("No JavaScript or TypeScript code found.");
497498
}
498-
// ensuring that the finalize steps detects that no code was seen.
499+
// Ensuring that the finalize steps detects that no code was seen.
500+
// This is necessary to ensure we don't produce an overlay-base database without externs.
499501
Path srcFolder = Paths.get(EnvironmentVariables.getWipDatabase(), "src");
500502
try {
501503
FileUtil8.recursiveDelete(srcFolder);

javascript/extractor/src/com/semmle/js/extractor/EnvironmentVariables.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ public class EnvironmentVariables {
1818
public static final String CODEQL_EXTRACTOR_JAVASCRIPT_WIP_DATABASE_ENV_VAR =
1919
"CODEQL_EXTRACTOR_JAVASCRIPT_WIP_DATABASE";
2020

21+
public static final String CODEQL_EXTRACTOR_ACTIONS_WIP_DATABASE_ENV_VAR =
22+
"CODEQL_EXTRACTOR_ACTIONS_WIP_DATABASE";
23+
2124
public static final String CODEQL_DIST_ENV_VAR = "CODEQL_DIST";
2225

2326
/**
@@ -94,4 +97,8 @@ public static String getCodeQLDist() {
9497
public static String getWipDatabase() {
9598
return Env.systemEnv().getNonEmpty(CODEQL_EXTRACTOR_JAVASCRIPT_WIP_DATABASE_ENV_VAR);
9699
}
100+
101+
public static boolean isActionsExtractor() {
102+
return Env.systemEnv().getNonEmpty(CODEQL_EXTRACTOR_ACTIONS_WIP_DATABASE_ENV_VAR) != null;
103+
}
97104
}

0 commit comments

Comments
 (0)