Skip to content

Commit

Permalink
ci: validate crate versions
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardosm committed Apr 17, 2024
1 parent 5a61235 commit cb2fdc8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
41 changes: 35 additions & 6 deletions ci/lint-aux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,41 @@ set -euo pipefail

. ci/utils.sh

crates=(
rsjsonnet-lang
rsjsonnet-front
rsjsonnet
)

begin_group "Check crate versions"

expected_version="$(crate_version rsjsonnet)"
for crate in "${crates[@]}"; do
version="$(crate_version "$crate")"

if [[ ! "$version" =~ ^[0-9].[0-9].[0-9](-pre)?$ ]]; then
echo "Invalid version for $crate"
exit 1
fi

if [[ "$version" = *-pre ]]; then
publish_ok="$(crate_metadata "$crate" | jq '.publish == []')"
else
publish_ok="$(crate_metadata "$crate" | jq '.publish == null')"
fi
if ! "$publish_ok"; then
echo "Invalid publish for $crate"
exit 1
fi

if [ "$version" != "$expected_version" ]; then
echo "Incorrect version for $crate"
exit 1
fi
done

end_group

begin_group "Check MSRV consistency"

msrv="$(cat ci/rust-versions/msrv.txt)"
Expand All @@ -22,12 +57,6 @@ for readme in "${msrv_readmes[@]}"; do
fi
done

crates=(
rsjsonnet-lang
rsjsonnet-front
rsjsonnet
)

for crate in "${crates[@]}"; do
if [ "$(crate_metadata "$crate" | jq -r '.rust_version')" != "$msrv" ]; then
echo "Incorrect rust-version for $crate"
Expand Down
9 changes: 9 additions & 0 deletions ci/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,12 @@ crate_metadata() {
end
"
}

crate_version() {
if [ $# -ne 1 ]; then
echo_stderr "Invalid use of $0"
exit 1
fi
crate="$1"
crate_metadata "$crate" | jq -r '.version'
}

0 comments on commit cb2fdc8

Please sign in to comment.