Skip to content

Merge main into releases/v3 #2605

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

Merged
merged 9 commits into from
Nov 14, 2024
Prev Previous commit
Next Next commit
Allow warnings in tryGetFolderBytes to be suppressed
To avoid confusing run annotations when dependency caching is enabled
  • Loading branch information
mbg committed Nov 12, 2024
commit 7bc6222c12a03ce44091a2506a776d9f02e2096a
5 changes: 3 additions & 2 deletions lib/caching-utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/caching-utils.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/dependency-caching.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/dependency-caching.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions lib/util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/util.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/caching-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ import { isHostedRunner, tryGetFolderBytes } from "./util";
* Returns the total size of all the specified paths.
* @param paths The paths for which to calculate the total size.
* @param logger A logger to record some informational messages to.
* @param quiet A value indicating whether to suppress logging warnings (default: false).
* @returns The total size of all specified paths.
*/
export async function getTotalCacheSize(
paths: string[],
logger: Logger,
quiet: boolean = false,
): Promise<number> {
const sizes = await Promise.all(
paths.map((cacheDir) => tryGetFolderBytes(cacheDir, logger)),
paths.map((cacheDir) => tryGetFolderBytes(cacheDir, logger, quiet)),
);
return sizes.map((a) => a || 0).reduce((a, b) => a + b, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/dependency-caching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export async function uploadDependencyCaches(config: Config, logger: Logger) {
// use the cache quota that we compete with. In that case, we do not wish to use up all of the quota
// with the dependency caches. For this, we could use the Cache API to check whether other workflows
// are using the quota and how full it is.
const size = await getTotalCacheSize(cacheConfig.paths, logger);
const size = await getTotalCacheSize(cacheConfig.paths, logger, true);

// Skip uploading an empty cache.
if (size === 0) {
Expand Down
9 changes: 8 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -785,16 +785,23 @@ export function listFolder(dir: string): string[] {
*
* @param cacheDir A directory to get the size of.
* @param logger A logger to log any errors to.
* @param quiet A value indicating whether to suppress warnings for errors (default: false).
* Ignored if the log level is `debug`.
* @returns The size in bytes of the folder, or undefined if errors occurred.
*/
export async function tryGetFolderBytes(
cacheDir: string,
logger: Logger,
quiet: boolean = false,
): Promise<number | undefined> {
try {
return await promisify<string, number>(getFolderSize)(cacheDir);
} catch (e) {
logger.warning(`Encountered an error while getting size of folder: ${e}`);
if (!quiet || logger.isDebug()) {
logger.warning(
`Encountered an error while getting size of '${cacheDir}': ${e}`,
);
}
return undefined;
}
}
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy