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

fix: test all file #3

Merged
merged 22 commits into from
Jan 24, 2025
Merged

fix: test all file #3

merged 22 commits into from
Jan 24, 2025

Conversation

thomasBousselin
Copy link
Member

@thomasBousselin thomasBousselin commented Jan 24, 2025

The previous pipeline only tested the last file

@thomasBousselin thomasBousselin marked this pull request as draft January 24, 2025 10:30
@thomasBousselin thomasBousselin changed the title test: break stuff test: break stuff and It only test the last file seen. Jan 24, 2025
@thomasBousselin thomasBousselin changed the title test: break stuff and It only test the last file seen. fix: only test the last file seen. Jan 24, 2025
@thomasBousselin thomasBousselin changed the title fix: only test the last file seen. fix: test all file Jan 24, 2025
@thomasBousselin thomasBousselin marked this pull request as ready for review January 24, 2025 10:50
@thomasBousselin
Copy link
Member Author

@xamcost Forgot the commits name it was just supposed to be a test at the beginning.

Comment on lines 26 to 30
for file in $(find . -name "*.jsonld"); do
printf "Checking $file .. "
jq empty $file && echo "OK"
jq empty $file || exit 1
echo "OK"
done || exit 1
Copy link
Contributor

Choose a reason for hiding this comment

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

@thomasBousselin My bad, my implementation was indeed not exiting with an error if another file than the last one was invalid, sorry about that! Your implementation correct that! However, it stops the loop at the first encountered error, which means that other file would not be checked once one is invalid. My original intention was to check all files and exit with an error if any error is encountered in the loop, but I was wrong. Another way to actually do this would be to build on your solution but exit only with a final check, like this:

error=0
for file in $(find . -name "*.jsonld"); do
  printf "Checking $file .. "
  jq empty $file && echo "OK" || error=1
done

exit $error

That way, all files are checked, even if the first one is invalid, and the code exits with an error if at least one error got raised in the loop. What do you think ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it is better. I have added an echo in case of error for readability.

Copy link
Contributor

@xamcost xamcost left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for this work @thomasBousselin , and for the thorough testing! Have a nice week end ✨

@thomasBousselin
Copy link
Member Author

You to

@thomasBousselin thomasBousselin merged commit 1f69021 into main Jan 24, 2025
1 check passed
@thomasBousselin thomasBousselin deleted the test/break-stuff branch January 24, 2025 15:39
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.

2 participants