|
| 1 | +name: Tests and Shellcheck |
| 2 | + |
| 3 | +# Trigger the workflow on push or pull request |
| 4 | +on: [push, pull_request] |
| 5 | + |
| 6 | + |
| 7 | +jobs: |
| 8 | + |
| 9 | + tests: |
| 10 | + name: Run bash function tests |
| 11 | + runs-on: macos-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v2 |
| 15 | + |
| 16 | + - name: Log Mac OS version information |
| 17 | + run: | |
| 18 | + sw_vers |
| 19 | +
|
| 20 | + # Run the 'java-version-tester' script and show&save (`tee`) the output to a |
| 21 | + # logfile; then grep the logfile for 'FAILED' entries which would cause grep |
| 22 | + # to exit with 0; then run 'test' command and swap the grep exit code |
| 23 | + # to return with 0 if grep doesn't match and return with 1 if it matches. |
| 24 | + - name: Run function tests in java-version-tester.sh |
| 25 | + run: | |
| 26 | + echo "Running tests..." |
| 27 | + bash test/java-version-tester.sh | tee test/java-version-tester.log |
| 28 | + echo "Tests done. Checking for failures..." |
| 29 | + test/check-log.sh test/java-version-tester.log FAILED |
| 30 | +
|
| 31 | +
|
| 32 | + shellcheck: |
| 33 | + name: Check bash syntax with shellcheck |
| 34 | + runs-on: macos-latest |
| 35 | + |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v2 |
| 38 | + |
| 39 | + - name: Log Mac OS version information |
| 40 | + run: | |
| 41 | + sw_vers |
| 42 | +
|
| 43 | + - name: Install shellcheck via HomeBrew |
| 44 | + run: | |
| 45 | + brew install shellcheck |
| 46 | + shellcheck -V |
| 47 | +
|
| 48 | + # Test with shellcheck for bash syntax errors which should fail the build. |
| 49 | + # Until https://github.com/koalaman/shellcheck/issues/524 is implemented, |
| 50 | + # grep for errors and fail manually. |
| 51 | + # |
| 52 | + # Show & save the output via `tee` to a logfile; then grep the logfile for |
| 53 | + # 'error:' entries which would cause grep to exit with 0; then run 'test' |
| 54 | + # command and swap the grep exit code to return with 0 if grep doesn't match |
| 55 | + # and return with 1 if it matches |
| 56 | + - name: Run shellcheck on the launcher stub |
| 57 | + run: | |
| 58 | + echo "Running shellcheck..." |
| 59 | + shellcheck -s bash -f gcc src/universalJavaApplicationStub | tee test/shellcheck.log |
| 60 | + echo "Shellcheck done. Checking for errors..." |
| 61 | + test/check-log.sh test/shellcheck.log "error:" |
0 commit comments