-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update maintainer and CI shell scripts #3326
Conversation
POSIX does not specify test for > 4 arguments: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html shellcheck rule: SC2166
POSIX allows both the legacy `cmd` and the new-style $(cmd) syntaxes: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_03 However, POSIX recommends using the new-style syntax, as it has less restrictions and allows nesting without escape characters: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html#tag_23_02_06_03 shellcheck rule: SC2006
shellcheck rule: SC2086
The original pattern wouldn't work if a filename was the suffix of another, e.g. `lb.py` would be marked as used in the CMakeLists.txt because of a match at the line `python_test(FILE engine_lb.py)`. The new pattern is also not a regular expression: the dot in the file extension doesn't match any character, only the dot character.
Replace deprecated `egrep` by `grep -E`. shellcheck rule: SC2196
Add a shebang in all shell scripts. Downgrade shebangs from Bash to Dash (sh) in small scripts that don't use Bash-specific syntax. Use the most portable shebang (`#!/usr/bin/env <shell>`) to include the user $PATH in the search path. shellcheck rule: SC2148
shellcheck rules: SC2002 SC2116
shellcheck rules: SC2061 SC2063
Separate unit tests from python tests. Run unit tests on Fedora, Debian and OpenSUSE.
Codecov Report
@@ Coverage Diff @@
## python #3326 +/- ##
=======================================
- Coverage 86% 86% -1%
=======================================
Files 538 536 -2
Lines 25411 25562 +151
=======================================
+ Hits 21895 21997 +102
- Misses 3516 3565 +49
Continue to review full report at Codecov.
|
Is it possible to run the scripts in the CI in POSIX compatibility mode (e.g. using |
Not really. For example |
Reduce bashisms. Downgrade shebangs from Bash to Dash (sh) in POSIX-compliant shell scripts. Use the most portable shebang (`#!/usr/bin/env <shell>`) to include the user $PATH in the search path.
I've removed more bashisms, but several shell scripts still rely on useful bash-specific features:
List of bash scripts: head -n 1 $(find maintainer/ testsuite/ -name "*.sh")
|
I also don't think it is so super important. At the end of the day most of those scripts only run in an environment that we control. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine. We should really migrate this mess to Python scripts ASAP though.
@@ -1,4 +1,4 @@ | |||
#!/usr/bin/env bash | |||
#!/usr/bin/env sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/usr/bin/env sh
is useless as /usr/bin/env
is not guaranteed by POSIX (neither is /bin/sh
, by the way). I would just use /bin/sh
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the idea was to be more portable, as the program env
reads the user $PATH
. I put this change in the POSIX bucket for convenience, since most scripts modified in that commit had heterogenous shebangs that needed fixing, although it has nothing to do with POSIX. In fact, sh
might not even point to the dash
interpreter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, it seems like we develop a DevOps library in bash without knowing it 😄
bors r=KaiSzuttor |
3326: Update maintainer and CI shell scripts r=KaiSzuttor a=jngrad Fixes #3242 Description of changes: - reduce number of shellcheck warnings from 238 down to 104 - rules: `SC2002 SC2006 SC2061 SC2063 SC2086 SC2116 SC2148 SC2166 SC2196` - 50 of the remaining warnings are false positives from `build_cmake.sh` (`SC2086 SC2154`) - refactor outdated maintainer shell scripts - remove deprecated shell syntax and shell commands - use POSIX alternatives to bashisms when the change is trivial - quote string variables to guard against whitespace-related issues - start unit tests before integration tests - run unit tests for all operating systems (Debian, OpenSUSE, Fedora) Notes: - `shellcheck` is unsuitable for CI in its current form (e.g. no rule whitelisting capability) - the shell scripts now have an homogeneous syntax and few linter warnings, which is desirable if we decide to port them to Python in the future Co-authored-by: Jean-Noël Grad <[email protected]>
Build succeeded |
Fixes #3242
Description of changes:
SC2002 SC2006 SC2061 SC2063 SC2086 SC2116 SC2148 SC2166 SC2196
build_cmake.sh
(SC2086 SC2154
)Notes:
shellcheck
is unsuitable for CI in its current form (e.g. no rule whitelisting capability)