Skip to content

Commit

Permalink
Merge pull request #2026 from Zac-HD/apt-get-shellcheck
Browse files Browse the repository at this point in the history
Make shellcheck install much faster
  • Loading branch information
Zac-HD committed Jun 30, 2019
2 parents dcea297 + aa155f8 commit 3f60f23
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 11 additions & 4 deletions tooling/src/hypothesistooling/installers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from __future__ import absolute_import, division, print_function

import os
import shutil
import subprocess

import hypothesistooling.scripts as scripts
Expand Down Expand Up @@ -57,7 +58,9 @@ def ensure_python(version):

STACK = os.path.join(HOME, ".local", "bin", "stack")
GHC = os.path.join(HOME, ".local", "bin", "ghc")
SHELLCHECK = os.path.join(HOME, ".local", "bin", "shellcheck")
SHELLCHECK = shutil.which("shellcheck") or os.path.join(
HOME, ".local", "bin", "shellcheck"
)


def ensure_stack():
Expand Down Expand Up @@ -90,9 +93,13 @@ def ensure_ghc():
def ensure_shellcheck():
if os.path.exists(SHELLCHECK):
return
update_stack()
ensure_ghc()
subprocess.check_call([STACK, "install", "ShellCheck"])
if shutil.which("apt-get") is not None:
subprocess.check_call(["apt-get", "update"])
subprocess.check_call(["apt-get", "install", "shellcheck"])
else:
update_stack()
ensure_ghc()
subprocess.check_call([STACK, "install", "ShellCheck"])


@once
Expand Down
4 changes: 3 additions & 1 deletion whole-repo-tests/test_shellcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@


def test_all_shell_scripts_are_valid():
subprocess.check_call([install.SHELLCHECK, *SCRIPTS], cwd=tools.ROOT)
subprocess.check_call(
[install.SHELLCHECK, "--exclude=SC1073,SC1072", *SCRIPTS], cwd=tools.ROOT
)

0 comments on commit 3f60f23

Please sign in to comment.