Warn when the workdir is empty (#322)

Closes: #306
This commit is contained in:
Kevin Stillhammer 2025-03-16 22:15:17 +01:00 committed by GitHub
parent 0e855c90d0
commit a05a582c56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 57 additions and 2 deletions

View file

@ -16,6 +16,7 @@ import {
import {
cacheLocalPath,
checkSum,
ignoreEmptyWorkdir,
enableCache,
githubToken,
pyProjectFile,
@ -30,6 +31,7 @@ import fs from "node:fs";
import { getUvVersionFromConfigFile } from "./utils/pyproject";
async function run(): Promise<void> {
detectEmptyWorkdir();
const platform = await getPlatform();
const arch = getArch();
@ -61,6 +63,20 @@ async function run(): Promise<void> {
}
}
function detectEmptyWorkdir(): void {
if (fs.readdirSync(".").length === 0) {
if (ignoreEmptyWorkdir) {
core.info(
"Empty workdir detected. Ignoring because ignore-empty-workdir is enabled",
);
} else {
core.warning(
"Empty workdir detected. This may cause unexpected behavior. You can enable ignore-empty-workdir to mute this warning.",
);
}
}
}
async function setupUv(
platform: Platform,
arch: Architecture,

View file

@ -13,6 +13,8 @@ export const cacheDependencyGlob = core.getInput("cache-dependency-glob");
export const pruneCache = core.getInput("prune-cache") === "true";
export const ignoreNothingToCache =
core.getInput("ignore-nothing-to-cache") === "true";
export const ignoreEmptyWorkdir =
core.getInput("ignore-empty-workdir") === "true";
export const toolBinDir = getToolBinDir();
export const toolDir = getToolDir();
export const githubToken = core.getInput("github-token");