Skip to content

Commit

Permalink
draft: sketched out SO interface CI workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
tristpinsm committed Sep 24, 2024
1 parent 1ff6632 commit df86024
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/interface_ci.yml
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
34 changes: 34 additions & 0 deletions tests/ci/check_so_interface.py
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])

0 comments on commit df86024

Please sign in to comment.