Compare commits

..

9 Commits

Author SHA1 Message Date
Angela P Wen b5b1699bc0 Update error message with appropriate version 2022-11-10 15:59:39 -08:00
Angela P Wen e977f57489 Force npm version in PR check to be 8.19.2 2022-11-10 15:56:06 -08:00
Angela P Wen e42f82ead7 Add npm update to error message 2022-11-10 15:38:12 -08:00
Angela P Wen 259a837405 Update package-lock with latest npm version 2022-11-10 15:35:48 -08:00
Angela P Wen 9a2a2da304 Remove setup node Action 2022-11-10 15:35:32 -08:00
Angela P Wen d39a4f6fac Specify v16.18.0 2022-11-10 14:22:33 -08:00
Angela P Wen 0eee1e99c7 Add node setup step 2022-11-10 13:24:39 -08:00
Edoardo Pirovano 006bb00765 Merge pull request #1354 from github/edoardo/force-exit-on-timeout
Force exit of process if a timeout has occurred
2022-11-10 16:56:41 +00:00
Edoardo Pirovano d6f6ef4b0b Force exit of process if a timeout has occurred 2022-11-09 17:28:15 +00:00
10 changed files with 11 additions and 45 deletions
@@ -7,7 +7,7 @@ if [ ! -z "$(git status --porcelain)" ]; then
>&2 echo "Failed: Repo should be clean before testing!"
exit 1
fi
sudo npm install --force -g npm@latest
sudo npm install --force -g npm@8.19.2
# Reinstall modules and then clean to remove absolute paths
# Use 'npm ci' instead of 'npm install' as this is intended to be reproducible
npm ci
@@ -15,7 +15,7 @@ npm run removeNPMAbsolutePaths
# Check that repo is still clean
if [ ! -z "$(git status --porcelain)" ]; then
# If we get a fail here then the PR needs attention
>&2 echo "Failed: node_modules are not up to date. Run 'npm ci && npm run removeNPMAbsolutePaths' on a macOS machine to update. Note it is important this command is run on macOS and not any other operating system as there is one dependency (fsevents) that is needed for macOS and may not be installed if the command is run on a Windows or Linux machine."
>&2 echo "Failed: node_modules are not up to date. Run 'npm ci && npm run removeNPMAbsolutePaths' on a macOS machine to update and commit. Note it is important this command is run on macOS and not any other operating system as there is one dependency (fsevents) that is needed for macOS and may not be installed if the command is run on a Windows or Linux machine. If there are no changes, run 'npm install --force -g npm@8.19.2' with root permissions first."
git status
exit 1
fi
-9
View File
@@ -74,14 +74,6 @@ async function sendSuccessStatusReport(startedAt, config, toolsVersion, logger)
async function run() {
const startedAt = new Date();
const logger = (0, logging_1.getActionsLogger)();
const longTask = new Promise((resolve) => {
setTimeout(() => {
resolve();
}, 999999999);
});
await (0, util_1.withTimeout)(10, longTask, () => {
logger.info("Long task timed out");
});
(0, util_1.initializeEnvironment)(util_1.Mode.actions, pkg.version);
await (0, util_1.checkActionVersion)(pkg.version);
let config;
@@ -185,7 +177,6 @@ async function runWrapper() {
core.setFailed(`init action failed: ${error}`);
console.log(error);
}
await (0, util_1.checkForTimeout)();
}
void runWrapper();
//# sourceMappingURL=init-action.js.map
File diff suppressed because one or more lines are too long
-8
View File
@@ -71,14 +71,6 @@ exports.getTrapCachingExtractorConfigArgsForLang = getTrapCachingExtractorConfig
*/
async function downloadTrapCaches(codeql, languages, logger) {
var _a, _b;
const longTask = new Promise((resolve) => {
setTimeout(() => {
resolve();
}, 999999999);
});
await (0, util_1.withTimeout)(10, longTask, () => {
logger.info("Long task timed out");
});
const result = {};
const languagesSupportingCaching = await getLanguagesSupportingCaching(codeql, languages, logger);
logger.info(`Found ${languagesSupportingCaching.length} languages that support TRAP caching`);
File diff suppressed because one or more lines are too long
Generated
+3 -2
View File
@@ -733,7 +733,8 @@ let hadTimeout = false;
* original promise hangs, then this will prevent the process terminating.
* If a timeout has occurred then the global hadTimeout variable will get set
* to true, and the caller is responsible for forcing the process to exit
* if this is the case by calling the `checkForTimeout` function.
* if this is the case by calling the `checkForTimeout` function at the end
* of execution.
*
* @param timeoutMs The timeout in milliseconds.
* @param promise The promise to run.
@@ -753,7 +754,7 @@ async function withTimeout(timeoutMs, promise, onTimeout) {
// Workaround: While the promise racing below will allow the main code
// to continue, the process won't normally exit until the asynchronous
// task in the background has finished. We set this variable to force
// an exit at the end of our code.
// an exit at the end of our code when `checkForTimeout` is called.
hadTimeout = true;
onTimeout();
}
+1 -1
View File
File diff suppressed because one or more lines are too long
-11
View File
@@ -29,7 +29,6 @@ import { parseRepositoryNwo } from "./repository";
import { getTotalCacheSize } from "./trap-caching";
import {
checkActionVersion,
checkForTimeout,
checkGitHubVersionInRange,
codeQlVersionAbove,
DEFAULT_DEBUG_ARTIFACT_NAME,
@@ -42,7 +41,6 @@ import {
initializeEnvironment,
isHostedRunner,
Mode,
withTimeout,
} from "./util";
// eslint-disable-next-line import/no-commonjs
@@ -139,14 +137,6 @@ async function sendSuccessStatusReport(
async function run() {
const startedAt = new Date();
const logger = getActionsLogger();
const longTask = new Promise<void>((resolve) => {
setTimeout(() => {
resolve();
}, 999_999_999);
});
await withTimeout(10, longTask, () => {
logger.info("Long task timed out");
});
initializeEnvironment(Mode.actions, pkg.version);
await checkActionVersion(pkg.version);
@@ -349,7 +339,6 @@ async function runWrapper() {
core.setFailed(`init action failed: ${error}`);
console.log(error);
}
await checkForTimeout();
}
void runWrapper();
-8
View File
@@ -68,14 +68,6 @@ export async function downloadTrapCaches(
languages: Language[],
logger: Logger
): Promise<Partial<Record<Language, string>>> {
const longTask = new Promise<void>((resolve) => {
setTimeout(() => {
resolve();
}, 999_999_999);
});
await withTimeout(10, longTask, () => {
logger.info("Long task timed out");
});
const result = {};
const languagesSupportingCaching = await getLanguagesSupportingCaching(
codeql,
+3 -2
View File
@@ -872,7 +872,8 @@ let hadTimeout = false;
* original promise hangs, then this will prevent the process terminating.
* If a timeout has occurred then the global hadTimeout variable will get set
* to true, and the caller is responsible for forcing the process to exit
* if this is the case by calling the `checkForTimeout` function.
* if this is the case by calling the `checkForTimeout` function at the end
* of execution.
*
* @param timeoutMs The timeout in milliseconds.
* @param promise The promise to run.
@@ -896,7 +897,7 @@ export async function withTimeout<T>(
// Workaround: While the promise racing below will allow the main code
// to continue, the process won't normally exit until the asynchronous
// task in the background has finished. We set this variable to force
// an exit at the end of our code.
// an exit at the end of our code when `checkForTimeout` is called.
hadTimeout = true;
onTimeout();
}