Skip to content

Commit 20fd146

Browse files
Validated SPEC fields uppon PR and commit (#173)
* Bumping version from 0.1.60 to 0.1.61 * Validated SPEC fields uppon PR and commit * Removed validate spec condition * Removed validate spec condition
1 parent cfb7e8d commit 20fd146

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Validate SPEC fields
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
pytest:
10+
name: Validate SPEC fields
11+
runs-on: ubuntu-latest
12+
env:
13+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
14+
steps:
15+
- uses: actions/checkout@master
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v1
19+
with:
20+
python-version: '3.10'
21+
22+
- uses: docker-practice/actions-setup-docker@master
23+
24+
- name: Install Poetry
25+
run: |
26+
curl -sSL https://install.python-poetry.org | python3 -
27+
28+
- name: Install Dev requirements
29+
run: |
30+
pip install -U setuptools wheel
31+
pip install -r dev_requirements.txt
32+
33+
- name: Install Dependencies
34+
run: |
35+
poetry install
36+
37+
- name: Validate SPEC fields
38+
run: |
39+
poetry run redis-benchmarks-spec-cli --tool stats --fail-on-required-diff

redis_benchmarks_specification/__cli__/args.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ def spec_cli_args(parser):
4040
action="store_true",
4141
help="Override test specs.",
4242
)
43+
parser.add_argument(
44+
"--fail-on-required-diff",
45+
default=False,
46+
action="store_true",
47+
help="Fail tool when there is difference between required parameters.",
48+
)
4349
parser.add_argument(
4450
"--push-stats-redis",
4551
default=False,

redis_benchmarks_specification/__cli__/stats.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@ def generate_stats_cli_command_logic(args, project_name, project_version):
4444
)
4545
)
4646
tracked_groups = []
47+
override_enabled = args.override_tests
48+
fail_on_required_diff = args.fail_on_required_diff
49+
overall_result = True
4750
for test_file in testsuite_spec_files:
4851
benchmark_config = {}
4952
requires_override = False
50-
override_enabled = args.override_tests
53+
test_result = True
5154
with open(test_file, "r") as stream:
55+
5256
try:
5357
benchmark_config = yaml.safe_load(stream)
5458
test_name = benchmark_config["name"]
@@ -126,8 +130,13 @@ def generate_stats_cli_command_logic(args, project_name, project_version):
126130
test_file, e.__str__()
127131
)
128132
)
133+
test_result = False
129134
pass
130135

136+
if requires_override:
137+
test_result = False
138+
overall_result &= test_result
139+
131140
if requires_override and override_enabled:
132141
logging.info(
133142
"Saving a new version of the file {} with the overrided data".format(
@@ -146,6 +155,12 @@ def generate_stats_cli_command_logic(args, project_name, project_version):
146155
total_tracked_groups = len(tracked_groups)
147156
logging.info("Total tracked groups: {}".format(total_tracked_groups))
148157

158+
if overall_result is False and fail_on_required_diff:
159+
logging.error(
160+
"Failing given there were changes required to be made and --fail-on-required-diff was enabled"
161+
)
162+
exit(1)
163+
149164
if args.commandstats_csv != "":
150165
logging.info(
151166
"Reading commandstats csv {} to determine commands/test coverage".format(

0 commit comments

Comments
 (0)