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

Check for uncommitted files beyond the diff directory #278

Merged
merged 1 commit into from Jul 25, 2023

Conversation

jeffwidman
Copy link
Member

@jeffwidman jeffwidman commented Nov 2, 2022

This removes the indirection of the bash script so that it's immediately clear from the github action definition file what is being checked. Currently the logic is split between the action which does the rebuild and the bash script which checks the diff.

It also checks for any delta in the git repo, not just the dist/ directory. Any change should fail CI until it's either committed or added to .gitignore.

@jeffwidman jeffwidman requested a review from a team as a code owner November 2, 2022 21:30
@@ -31,5 +32,7 @@ jobs:
- name: Rebuild the dist/ directory
run: npm run build

- name: Compare the expected and actual dist/ directories
run: bin/check-diff
Copy link
Contributor

Choose a reason for hiding this comment

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

As I recall, the intent of using this script was to have the Check Run show the diff on failure so you didn't need to run it on your machine to see what the issue was.

This was useful as we had environment-specific issues early on where the Typescript compile wasn't properly encapsulated and produced a diff on Actions, but none locally.

It also checks for any delta in the git repo, not just the dist/ directory. Any change should fail CI until it's either committed or added to .gitignore.

That's fair - I don't have a strong opinion on this, I think it was originally just the dist/ directory to keep the CI build focused on verifying the distributed code as any other changes were less impactful.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is useful, so I kept it, and then augmented with another job that looks for any other uncommitted files.

retVal=$?
if [ $retVal -ne 0 ]; then
echo "Detected uncommitted changes after build:"
git --no-pager diff dist/
Copy link
Contributor

@brrygrdn brrygrdn Nov 3, 2022

Choose a reason for hiding this comment

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

The contents of the diff/ folder are marked as generated so this was just to ensure we spat out the actual change in the obfuscated JS.

@jeffwidman
Copy link
Member Author

Hmm... I'm really not sure what to do here, as @brrygrdn raises good points, but I'm still not excited by having a separate script... that said, movign the bin/check-diff code in seems a bit complicated. And probably best to ensure we do check all files, not just dist/...

I'll let this float a bit long in case anyone else has opinions, otherwise I'll probably either close this or leave existing code as-is, but add a follow-on step so that if there are no changes in dist/ to ensure no other uncommitted changes elsewhere either...

I guess what also could be helpful here is a few more code comments in the source so that someone down the road doesn't open a PR on this either.

@jeffwidman jeffwidman force-pushed the replace-check-diff-with-a-one-liner branch from cd41e39 to 02f6890 Compare July 21, 2023 18:25
Copy link
Member Author

Choose a reason for hiding this comment

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

Code didn't change in this script, only renamed it and added code comments for improved clarity.

@jeffwidman jeffwidman changed the title Replace bin/check-diff with a one-liner Check for uncommitted files beyond the diff directory Jul 21, 2023
@jeffwidman
Copy link
Member Author

I updated based on @brrygrdn 's helpful context/feedback.

This is ready for another review.

Copy link
Contributor

@brrygrdn brrygrdn left a comment

Choose a reason for hiding this comment

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

🚀

This checks for _any_ delta in the git repo, not just the `dist/`
directory. Any change should fail CI until it's either committed or
added to `.gitignore`.

Additionally, I clarified the script name/code slightly to explain why
it's needed/handled separately from checking for uncommitted files.
@jeffwidman jeffwidman force-pushed the replace-check-diff-with-a-one-liner branch from 02f6890 to de83502 Compare July 25, 2023 16:17
@jeffwidman jeffwidman enabled auto-merge (squash) July 25, 2023 16:17
@jeffwidman jeffwidman merged commit 06df9f8 into main Jul 25, 2023
6 checks passed
@jeffwidman jeffwidman deleted the replace-check-diff-with-a-one-liner branch July 25, 2023 16:18
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.

None yet

3 participants