pytorch
65d5004b - Update, appease, and enable fail-on for shellcheck (#47786)

Commit
4 years ago
Update, appease, and enable fail-on for shellcheck (#47786) Summary: Currently ([example](https://github.com/pytorch/pytorch/runs/1381883195)), ShellCheck is run on `*.sh` files in `.jenkins/pytorch`, but it uses a three-and-a-half-year-old version, and doesn't fail the lint job despite yielding many warnings. This PR does the following: - update ShellCheck to v0.7.1 (and generally make it always use the latest `"stable"` release), to get more warnings and also enable the directory-wide directives that were introduced in v0.7.0 (see the next bullet) - move the rule exclusions list from a variable in `.jenkins/run-shellcheck.sh` to a [declarative file](https://github.com/koalaman/shellcheck/issues/725#issuecomment-469102071) `.jenkins/pytorch/.shellcheckrc`, so now editor integrations such as [vscode-shellcheck](https://github.com/timonwong/vscode-shellcheck) give the same warnings as the CLI script - fix all ShellCheck warnings in `.jenkins/pytorch` - remove the suppression of ShellCheck's return value, so now it will fail the lint job if new warnings are introduced --- While working on this, I was confused because I was getting fairly different results from running ShellCheck locally versus what I saw in the CI logs, and also different results among the laptop and devservers I was using. Part of this was due to different versions of ShellCheck, but there were even differences within the same version. For instance, this command should reproduce the results in CI by using (almost) exactly the same environment: ```bash act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 -j quick-checks \ | sed '1,/Run Shellcheck Jenkins scripts/d;/Success - Shellcheck Jenkins scripts/,$d' \ | cut -c25- ``` But the various warnings were being displayed in different orders, so it was hard to tell at a glance whether I was getting the same result set or not. However, piping the results into this ShellCheck-output-sorting Python script showed that they were in fact the same: ```python import fileinput items = ''.join(fileinput.input()).split('\n\n') print(''.join(sorted(f'\n{item.strip()}\n\n' for item in items)), end='') ``` Note that while the above little script worked for the old version (v0.4.6) that was previously being used in CI, it is a bit brittle, and will not give great results in more recent ShellCheck versions (since they give more different kinds of output besides just a list of warnings). Pull Request resolved: https://github.com/pytorch/pytorch/pull/47786 Reviewed By: seemethere Differential Revision: D24900522 Pulled By: samestep fbshipit-source-id: 92d66e1d5d28a77de5a4274411598cdd28b7d436
Author
Parents
Loading