Skip to content
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

Use all.sh and its component list in pre-push hook #2639

Merged

Conversation

mpg
Copy link
Contributor

@mpg mpg commented May 10, 2019

Description

Currently there is some level of duplication between all.sh and the pre-push hook: when a fast check is added to all.sh we have to remember to add it to the pre-push hook as well.

This commit adds five components that were previously not run:

  • check_recursion
  • check_changelog
  • check_test_cases
  • check_python_files
  • check_generate_test_code

It also changes the behaviour in case in-tree cmake was enabled before pushing or otherwise running the pre-push hook: previously the script failed because check_names is not compatible with cmake, now it silently disables cmake (and succeeds unless there is an actual issue).

Status

READY

Requires Backporting

Yes, as it's a test script.

Migrations

NO

Manuel testing

Though the most important case to test is tests/scripts/all.sh -q -k 'check_*' with and without errors, as that's what's used in the pre-push hook, I believe the full test matrix is 2x2x2:

  • --quiet / --no-quiet
  • --keep-going / --no-keep-going
  • errors or no errors (an error can be triggerred for example by adding trailing whitespace in library/aes.c)

I don't think it's really useful at this point to test anything other that the check_* components with -q.

@mpg mpg added enhancement mbed TLS team needs-review Every commit must be reviewed by at least two team members, needs-backports Backports are missing or are pending review and approval. component-platform Portability layer and build scripts labels May 10, 2019
@gilles-peskine-arm gilles-peskine-arm added needs-work and removed needs-review Every commit must be reviewed by at least two team members, labels Oct 31, 2019
mpg added 5 commits June 2, 2020 11:19
It brings no value and distracts us from the actual content.

Signed-off-by: Manuel Pégourié-Gonnard <[email protected]>
The primary purpose is to use it to run all.sh -k -q in the pre-push hook, but
this can be useful in any circumstance where you're not interested in the full
output from each component and just want a short summary of which components
were run (and if any failed).

Note that only stdout from components is suppressed, stderr is preserved so
that errors are reported. This means components should avoid printing to
stderr in normal usage (ie in the absence of errors).

Currently all the `check_*` components obey this convention except:
- check_generate_test_code: unittest prints progress to stderr
- check_test_cases: lots of non-fatal warnings printed to stderr

These components will be fixed in follow-up commits.

Signed-off-by: Manuel Pégourié-Gonnard <[email protected]>
Signed-off-by: Manuel Pégourié-Gonnard <[email protected]>
Signed-off-by: Manuel Pégourié-Gonnard <[email protected]>
The list in the pre-push hook was redundant with the list of `check_*`
components in all.sh, and unsurprisingly it was outdated.

Missing components were:

- check_recursion
- check_changelog
- check_test_cases
- check_python_files
- check_generate_test_code

Signed-off-by: Manuel Pégourié-Gonnard <[email protected]>
@mpg mpg force-pushed the use-all-sh-checks-for-pre-push branch from 25c637f to 129e13c Compare June 2, 2020 09:58
@mpg
Copy link
Contributor Author

mpg commented Jun 2, 2020

@gilles-peskine-arm I've force-pushed a version with a new history, as I don't think the initial fiddling in pre-push.sh had much value. I recommend you review the new history directly as the changes are small anyway.

@mpg mpg added needs-review Every commit must be reviewed by at least two team members, and removed needs-work labels Jun 2, 2020
@mpg mpg requested a review from gilles-peskine-arm June 2, 2020 10:03
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still a few minor problems with output suppression in all.sh.

I timed the old hook at 40s and the new one at 53s. It would be nice to only check what's change, but that would be a lot of work. I don't personally care since I don't use the hook anyway (let the CI take care of testing, that's my philosophy).

mpg added 2 commits June 8, 2020 10:46
Since dd prints everything on stderr, both normal status update and actual
errors when they occur, redirecting that to /dev/null is a trade-off that's
acceptable in quiet mode (typically used on a developer's machine and the
developer will re-run in non-quiet mode if anything fails without sufficient
detail in the output), but not that much in non-quiet mode.

For example, if our dd invocation fails because the disk in full on a CI
machine, we want the error to be reported at the time we invoke dd, and not
later when a seemingly unrelated test fails due to an incorrect seedfile.

Signed-off-by: Manuel Pégourié-Gonnard <[email protected]>
While pure sh doesn't have a concept of local variables, we can partially
emulate them by unsetting variables before we exit the function, and use the
convention of giving them lowercase names to distinguish from global
variables.

Signed-off-by: Manuel Pégourié-Gonnard <[email protected]>
@mpg mpg requested a review from gilles-peskine-arm June 8, 2020 09:23
@mpg
Copy link
Contributor Author

mpg commented Jun 8, 2020

@gilles-peskine-arm I believe I've addressed all your feedback, except one that you indicated was not a blocker. This is ready for you to review again.

@mpg mpg added the good-first-issue Good for newcomers label Jun 10, 2020
Copy link
Contributor

@ronald-cron-arm ronald-cron-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice change, now I will use tests/scripts/all.sh -q -k 'check_*' to check my commits before to push them to the CI.

@mpg mpg removed the needs-review Every commit must be reviewed by at least two team members, label Jun 23, 2020
@gilles-peskine-arm gilles-peskine-arm added approved Design and code approved - may be waiting for CI or backports and removed needs-backports Backports are missing or are pending review and approval. labels Jun 23, 2020
@gilles-peskine-arm gilles-peskine-arm merged commit 04c6b61 into Mbed-TLS:development Jun 23, 2020
@mpg mpg deleted the use-all-sh-checks-for-pre-push branch August 14, 2020 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Design and code approved - may be waiting for CI or backports component-platform Portability layer and build scripts enhancement good-first-issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants