0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-07 14:55:41 +00:00

detect more CI ()

* detect more CI

* properly detect free space on windows
This commit is contained in:
Costa Tsaousis 2025-03-30 21:42:12 +03:00 committed by GitHub
parent 39339bf572
commit 60a9495f65
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 26 deletions

View file

@ -715,25 +715,39 @@ struct log_priority PRI_KILLED_HARD = { NDLP_ERR, NDLP_WARNING };
static bool is_ci(void) {
// List of known CI environment variables.
const char *ci_vars[] = {
"CI", // Generic CI flag
"TRAVIS", // Travis CI
"GITHUB_ACTIONS", // GitHub Actions
"GITLAB_CI", // GitLab CI
"CIRCLECI", // CircleCI
"APPVEYOR", // AppVeyor
"CI", // Generic CI flag
"CONTINUOUS_INTEGRATION", // Alternate generic flag
"BUILD_NUMBER", // Jenkins, TeamCity
"RUN_ID", // AWS CodeBuild, some others
"TRAVIS", // Travis CI
"GITHUB_ACTIONS", // GitHub Actions
"GITHUB_TOKEN", // GitHub Actions
"GITLAB_CI", // GitLab CI
"CIRCLECI", // CircleCI
"APPVEYOR", // AppVeyor
"BITBUCKET_BUILD_NUMBER", // Bitbucket Pipelines
"SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", // Azure DevOps
"TF_BUILD", // Azure DevOps (alternate)
"BAMBOO_BUILDKEY", // Bamboo CI
"GO_PIPELINE_NAME", // GoCD
"HUDSON_URL", // Hudson CI
"TEAMCITY_VERSION", // TeamCity
"CI_NAME", // Some environments (e.g., CodeShip)
"CI_WORKER", // AppVeyor (alternate)
"CI_SERVER", // Generic
"HEROKU_TEST_RUN_ID", // Heroku CI
"BUILDKITE", // Buildkite
"DRONE", // Drone CI
"SEMAPHORE", // Semaphore CI
"NETLIFY", // Netlify CI
"NOW_BUILDER", // Vercel (formerly Zeit Now)
NULL
};
// Iterate over the CI environment variable names.
for (const char **env = ci_vars; *env; env++) {
const char *val = getenv(*env);
if (val && *val &&
(strcasecmp(val, "true") == 0 ||
strcasecmp(val, "yes") == 0 ||
strcasecmp(val, "on") == 0 ||
strcasecmp(val, "1") == 0)) {
if(getenv(*env))
return true;
}
}
return false;
@ -990,7 +1004,7 @@ void daemon_status_file_check_crash(void) {
(!no_previous_status || daemon_status_file_saved) &&
// we have more than 2 restarts, or this is not a CI run
(last_session_status.restarts > 2 || !is_ci()) &&
(last_session_status.restarts > 1 || !is_ci()) &&
// we have not reported this
!dedup_already_posted(&session_status, daemon_status_file_hash(&last_session_status, msg, cause), false)

View file

@ -52,17 +52,12 @@ OS_SYSTEM_DISK_SPACE os_disk_space(const char *path) {
OS_SYSTEM_DISK_SPACE os_disk_space(const char *path_utf8) {
OS_SYSTEM_DISK_SPACE space = OS_SYSTEM_DISK_SPACE_EMPTY;
// Convert the UTF-8 path to a wide-character string.
int wlen = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, path_utf8, -1, NULL, 0);
if (wlen == 0) {
// Conversion error; optionally, GetLastError() can provide more details.
ssize_t wpath_size = cygwin_conv_path(CCP_POSIX_TO_WIN_W, path_utf8, NULL, 0);
if(wpath_size < 0)
return space;
}
wchar_t *wpath = (wchar_t *)mallocz(wlen * sizeof(wchar_t));
if (MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, path_utf8, -1, wpath, wlen) == 0) {
// Conversion error.
wchar_t *wpath = mallocz(wpath_size);
if(cygwin_conv_path(CCP_POSIX_TO_WIN_W, path_utf8, wpath, wpath_size) != 0) {
freez(wpath);
return space;
}

View file

@ -37,9 +37,6 @@ FILE_LOCK file_lock_get(const char *filename) {
return FILE_LOCK_INVALID;
wchar_t *wpath = mallocz(wpath_size);
if(!wpath)
return FILE_LOCK_INVALID;
if(cygwin_conv_path(CCP_POSIX_TO_WIN_W, filename, wpath, wpath_size) != 0) {
freez(wpath);
return FILE_LOCK_INVALID;