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

improved uuid checks on commit hook and make targets #3855

Merged
merged 1 commit into from
Sep 27, 2016

Conversation

rochacbruno
Copy link
Contributor

@rochacbruno rochacbruno commented Sep 23, 2016

Following recommendations from our meeting.

  • Put the fix uuids scripts all together in a single file
  • Now there is only make uuid-check and make uuid-fix
  • make install-commit-hook includes a call to uuid-fix to fix id issues also can-i-push? to check if everyhting is ok
  • added check for @id:xyz missing whitespace after : as in @id: xyz
  • flake8 will be checked only for modified files
  • travis will run check-uuid again once PR is sent

TODO:

  • Automatically include uuid on all tests which misses @id (currently we need to keep an empty one to be filled)
  • Move all that logic to testimony itself as it is already checking for tags issues and there is issue opened there. Improve Testimony token validation testimony#121

@rochacbruno rochacbruno added the in progress This issue is being worked on label Sep 23, 2016
@coveralls
Copy link

coveralls commented Sep 23, 2016

Coverage Status

Coverage remained the same at 73.814% when pulling 75cd9d5 on rochacbruno:makefile_improvements into 7ca6664 on SatelliteQE:master.

@rochacbruno rochacbruno added review and removed in progress This issue is being worked on labels Sep 23, 2016
@rochacbruno rochacbruno self-assigned this Sep 23, 2016
@oshtaier
Copy link
Contributor

ACK. Missed all that shell magic, but as far as I see two files were just merged into one

@rochacbruno
Copy link
Contributor Author

@oshtaier regex + grep + sed = magic

Copy link
Member

@omaciel omaciel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I want to suggest is this: can we make the @id: token a constant and use it throughout the entire solution? We may want to change from @id: to :id: in the near future, and having a constant would help :)

@@ -3,19 +3,21 @@
# This script checks duplicated or empty uuids and exit with 1 if found

# finds occurrences of empty @id: testimony tags
grep -E -i -r -n "@id:(.+[[:blank:]]|$)" tests/foreman/
grep -E -i -r -n "@id:(.+[[:blank:]]|$)" tests/foreman/ --include=*.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

fi

# Finds occurrences of @id: in testimony tags then
# sort the output and filters only the duplicated
# then looks for existence of "@id:" in final output
# NOTE: can't print the line number -n here because of uniq -d
grep -r -i "@id:" tests/foreman/ | sort | uniq -d | grep "@id:"
grep -r -i "@id:" tests/foreman/ --include=*.py | sort | uniq -d | grep "@id:"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if [ -n "$EMPTY_IDS" ]; then
echo "Generating new UUIDS for empty @id tags..."
else
echo "No empty @id was found"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to explicitly exit here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to exit here because I want the other checks in script to work until the end of the script.

# iterate if any empty @id found
for output_line in $EMPTY_IDS
do
if (echo "$output_line" | grep "tests/foreman"); then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this check required? Your grep is already pointing at tests/foreman so I expect that all lines would have this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to include it here because in some cases grep output have been wrapped, but I can try different approach.


flake8:
$(info "Checking style and syntax errors with flake8 linter...")
@flake8 . --show-source
@flake8 $(shell git diff --name-only) --show-source
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good change, but I feel that it is more suitable for travis and commit hook other than checking local changes, I mean I will not be able to run make flake8 for files that I have not added to git yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elyezer should I change the target name to gitflake or add a new target?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, that is a personal preference but if others don't worry about it then it is fine to leave instead of creating a separated target.

I've just pointed some of the usecase I personally have.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to gitflake8

exit 1
else
echo "No @id missing spaces after : was found"
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing new line at the end of this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

@elyezer
Copy link
Contributor

elyezer commented Sep 26, 2016

My comments are not a blocker, also don't wait for me to get this merged.

@rochacbruno rochacbruno force-pushed the makefile_improvements branch 3 times, most recently from d82c1ba to b1f8baf Compare September 27, 2016 02:29
@rochacbruno
Copy link
Contributor Author

@omaciel token changed to $ID_TOKEN constant

@elyezer your comments addressed

@coveralls
Copy link

Coverage Status

Coverage remained the same at 73.814% when pulling b1f8baf on rochacbruno:makefile_improvements into dbc1609 on SatelliteQE:master.

@elyezer
Copy link
Contributor

elyezer commented Sep 27, 2016

Thank you @rochacbruno, will leave to @omaciel have a second look before merging.

@omaciel
Copy link
Member

omaciel commented Sep 27, 2016

@rochacbruno

2016-09-27 11:47:39 < omaciel> brunorocha|brb: about https://github.com/SatelliteQE/robottelo/pull/3855 I see that 
                               $ID_TOKEN is defined in 2 scripts. Perhaps it could be defined in one place and 
                               sourced in the other 2 scripts?

@rochacbruno
Copy link
Contributor Author

@omaciel fixed! I merged the solution in a single script fix_uuids.sh which now accepts a --check argument to run in check only mode. So we have now the $ID_TOKEN defined in a single place and a single script to maintain.

@coveralls
Copy link

coveralls commented Sep 27, 2016

Coverage Status

Coverage remained the same at 73.828% when pulling 1230c10 on rochacbruno:makefile_improvements into 65ab63a on SatelliteQE:master.

@omaciel omaciel merged commit be8d271 into SatelliteQE:master Sep 27, 2016
@omaciel omaciel removed the review label Sep 27, 2016
@rochacbruno rochacbruno deleted the makefile_improvements branch September 28, 2016 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants