From 9d54e960117487e1d167c26ed13cd5e7114f7418 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 19 Sep 2019 12:26:12 +0300 Subject: [PATCH] docs: update --- .github/workflows/main.yml | 9 +++++++++ test.sh | 24 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 .github/workflows/main.yml create mode 100755 test.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..c60900d --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,9 @@ +name: Shellcheck +on: [push] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Run shellcheck. + run: ./test.sh diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..ac97df7 --- /dev/null +++ b/test.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# shellcheck source=/dev/null +# +# Tests for the Pure sh Bible. + +main() { + trap 'rm -f readme_code test_file' EXIT INT + + # Extract code blocks from the README. + while read -r line; do + [ "$code" ] && [ "$line" != \`\`\` ] && + printf '%s\n' "$line" + + case $line in + \`\`\`sh) code=1 ;; + \`\`\`) code= + esac + done < README.md > readme_code + + # Run shellcheck and source the code. + shellcheck -s sh readme_code test.sh || exit 1 +} + +main "$@"