Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python code lint check #19

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/modules-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@ jobs:
uses: actions/checkout@v3

- name: Install Avocado to run tests
run: pip3 install avocado-framework==102.0
run: pip3 install 'avocado-framework<104.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
steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Install Avocado to allow for lint check on Python code under tests directory
run: pip3 install 'avocado-framework<104.0'

- name: run static checks
uses: avocado-framework/avocado-ci-tools@main
with:
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
Loading