Skip to content

Commit

Permalink
Add Python code lint check
Browse files Browse the repository at this point in the history
This updates the avocado-static-check submodule, and implements the
changes necessary to have the lint checks passing.

Signed-off-by: Cleber Rosa <[email protected]>
  • Loading branch information
clebergnu committed Feb 22, 2024
1 parent 09199b9 commit 3e67b7b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/modules-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
run: pip3 install avocado-framework==102.0

- name: Run the ar module test
run: ./tests/test-module.py metadata/autils/archive/ar.yml
run: ./tests/test_module.py metadata/autils/archive/ar.yml

static-checks:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/schema-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
uses: actions/checkout@v3

- name: Validating all libraries against our schema
run: python3 tests/validate-schema.py
run: python3 tests/validate_schema.py
5 changes: 3 additions & 2 deletions autils/archive/ar.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def __next__(self):
member = struct.unpack(
FILE_HEADER_FMT, open_file.read(FILE_HEADER_SIZE)
)
except struct.error:
raise StopIteration
except struct.error as exc:
raise StopIteration from exc

# No support for extended file names
identifier = member[0].decode("ascii").strip()
Expand All @@ -105,3 +105,4 @@ def read_member(self, identifier):
with self as open_file:
open_file.seek(member.offset)
return open_file.read(member.size)
return None
2 changes: 1 addition & 1 deletion static-checks
4 changes: 2 additions & 2 deletions tests/test-module.py → tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"Fedora 37": "fedora:37",
}

metadata_path = sys.argv[1]
with open(metadata_path, "rb") as m:
METADATA_PATH = sys.argv[1]
with open(METADATA_PATH, "rb") as m:
metadata = yaml.load(m, Loader=yaml.SafeLoader)

test_suites = []
Expand Down
2 changes: 2 additions & 0 deletions tests/validate-schema.py → tests/validate_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def validate_yaml(filename, schema):


def validate_yamls():
"""Validates all yamls in the repo against the autils schema."""
print("Starting validation...")
failed = False
for file in glob.glob("./metadata/autils/*/*.yml"):
Expand All @@ -53,6 +54,7 @@ def validate_yamls():
return 1

print("All files passed validation.")
return 0


if __name__ == "__main__":
Expand Down

0 comments on commit 3e67b7b

Please sign in to comment.