-
Notifications
You must be signed in to change notification settings - Fork 4
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
CI: spectests in CI #95
Conversation
Am I right that |
#bash ./ci/run-tests.sh --locked | grep test_zkasm
<snip>
test test_zkasm::tests::run_spectests ... ok
<snip> |
I’ll defer this to @Akashin since it was their request. I personally think it would be easier on the eyes if this file was post-processed with |
@nagisa can you take a look please, why it fails? As prints show python script goes to |
I do agree that we would benefit from making this output easily readable by humans to make it easier to study this data. I think CSV is fine for the first version, but we should iterate on it in the future PR. |
.github/workflows/main.yml
Outdated
@@ -50,6 +50,19 @@ jobs: | |||
- run: npm ci --prefix tests/zkasm | |||
- run: ./ci/test-zkasm.sh | |||
|
|||
spectest_zkasm: |
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.
I suggest we merge this with the previous test_zkasm
job:
- They are semantically in the same category
- We will likely have more of these tests (for each of spec test files) and we wouldn't want a new job for each one of them
- This will make sure we reuse NPM cache between jobs and save execution time as that is the dominating step for this job
Am I missing any reasons to split these into separate jobs?
ci/zkasm-result.py
Outdated
if file.endswith('.wat'): | ||
test_name = os.path.splitext(file)[0] | ||
zkasm_file = f'{test_name}.zkasm' | ||
status_map[test_name] = 'compilation success' if zkasm_file in os.listdir(generated_dir) else 'compilation failed' |
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.
You can do os.path.exists(os.path.join(generated_dir, zkasm_file))
to be more specific
ci/zkasm-result.py
Outdated
def check_compilation_status(): | ||
status_map = {} | ||
for file in os.listdir(tests_dir): | ||
if file.endswith('.wat'): |
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.
General idea to reduce code nesting, use continue
:
if not file.endswith('.wat'):
continue
# Code below becomes less nested.
...
|
||
def update_status_from_stdin(status_map): | ||
for line in sys.stdin: | ||
if "--> fail" in line or "--> pass" in line: |
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.
That's the reason I originally suggested doing this in run-tests-zkasm.js
where we have the information about test status programmatically and don't have to parse strings.
I'm fine with keeping this in Python for now, but if you agree moving this to JS will simplify code, feel free to do this.
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.
This parsing takes just a few lines, and I found that wasmtime
repo already contains some python files, so it won't be a big deviation from style of the repo, so I decided proceed with more convenient for me language
ci/zkasm-result.py
Outdated
csvwriter = csv.writer(csvfile) | ||
csvwriter.writerow(['Test', 'Status']) | ||
status_list = sorted(list(map(lambda x: (x, status_map[x]), status_map))) | ||
for (test, status) in status_list: |
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.
You can also do csvwriter.writerows(status_list)
ci/zkasm-result.py
Outdated
with open(state_csv_path, 'w', newline='') as csvfile: | ||
csvwriter = csv.writer(csvfile) | ||
csvwriter.writerow(['Test', 'Status']) | ||
status_list = sorted(list(map(lambda x: (x, status_map[x]), status_map))) |
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.
You can simplify this to sorted(status_map.items())
ci/zkasm-result.py
Outdated
for line in sys.stdin: | ||
if "--> fail" in line or "--> pass" in line: | ||
_, _, test_path = line.partition(' ') | ||
test_name = os.path.basename(test_path).split('.')[0] |
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.
The canonical way to do this is:
filename, file_extension = os.path.splitext(os.path.basename('/path/to/somefile.ext'))
# filename == "somefile"
ci/zkasm-result.py
Outdated
print("assert foo") | ||
with open(state_csv_path, newline='') as csvfile: | ||
csvreader = csv.reader(csvfile) | ||
print("csvreader ok") |
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.
Leaving a comment not to forget to remove debug statements before submitting the PR.
ci/zkasm-result.py
Outdated
print('a') | ||
for row in csvreader: | ||
print('b') | ||
if row[0] == "Test" or row[0] == "Total Passed" or row[0] == "Amount of Tests": |
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.
A way to simplify: if row[0] in ["Test", "Total Passed", "Amount of Tests"]:
I suspect this is because we have pipefail set and the first command See https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425#set--o-pipefail |
da32ac4
to
e204a9e
Compare
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.
Let's ship it!
Thanks for review, Andrei! |
Added script to generate
.csv
with spectest results and asserting commited result corresponds actual results in CIFixes #84