From 0d084e9a213b8dbc8a09933b64399db7e5457632 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Wed, 14 Aug 2024 14:10:49 +0200 Subject: [PATCH 1/3] Add shellcheck github workflow --- .github/workflows/shellcheck.yml | 18 ++++++++++++++++++ bin/bootstrap | 1 + 2 files changed, 19 insertions(+) create mode 100644 .github/workflows/shellcheck.yml diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 0000000..e185585 --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,18 @@ +name: shellcheck + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +jobs: + shellcheck: + name: Run shellcheck on scripts + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + + - name: Run shellcheck + uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 diff --git a/bin/bootstrap b/bin/bootstrap index e92bbf4..c46b75f 100755 --- a/bin/bootstrap +++ b/bin/bootstrap @@ -48,6 +48,7 @@ system("rm -rf %s" % File.join(dir, ".ruby-version")) system("rm -rf %s" % File.join(dir, "bin/bootstrap")) system("rm -rf %s" % File.join(dir, ".github/ISSUE_TEMPLATE.md")) system("rm -rf %s" % File.join(dir, ".github/workflows/pause-community-contributions.yml")) +system("rm -rf %s" % File.join(dir, ".github/workflows/shellcheck.yml")) system("mv %s/TRACK_README.md %s/README.md" % [dir, dir]) f = File.join(dir, 'LICENSE') From 47effbf9b7fd8db7837d613228add25453456266 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Wed, 14 Aug 2024 14:19:42 +0200 Subject: [PATCH 2/3] Fix shellcheck --- bin/verify-exercises | 1 + bin/verify-exercises-in-docker | 2 ++ 2 files changed, 3 insertions(+) diff --git a/bin/verify-exercises b/bin/verify-exercises index 269a608..3355f55 100755 --- a/bin/verify-exercises +++ b/bin/verify-exercises @@ -29,6 +29,7 @@ copy_example_or_examplar_to_solution() { } unskip_tests() { + # shellcheck disable=SC2034 jq -r '.files.test[]' .meta/config.json | while read -r test_file; do noop # TODO: replace this with the command to unskip the tests. # Note: this function runs from within an exercise directory. diff --git a/bin/verify-exercises-in-docker b/bin/verify-exercises-in-docker index f64083f..d4c2033 100755 --- a/bin/verify-exercises-in-docker +++ b/bin/verify-exercises-in-docker @@ -30,6 +30,7 @@ copy_example_or_examplar_to_solution() { } pull_docker_image() { + # shellcheck disable=SC1083 docker pull exercism/{{SLUG}}-test-runner || die $'Could not find the `exercism/{{SLUG}}-test-runner` Docker image.\nCheck the test runner docs at https://exercism.org/docs/building/tooling/test-runners for more information.' } @@ -38,6 +39,7 @@ run_tests() { local slug slug="${1}" + # shellcheck disable=SC1083 docker run \ --rm \ --network none \ From 8f5b6aa231fbc9e33f80c1cb5ee3eb939f8f619d Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Wed, 14 Aug 2024 14:27:37 +0200 Subject: [PATCH 3/3] Remove shellcheck exceptions --- bin/bootstrap | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bin/bootstrap b/bin/bootstrap index c46b75f..3c3a37f 100755 --- a/bin/bootstrap +++ b/bin/bootstrap @@ -45,10 +45,10 @@ system("rm -rf %s" % File.join(dir, ".git")) system("rm -rf %s" % File.join(dir, "Gemfile")) system("rm -rf %s" % File.join(dir, "Gemfile.lock")) system("rm -rf %s" % File.join(dir, ".ruby-version")) -system("rm -rf %s" % File.join(dir, "bin/bootstrap")) -system("rm -rf %s" % File.join(dir, ".github/ISSUE_TEMPLATE.md")) -system("rm -rf %s" % File.join(dir, ".github/workflows/pause-community-contributions.yml")) -system("rm -rf %s" % File.join(dir, ".github/workflows/shellcheck.yml")) +system("rm -rf %s" % File.join(dir, "bin", "bootstrap")) +system("rm -rf %s" % File.join(dir, ".github", "ISSUE_TEMPLATE.md")) +system("rm -rf %s" % File.join(dir, ".github", "workflows", "pause-community-contributions.yml")) +system("rm -rf %s" % File.join(dir, ".github", "workflows", "shellcheck.yml")) system("mv %s/TRACK_README.md %s/README.md" % [dir, dir]) f = File.join(dir, 'LICENSE') @@ -63,6 +63,14 @@ File.open(f, "w") do |f| f.write contents.gsub('{{UUID}}') {|m| SecureRandom.uuid } end +%w[verify-exercises verify-exercises-in-docker].each do |name| + f = File.join(dir, 'bin', name) + contents = File.read(f) + File.open(f, "w") do |f| + f.write contents.gsub(/^\s*# shellcheck.*?\n/, '') + end +end + [ "config.json", "README.md",