Skip to content

Validated SPEC fields uppon PR and commit #173

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

Merged
merged 5 commits into from
Dec 8, 2022
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
39 changes: 39 additions & 0 deletions .github/workflows/validate-spec-fields.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Validate SPEC fields
on:
pull_request:
push:
branches:
- main

jobs:
pytest:
name: Validate SPEC fields
runs-on: ubuntu-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
steps:
- uses: actions/checkout@master

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.10'

- uses: docker-practice/actions-setup-docker@master

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -

- name: Install Dev requirements
run: |
pip install -U setuptools wheel
pip install -r dev_requirements.txt

- name: Install Dependencies
run: |
poetry install

- name: Validate SPEC fields
run: |
poetry run redis-benchmarks-spec-cli --tool stats --fail-on-required-diff
6 changes: 6 additions & 0 deletions redis_benchmarks_specification/__cli__/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ def spec_cli_args(parser):
action="store_true",
help="Override test specs.",
)
parser.add_argument(
"--fail-on-required-diff",
default=False,
action="store_true",
help="Fail tool when there is difference between required parameters.",
)
parser.add_argument(
"--push-stats-redis",
default=False,
Expand Down
17 changes: 16 additions & 1 deletion redis_benchmarks_specification/__cli__/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,15 @@ def generate_stats_cli_command_logic(args, project_name, project_version):
)
)
tracked_groups = []
override_enabled = args.override_tests
fail_on_required_diff = args.fail_on_required_diff
overall_result = True
for test_file in testsuite_spec_files:
benchmark_config = {}
requires_override = False
override_enabled = args.override_tests
test_result = True
with open(test_file, "r") as stream:

try:
benchmark_config = yaml.safe_load(stream)
test_name = benchmark_config["name"]
Expand Down Expand Up @@ -126,8 +130,13 @@ def generate_stats_cli_command_logic(args, project_name, project_version):
test_file, e.__str__()
)
)
test_result = False
pass

if requires_override:
test_result = False
overall_result &= test_result

if requires_override and override_enabled:
logging.info(
"Saving a new version of the file {} with the overrided data".format(
Expand All @@ -146,6 +155,12 @@ def generate_stats_cli_command_logic(args, project_name, project_version):
total_tracked_groups = len(tracked_groups)
logging.info("Total tracked groups: {}".format(total_tracked_groups))

if overall_result is False and fail_on_required_diff:
logging.error(
"Failing given there were changes required to be made and --fail-on-required-diff was enabled"
)
exit(1)

if args.commandstats_csv != "":
logging.info(
"Reading commandstats csv {} to determine commands/test coverage".format(
Expand Down