flux-framework / flux-sched

Fluxion Graph-based Scheduler
GNU Lesser General Public License v3.0
90 stars 41 forks source link

build: add descriptive warning about version #1294

Closed wihobbs closed 2 months ago

wihobbs commented 2 months ago

Problem: flux-sched's version comes from git describe, which is passed to CMake. CMake validates versions using a regex in CMake/Source/cmProjectCommand.cxx. When this is an invalid version, flux-sched can't build. This often happens in CI, forks, or stripped-down user environments, and often happens to new contributors.

Solution: Validate the version before passing to CMake. If the version is invalid, throw a descriptive warning with some suggestions.

Fixes #1291

This might be a little over-engineered, and suggestions about how to format the message are welcome.

trws commented 2 months ago

It works for me, there are two other options to set it:

  1. -DFLUX_SCHED_VER=<ver> as a cmake argument
  2. FLUX_SCHED_VERSION=<ver> as an env var

in case you'd like to include those.

wihobbs commented 2 months ago

Put it at the top, since IMO that's the easiest way to fix it. New message:

(s=125,d=0)  corona212 ~/flux-sched (cmake-ver-err)$ FLUX_SCHED_VERSION=junk cmake -B build
-- VER junk
CMake Warning at CMakeLists.txt:21 (message):
  CMake may generate an error that says "VERSION "junk" format invalid."

  If this happens, try the following:

      1. Set the variable manually, with `cmake -DFLUX_SCHED_VER=<version> ...`
         or FLUX_SCHED_VERSION=<version> in your environment.
      2. If you are running in a CI environment, run `git fetch tags`
         before building. Versions in flux-sched are derived from
         `git describe` which uses the most recent tag.
      3. If you are running in a fork of the main repository, try
         `git push --tags` to make sure tags are synchronized in
         your fork.
      4. If you are running outside of a repo (such as in a buildfarm),
         add a file to the source directory called flux-sched.ver and
         place a valid version string in that file.

CMake Error at CMakeLists.txt:37 (project):
  VERSION "junk" format invalid.

-- Configuring incomplete, errors occurred!
See also "/g/g0/hobbs17/flux-sched/build/CMakeFiles/CMakeOutput.log".
wihobbs commented 2 months ago

Oh, grr, git fetch tags needs to be git fetch --tags

trws commented 2 months ago

Looks good to me! Are you doing a similar one on core?

wihobbs commented 2 months ago

@trws Sure am, made it easier once I realized the configure.ac is really just a shell script with a different suffix.

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 75.3%. Comparing base (8d8941d) to head (1bcb014). Report is 2 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1294 +/- ## ====================================== Coverage 75.3% 75.3% ====================================== Files 110 110 Lines 15236 15236 ====================================== Hits 11486 11486 Misses 3750 3750 ```