From 476274474f5fc709b176f481d66865f190e14a52 Mon Sep 17 00:00:00 2001 From: ricky Date: Tue, 19 Nov 2019 10:46:10 -0500 Subject: [PATCH] Add shellcheck lint (#7392) * Add shellcheck lint script * Add to build * Add shellcheck lint to main lint task * Put shellcheck in the right place, hopefully? * Fix declared multiple executor types * Add sudo * Address shellcheck warnings * Add test-lint-shellcheck * Add test-lint-shellcheck to workflow * Use correct lint task * output version which could be helpful for debugging * Address PR feedback * consistency++ --- .circleci/config.yml | 12 ++++++++++++ development/auto-changelog.sh | 2 +- development/rollback.sh | 14 +++++++------- package.json | 1 + 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index af3b70ebb..5270da98f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,6 +22,7 @@ workflows: - test-lint: requires: - prep-deps + - test-lint-shellcheck - test-e2e-chrome: requires: - prep-deps @@ -49,6 +50,7 @@ workflows: - all-tests-pass: requires: - test-lint + - test-lint-shellcheck - test-unit - test-unit-global - test-mozilla-lint @@ -173,6 +175,16 @@ jobs: name: Verify locales command: yarn verify-locales --quiet + test-lint-shellcheck: + docker: + - image: circleci/node:10.17-browsers + steps: + - checkout + - run: sudo apt-get install shellcheck + - run: + name: Shellcheck Lint + command: yarn lint:shellcheck + test-deps: docker: - image: circleci/node:10.17-browsers diff --git a/development/auto-changelog.sh b/development/auto-changelog.sh index 3ed059b3d..26ab8e93f 100755 --- a/development/auto-changelog.sh +++ b/development/auto-changelog.sh @@ -10,7 +10,7 @@ git fetch --tags most_recent_tag="$(git describe --tags "$(git rev-list --tags --max-count=1)")" -git rev-list "${most_recent_tag}"..HEAD | while read commit +git rev-list "${most_recent_tag}"..HEAD | while read -r commit do subject="$(git show -s --format="%s" "$commit")" diff --git a/development/rollback.sh b/development/rollback.sh index 639d72a67..a3040e6f1 100755 --- a/development/rollback.sh +++ b/development/rollback.sh @@ -4,20 +4,20 @@ echo "Rolling back to version $1" # Checkout branch to increment version -git checkout -b version-increment-$1 +git checkout -b "version-increment-$1" yarn version:bump patch # Store the new version name -NEW_VERSION=$(cat app/manifest.json | jq -r .version) +NEW_VERSION=$(jq -r .version < app/manifest.json) # Make sure origin tags are loaded git fetch origin # check out the rollback branch -git checkout origin/v$1 +git checkout "origin/v$1" # Create the rollback branch. -git checkout -b Version-$NEW_VERSION-Rollback-to-$1 +git checkout -b "Version-$NEW_VERSION-Rollback-to-$1" # Set the version files to the next one. git checkout master CHANGELOG.md @@ -28,8 +28,8 @@ git commit -m "Version $NEW_VERSION (Rollback to $1)" git push -u origin HEAD # Create tag and push that up too -git tag v${NEW_VERSION} -git push origin v${NEW_VERSION} +git tag "v${NEW_VERSION}" +git push origin "v${NEW_VERSION}" # Cleanup version branch -git branch -D version-increment-$1 +git branch -D "version-increment-$1" diff --git a/package.json b/package.json index 73659d909..49b38bc0d 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "lint:fix": "eslint . --ext js,json --fix", "lint:changed": "{ git ls-files --others --exclude-standard ; git diff-index --name-only --diff-filter=d HEAD ; } | grep --regexp='[.]js$' --regexp='[.]json$' | tr '\\n' '\\0' | xargs -0 eslint", "lint:changed:fix": "{ git ls-files --others --exclude-standard ; git diff-index --name-only --diff-filter=d HEAD ; } | grep --regexp='[.]js$' --regexp='[.]json$' | tr '\\n' '\\0' | xargs -0 eslint --fix", + "lint:shellcheck": "shellcheck --version && find . -type f -name '*.sh' ! -path './node_modules/*' -print0 | xargs -0 shellcheck", "verify-locales": "node ./development/verify-locale-strings.js", "mozilla-lint": "addons-linter dist/firefox", "watch": "cross-env METAMASK_ENV=test mocha --watch --require test/setup.js --reporter min --recursive \"test/unit/**/*.js\" \"ui/app/**/*.test.js\"",