Skip to content

Commit

Permalink
Fix check-syntax script (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
popematt authored Nov 14, 2024
1 parent d6ffc3c commit 8506bf5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ on:
- '**:**'

jobs:
validate:
check-conformance-test-syntax:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Ion CLI
run: cargo install ion-cli@0.8.0
run: cargo install ion-cli@0.9.1
- name: Run validation script
run: ./check-syntax
35 changes: 30 additions & 5 deletions check-syntax
Original file line number Diff line number Diff line change
@@ -1,9 +1,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] for the `-R` option.
# We have to include the `--no-auto-decompress` flag because there's an issue that prevents Ion CLI from
# correctly reading files that start with a line comment.
# See: https://github.com/amazon-ion/ion-cli/issues/162
ion schema -X validate --no-auto-decompress -RE -f conformance/grammar.isl test_file conformance/**/*.ion
# 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

0 comments on commit 8506bf5

Please sign in to comment.