-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
draft: sketched out SO interface CI workflow.
- Loading branch information
1 parent
1ff6632
commit df86024
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,15 @@ | ||
|
||
name: interface-ci | ||
on: [pull_request] | ||
|
||
jobs: | ||
check-so-interface: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./tests/ci | ||
steps: | ||
- name: Check out the repository to the runner | ||
uses: actions/checkout@v4 | ||
- name: Check SO interface spec | ||
run: python ./check_so_interface.py |
This file contains 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,34 @@ | ||
import ast | ||
|
||
# functions and their arguments to check | ||
# specified here: https://www.overleaf.com/project/5e837cac9659910001e5f71e | ||
# could move this to a file | ||
interface = { | ||
"python/pysmurf/client/tune/smurf_tune.py": { # file | ||
"SmurfTuneMixin": { # class | ||
"find_freq": [], # function and args | ||
} | ||
}, | ||
} | ||
|
||
def _compare_args(ast_args, spec_args): | ||
# check the arguments in the code match the specification | ||
pass | ||
|
||
if __name__ == "__main__": | ||
for fname, spec in interface.items(): | ||
with open(fname, 'r') as fh: | ||
tree = ast.parse(fh.read()) | ||
|
||
for key in spec: | ||
# check this function/class is in the code | ||
assert key in tree | ||
|
||
# compare its arguments | ||
if isinstance(tree[key], ast.FunctionDef): | ||
assert _compare_args(spec[key], tree[key]) | ||
elif isinstance(tree[key], ast.ClassDef): | ||
# could make this recursive maybe | ||
for meth in spec[key]: | ||
assert meth in tree[key] | ||
assert _compare_args(spec[key][meth], tree[key][meth]) |