Skip to content

Commit

Permalink
test gha: add in hygiene job to check default cli version on major bu…
Browse files Browse the repository at this point in the history
…mp, on master push
  • Loading branch information
rjbou committed Mar 15, 2021
1 parent 68cddd7 commit 15ee685
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .github/scripts/hygiene.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,21 @@ fi
cd ..
(set +x ; echo -en "::endgroup::check src_ext patches\r") 2>/dev/null

###
# Default cli version check
###

if [ "$GITHUB_EVENT_NAME" = "push" ] && [ "${GITHUB_REF##*/}" = "master" ]; then
(set +x ; echo -en "::group::check default cli\r") 2>/dev/null
CURRENT_MAJOR="`sed -n "s/^AC_INIT(opam,\([0-9]\+\)[^0-9]*.*)$/\1/p" configure.ac`"
DEFAULT_CLI_MAJOR="`sed -n "/let *default *=/s/.*(\([0-9]*\)[^0-9]*.*/\1/p" src/client/opamCLIVersion.ml`"
if [ $CURRENT_MAJOR -eq $DEFAULT_CLI_MAJOR ]; then
echo "Major viersion is default cli one: $CURRENT_MAJOR"
else
echo -e "[\e[31mERROR\e[0m] Major version $CURRENT_MAJOR and default cli version $DEFAULT_CLI_MAJOR mismatches"
(set +x ; echo -en "::endgroup::check default cli\r") 2>/dev/null
ERROR=1
fi
fi

exit $ERROR
3 changes: 3 additions & 0 deletions src/client/opamCLIVersion.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ let of_string s =
| _ -> failwith "OpamVersion.CLI.of_string"

let current = of_string @@ OpamVersion.(to_string current_nopatch)

(* This line is checked on CI to ensure that default cli version
matches release opam version *)
let default = (2,0)

let of_string_opt s = try Some (of_string s) with Failure _ -> None
Expand Down
3 changes: 2 additions & 1 deletion src/client/opamCLIVersion.mli
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ include OpamStd.ABSTRACT
(** The current version of the CLI (major and minor of OpamVersion.current *)
val current : t

(* Default CLI version, currently 2.0 *)
(* Default CLI version, currently 2.0.
This value is checked in CI. *)
val default : t

(** Tests whether a valid CLI version is supported by the client library *)
Expand Down

0 comments on commit 15ee685

Please # to comment.