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

perl syntax checking in parallel, but limit the number of processes. #4328

Merged
merged 5 commits into from
Oct 9, 2020

Conversation

svensven
Copy link
Contributor

@svensven svensven commented Oct 7, 2020

Adapted from the refresh_taxonomies.js script.

The syntax checking is slow (5-6 mins on github), but checking over 100 scripts simultaneously is also unworkable:
#3368

The limit is configurable, in case the environment running the checks ever has more than the 2 cores it currently does. Increasing the limit on 2 cores works (at least with 3 & 4), but is no faster.

Should shave another 2-3 mins off the pull request workflow.

Update: With the changed files workflow plugin, it removes the whole 5-6 mins.

Adapted from the refresh_taxonomies.js script.

The syntax checking is slow (5-6 mins on github), but checking over 100 scripts simultaneously is also unworkable:
openfoodfacts#3368

The limit is configurable, in case the environment running the checks ever has more than the 2 cores it currently does. Increasing the limit on 2 cores works (at least with 3 & 4), but is no faster.
@svensven svensven added the GitHub Actions Pull requests that update Github_actions code label Oct 7, 2020
running = Number.MAX_SAFE_INTEGER;
while (running > 0) {
running = spawns.reduce((pv, cv) => {
if (cv.exitCode === null) {
Copy link
Contributor

@Ban3 Ban3 Oct 7, 2020

Choose a reason for hiding this comment

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

You might want to check cv.signalCode here as well. If the process gets killed for out of memory reason, the exitCode will stay as null and CI wont fail until timeout is reached.

This is a issue with refresh-taxonomies.js too, as we saw recently with Travis failures.

From the exit event documentation. This refers to the function arguments, but it also applies to the properties:

The 'exit' event is emitted after the child process ends. If the process exited, code is the final exit code of the process, otherwise null. If the process terminated due to receipt of a signal, signal is the string name of the signal, otherwise null. One of the two will always be non-null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so, if (cv.exitCode === null && cv.signalCode === null) { ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@svensven Yeah, I think that's good enough for our purposes. I think technically signalCode can be some non-null signal that didn't lead to exit (like SIGUSR2 or whatever) but seems pretty unlikely to happen.

@stephanegigandet
Copy link
Contributor

If it's just syntax checking, maybe we could try a way to run the tests only when the scripts have changed, like we do for the taxonomies. It doesn't make much sense to test 100 scripts every time.

I don't know if we can get the info of whether a file has been changed in a PR when we run the tests though.
One option could be to periodically touch and commit a file, but it's not very elegant.

@svensven
Copy link
Contributor Author

svensven commented Oct 8, 2020

I don't know if we can get the info of whether a file has been changed in a PR when we run the tests though.

That would be nice. Given that someone's written this https://github.com/jitterbit/get-changed-files but, looking at its issues, github doesn't expose enough information to handle force-pushes etc, it may be difficult to achieve.

@svensven
Copy link
Contributor Author

svensven commented Oct 8, 2020

this one seems to use a different technique, which maybe doesn't have the same issue:
https://github.com/marketplace/actions/changed-files-exporter

also, some whitespace, because it took me far too long to realise the run block wasn't all one backslash-continued command.
@svensven svensven requested a review from a team October 8, 2020 13:14
they were never checked directly, but checking all scripts checked them by inheritance.
@sonarcloud
Copy link

sonarcloud bot commented Oct 9, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@svensven svensven merged commit d049232 into openfoodfacts:master Oct 9, 2020
@svensven svensven deleted the check-perl-parallel branch October 9, 2020 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GitHub Actions Pull requests that update Github_actions code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants