Skip to content

Commit

Permalink
Add shellcheck github workflow (#190)
Browse files Browse the repository at this point in the history
* Add shellcheck github workflow

* Fix shellcheck

* Remove shellcheck exceptions
  • Loading branch information
ErikSchierboom authored Aug 14, 2024
1 parent a47547d commit df67ec7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 12 additions & 3 deletions bin/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +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, "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')
Expand All @@ -62,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",
Expand Down
1 change: 1 addition & 0 deletions bin/verify-exercises
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions bin/verify-exercises-in-docker
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
}
Expand All @@ -38,6 +39,7 @@ run_tests() {
local slug
slug="${1}"

# shellcheck disable=SC1083
docker run \
--rm \
--network none \
Expand Down

0 comments on commit df67ec7

Please sign in to comment.