-
Notifications
You must be signed in to change notification settings - Fork 20
/
check-syntax
executable file
·34 lines (28 loc) · 1.23 KB
/
check-syntax
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
#!/bin/bash
set -eu
# Checks the syntax of the conformance test files against an ISL grammar for the conformance DSL.
# This requires at least [email protected] because a bugfix in ion-rust
readonly ion_cli_min_version="ion 0.9.1"
# Check the Ion CLI version so that we aren't erroneously passing because of an unfixed bug
readonly ion_cli_version=$(printf "%s\n%s" "$ion_cli_min_version" "$(ion -V)" | sort --version-sort | head -n 1)
if [[ "$ion_cli_version" != "$ion_cli_min_version" ]]; then
echo "This script requires $ion_cli_min_version; found $ion_cli_version"
exit 1
fi
readonly command=\
'ion schema -X validate -RE -f conformance/grammar.isl test_file conformance/**/*.ion'
# Macs come with older versions of bash which don't support globstar, so if we're on an older
# version of bash, we'll attempt to use zsh instead, but we don't use zsh by default because
# it doesn't come pre-installed on GitHub Actions runners
if [ -z "${BASH_VERSION}" ] || [ "${BASH_VERSION%%.*}" -lt 4 ]; then
if which -s zsh; then
printf "bash version requirements not met; using zsh\n\n"
echo "$command" | zsh
else
echo "The check-syntax script requires either bash >=4.0.0 or zsh"
exit 1
fi
else
shopt -s globstar
eval "$command"
fi