-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlint-aux.sh
executable file
·93 lines (75 loc) · 2.25 KB
/
lint-aux.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env bash
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" != "true" ]; then
echo "Invalid publish for $crate"
exit 1
fi
if [ "$version" != "$expected_version" ]; then
echo "Incorrect version for $crate"
exit 1
fi
done
version="$(crate_version "rsjsonnet")"
changelog_date="$(awk -v ver="${version%-pre}" '/^## / { if ($2 == ver) print $3 }' CHANGELOG.md)"
if [[ "$version" = *-pre ]]; then
if [ "$changelog_date" != "(unreleased)" ]; then
echo "Invalid date in changelog for version $version"
exit 1
fi
else
if [[ ! "$changelog_date" =~ \([0-9]{4}-[0-9]{2}-[0-9]{2}\) ]]; then
echo "Invalid date in changelog for version $version"
exit 1
fi
fi
end_group
begin_group "Check MSRV consistency"
msrv="$(cat ci/rust-versions/msrv.txt)"
msrv="${msrv%.*}"
msrv_readmes=(
README.md
rsjsonnet/README.md
rsjsonnet-front/README.md
rsjsonnet-lang/README.md
)
for readme in "${msrv_readmes[@]}"; do
if [[ "$(grep img.shields.io/badge/rustc "$readme")" != *"rustc-$msrv+-lightgray.svg"* ]]; then
echo "Incorrect MSRV in $readme"
exit 1
fi
done
for crate in "${crates[@]}"; do
if [ "$(crate_metadata "$crate" | jq -r '.rust_version')" != "$msrv" ]; then
echo "Incorrect rust-version for $crate"
exit 1
fi
done
end_group
begin_group "Check shell scripts with shellcheck"
find . -type f -name "*.sh" -not -path "./.git/*" -print0 | xargs -0 shellcheck
end_group
begin_group "Check markdown documents with markdownlint"
find . -type f -name "*.md" -not -path "./.git/*" -print0 | xargs -0 markdownlint
end_group
begin_group "Check markdown documents with markdown-link-check"
find . -type f -name "*.md" -not -path "./.git/*" -print0 | xargs -0 markdown-link-check -c markdown-link-check.json
end_group