@cryptotaxi247 / netdata-1 / commits / 60a9495f6

detect more CI (#19999)

* detect more CI * properly detect free space on windows

Costa Tsaousis committed Mar 30, 2025 at 21:42 UTC 60a9495f65600cafafece05ee1903a12702cf510
3 files changed +32 -26
src/daemon/status-file.c
+28 -14
@@ -715,25 +715,39 @@ struct log_priority PRI_KILLED_HARD = { NDLP_ERR, NDLP_WARNING };
715 static bool is_ci(void) {
716 // List of known CI environment variables.
717 const char *ci_vars[] = {
718 - "CI", // Generic CI flag
719 - "TRAVIS", // Travis CI
720 - "GITHUB_ACTIONS", // GitHub Actions
721 - "GITLAB_CI", // GitLab CI
722 - "CIRCLECI", // CircleCI
723 - "APPVEYOR", // AppVeyor
718 + "CI", // Generic CI flag
719 + "CONTINUOUS_INTEGRATION", // Alternate generic flag
720 + "BUILD_NUMBER", // Jenkins, TeamCity
721 + "RUN_ID", // AWS CodeBuild, some others
722 + "TRAVIS", // Travis CI
723 + "GITHUB_ACTIONS", // GitHub Actions
724 + "GITHUB_TOKEN", // GitHub Actions
725 + "GITLAB_CI", // GitLab CI
726 + "CIRCLECI", // CircleCI
727 + "APPVEYOR", // AppVeyor
728 + "BITBUCKET_BUILD_NUMBER", // Bitbucket Pipelines
729 + "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", // Azure DevOps
730 + "TF_BUILD", // Azure DevOps (alternate)
731 + "BAMBOO_BUILDKEY", // Bamboo CI
732 + "GO_PIPELINE_NAME", // GoCD
733 + "HUDSON_URL", // Hudson CI
734 + "TEAMCITY_VERSION", // TeamCity
735 + "CI_NAME", // Some environments (e.g., CodeShip)
736 + "CI_WORKER", // AppVeyor (alternate)
737 + "CI_SERVER", // Generic
738 + "HEROKU_TEST_RUN_ID", // Heroku CI
739 + "BUILDKITE", // Buildkite
740 + "DRONE", // Drone CI
741 + "SEMAPHORE", // Semaphore CI
742 + "NETLIFY", // Netlify CI
743 + "NOW_BUILDER", // Vercel (formerly Zeit Now)
744 NULL
745 };
746
747 // Iterate over the CI environment variable names.
748 for (const char **env = ci_vars; *env; env++) {
729 - const char *val = getenv(*env);
730 - if (val && *val &&
731 - (strcasecmp(val, "true") == 0 ||
732 - strcasecmp(val, "yes") == 0 ||
733 - strcasecmp(val, "on") == 0 ||
734 - strcasecmp(val, "1") == 0)) {
749 + if(getenv(*env))
750 return true;
736 - }
751 }
752
753 return false;
@@ -990,7 +1004,7 @@ void daemon_status_file_check_crash(void) {
1004 (!no_previous_status || daemon_status_file_saved) &&
1005
1006 // we have more than 2 restarts, or this is not a CI run
993 - (last_session_status.restarts > 2 || !is_ci()) &&
1007 + (last_session_status.restarts > 1 || !is_ci()) &&
1008
1009 // we have not reported this
1010 !dedup_already_posted(&session_status, daemon_status_file_hash(&last_session_status, msg, cause), false)
src/libnetdata/os/disk_space.c
+4 -9
@@ -52,17 +52,12 @@ OS_SYSTEM_DISK_SPACE os_disk_space(const char *path) {
52 OS_SYSTEM_DISK_SPACE os_disk_space(const char *path_utf8) {
53 OS_SYSTEM_DISK_SPACE space = OS_SYSTEM_DISK_SPACE_EMPTY;
54
55 - // Convert the UTF-8 path to a wide-character string.
56 - int wlen = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, path_utf8, -1, NULL, 0);
57 - if (wlen == 0) {
58 - // Conversion error; optionally, GetLastError() can provide more details.
55 + ssize_t wpath_size = cygwin_conv_path(CCP_POSIX_TO_WIN_W, path_utf8, NULL, 0);
56 + if(wpath_size < 0)
57 return space;
60 - }
61 -
62 - wchar_t *wpath = (wchar_t *)mallocz(wlen * sizeof(wchar_t));
58
64 - if (MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, path_utf8, -1, wpath, wlen) == 0) {
65 - // Conversion error.
59 + wchar_t *wpath = mallocz(wpath_size);
60 + if(cygwin_conv_path(CCP_POSIX_TO_WIN_W, path_utf8, wpath, wpath_size) != 0) {
61 freez(wpath);
62 return space;
63 }
src/libnetdata/os/file_lock.c
-3
@@ -37,9 +37,6 @@ FILE_LOCK file_lock_get(const char *filename) {
37 return FILE_LOCK_INVALID;
38
39 wchar_t *wpath = mallocz(wpath_size);
40 - if(!wpath)
41 - return FILE_LOCK_INVALID;
42 -
40 if(cygwin_conv_path(CCP_POSIX_TO_WIN_W, filename, wpath, wpath_size) != 0) {
41 freez(wpath);
42 return FILE_LOCK_INVALID;