-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* *: add missing FCC variant/version * ign-storage: use valid SHA-512 hash to pass FCC validation * storage: fix [storage,yaml] delimiter * Add script to validate all FCCs in docs * workflows: add workflow to validate FCCs
- Loading branch information
Showing
7 changed files
with
86 additions
and
7 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,18 @@ | ||
--- | ||
name: Checks | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
|
||
jobs: | ||
fcc: | ||
name: Validate FCCs | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v2 | ||
- name: Run validator | ||
run: ./check.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,53 @@ | ||
#!/usr/bin/python3 | ||
# | ||
# Find all FCCs in the doc tree, use the podman FCCT container to run them | ||
# through fcct --strict, and fail on any errors. | ||
# | ||
# An FCC looks like this: | ||
# | ||
# [source,yaml] | ||
# ---- | ||
# variant:[...] | ||
# ---- | ||
# | ||
# If variant: is missing, we print a warning but continue, since there | ||
# might be non-FCC [source,yaml] documents. | ||
|
||
import os | ||
import re | ||
import subprocess | ||
import sys | ||
import textwrap | ||
|
||
container = os.getenv('FCCT_CONTAINER', 'quay.io/coreos/fcct:release') | ||
matcher = re.compile(r'^\[source,\s*yaml\]\n----\n(.+?\n)----$', re.MULTILINE | re.DOTALL) | ||
|
||
def handle_error(e): | ||
raise e | ||
|
||
ret = 0 | ||
for dirpath, _, filenames in os.walk('.', onerror=handle_error): | ||
for filename in filenames: | ||
filepath = os.path.join(dirpath, filename) | ||
if not filename.endswith('.adoc'): | ||
continue | ||
with open(filepath) as fh: | ||
filedata = fh.read() | ||
# Iterate over YAML source blocks | ||
for match in matcher.finditer(filedata): | ||
fcc = match.group(1) | ||
fccline = filedata.count('\n', 0, match.start(1)) + 1 | ||
if not fcc.startswith('variant:'): | ||
print(f'Ignoring non-FCC at {filepath} line {fccline}') | ||
continue | ||
result = subprocess.run( | ||
['podman', 'run', '--rm', '-i', container, '--strict'], | ||
universal_newlines=True, # can be spelled "text" on >= 3.7 | ||
input=fcc, | ||
stdout=subprocess.DEVNULL, | ||
stderr=subprocess.PIPE) | ||
if result.returncode != 0: | ||
formatted = textwrap.indent(result.stderr.strip(), ' ') | ||
print(f'Invalid FCC at {filepath} line {fccline}:\n{formatted}') | ||
ret = 1 | ||
sys.exit(ret) |
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
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
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
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
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