This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
CI: Rewrite check-each-crate in python
#13238
Merged
paritytech-processbot
merged 9 commits into
master
from
bkchr-rewrite-check-each-crate-python
Jan 25, 2023
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
20d8f1d
CI: Rewrite `check-each-crate` in python
bkchr ee8ba35
Fix dumb bugs and print everything to stderr
bkchr c4b4bfc
Don't buffer Python output
rcny 1b1fa84
:facepalm:
bkchr e87a4bc
Merge branch 'bkchr-rewrite-check-each-crate-python' of github.com:pa…
bkchr c96e997
:facepalm: :facepalm:
bkchr 16d5d6d
Use check all until we have more macos runners
bkchr 5fbfbe7
Update scripts/ci/gitlab/check-each-crate.py
bkchr d793016
Update scripts/ci/gitlab/pipeline/test.yml
bkchr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| # A script that checks each workspace crate individually. | ||
| # It's relevant to check workspace crates individually because otherwise their compilation problems | ||
| # due to feature misconfigurations won't be caught, as exemplified by | ||
| # https://github.com/paritytech/substrate/issues/12705 | ||
| # | ||
| # `check-each-crate.py target_group groups_total` | ||
| # | ||
| # - `target_group`: Integer starting from 1, the group this script should execute. | ||
| # - `groups_total`: Integer starting from 1, total number of groups. | ||
|
|
||
| import subprocess, sys | ||
|
|
||
| # Get all crates | ||
| output = subprocess.check_output(["cargo", "tree", "--locked", "--workspace", "--depth", "0", "--prefix", "none"]) | ||
|
|
||
| # Convert the output into a proper list | ||
| crates = [] | ||
| for line in output.splitlines(): | ||
| if line != b"": | ||
| crates.append(line.decode('utf8').split(" ")[0]) | ||
|
|
||
| # Make the list unique and sorted | ||
| crates = list(set(crates)) | ||
| crates.sort() | ||
|
|
||
| target_group = int(sys.argv[1]) - 1 | ||
| groups_total = int(sys.argv[2]) | ||
|
|
||
| if len(crates) == 0: | ||
| print("No crates detected!", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
| print(f"Total crates: {len(crates)}", file=sys.stderr) | ||
|
|
||
| crates_per_group = len(crates) // groups_total | ||
|
|
||
| # If this is the last runner, we need to take care of crates | ||
| # after the group that we lost because of the integer division. | ||
| if target_group + 1 == groups_total: | ||
| overflow_crates = len(crates) % groups_total | ||
| else: | ||
| overflow_crates = 0 | ||
|
|
||
| print(f"Crates per group: {crates_per_group}", file=sys.stderr) | ||
|
|
||
| # Check each crate | ||
| for i in range(0, crates_per_group + overflow_crates): | ||
| crate = crates_per_group * target_group + i | ||
|
|
||
| print(f"Checking {crates[crate]}", file=sys.stderr) | ||
|
|
||
| res = subprocess.run(["cargo", "check", "--locked", "-p", crates[crate]]) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In theory we would have to check with each feature subset… but that would make it even slower 😅
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I know :P |
||
|
|
||
| if res.returncode != 0: | ||
| sys.exit(1) | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.