Skip to content

Commit

Permalink
Write implemented tests table to README.md
Browse files Browse the repository at this point in the history
Instead of just printing it to the console, write the table directly to
the README. This also adds a test to ensure that there are no uncommited
changes to the table.
  • Loading branch information
gaudenz committed Jun 28, 2023
1 parent cd067a4 commit 7ae8bcd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@ jobs:

- name: Run Flake8
run: flake8 .

- name: Regenerate tests table
run: invoke implemented-tests-table

- name: Show changes in README.md
run: git diff -- README.md

- name: Verify README.md did not change
run: git status --short -- README.md | grep --invert-match '^ M'
21 changes: 20 additions & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,26 @@ def implemented_tests_table(c):
# Only show the category once per group
cat = None

print(tabulate(rows, headers, tablefmt="github"))
with open('README.md', 'r') as f:
readme = f.read()

test_list_section = False
with open('README.md', 'w') as f:
for l in readme.splitlines(keepends=True):

# While not in the test list section, write out lines
if not test_list_section:
f.write(l)

# Start of the test list section, write out the test list
if l.startswith('## Implemented Tests'):
test_list_section = True
f.write(f'\n{tabulate(rows, headers, tablefmt="github")}\n\n')

# Next section, end of test list section
elif test_list_section and l.startswith('##'):
test_list_section = False
f.write(l)


def format_event_attribute(event, key, value):
Expand Down

0 comments on commit 7ae8bcd

Please sign in to comment.