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

Shellcheck and shfmt on bash scripts #204

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

KaushikMalapati
Copy link
Contributor

Description

I accidentally changed the branch for the old pr #184 which automatically closed it, so I am making a new one.
I added a pre-commit job for shfmt which will automatically format bash scripts and went through all existing shellcheck errors/warnings that the existing job raises. I am disabling some warnings globally in .shellcheckrc and on a line-by-line basis in a few files.

Motivation and Context

#182
To standardize style and fix existing shellcheck issues so that future contributors only see pre-commit/workflow errors related to their changes instead of what was already there.

How Has This Been Tested?

Interactively

Where Has This Been Documented?

N/A

Copy link
Member

@ZLLentz ZLLentz left a comment

Choose a reason for hiding this comment

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

Partial review - made it up through checkcnf and found most things look very clean!
I'll resume my review either later or tomorrow depending on how things go

scripts/afs-remote-fix Outdated Show resolved Hide resolved
scripts/camViewer Outdated Show resolved Hide resolved
@tangkong
Copy link
Contributor

If I understand correctly, this is a re-creation of the previous shellcheck PR we spent some time reviewing before right? Or were there other changes made in addition? If I recall correctly, our main issue was that this touched a lot of files and we don't have a great way of regression testing the changes made here (short of manually testing the scripts).

I still think this looks largely un-problematic, though I might feel better if we approached this in pieces. Or maybe we just rip off the bandaid and make sure we're ready to hotfix any unexpected breaks

@ZLLentz
Copy link
Member

ZLLentz commented Oct 1, 2024

The main differences I see between this and previous are the addition of the shfmt pre-commit and applying fixes to files added since the last PR. I'm going to continue reviewing.

Copy link
Member

@ZLLentz ZLLentz left a comment

Choose a reason for hiding this comment

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

The only issue I found with the reformat here is the duplication of the python script
This is still super scary to merge but maybe it's time to just do it

I'm making issues for the other things I found

scripts/configdb_readxtc Show resolved Hide resolved
scripts/serverStat Show resolved Hide resolved
scripts/set_gem_timing Show resolved Hide resolved
Copy link
Contributor

@tangkong tangkong left a comment

Choose a reason for hiding this comment

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

I tried to keep a high-level view on these scripts, lacking the same bash-fu that Zach has. I reviewed most of this, but my brain did start to melt

I had a few questions, most of which are probably better addressed as followup issues

rc/bashrc Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we deprecate this in favor of our shared dotfiles?

Copy link
Member

Choose a reason for hiding this comment

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

I think we should, or we could at least include instructions in here for updating to the full shared dotfiles. This is a reasonable follow-up issue.

scripts/archive-status Show resolved Hide resolved
scripts/configdb_readxtc Outdated Show resolved Hide resolved
scripts/new_bare_repo Outdated Show resolved Hide resolved
scripts/pcds_conda Show resolved Hide resolved
scripts/set_gem_timing Show resolved Hide resolved
scripts/startami Show resolved Hide resolved
@ZLLentz
Copy link
Member

ZLLentz commented Oct 2, 2024

I think this is good if anyone is brave enough to merge it

@tangkong
Copy link
Contributor

tangkong commented Oct 3, 2024

I'm scared tbh. After we merge, should we tag/update asap to get people using these scripts? This will be the root of many a merge conflict I'm sure

@silkenelson
Copy link
Collaborator

I have a pull request to add needed functionality to makepeds which failed pre-commit which will have to resolved and I don't even have the time to fix the current problems.
Would there be a chance to not push changes to 56 files at the same time, in particular during operations? We need to make operational needed changes and I'm also concerned this will be messy.

@ZLLentz
Copy link
Member

ZLLentz commented Oct 3, 2024

Silke, this repo is not gating merges on pre-commit failures, they are currently optional, so for your PR you should proceed as normal given the time investment possible. The only merge requirement here is "one passing review".

For this PR I suspect we want to at least test the scripts that have gotten more than surface-level (whitespace) edits. Maybe the next step for this one is to collect the scripts that need to be re-tested.

@KaushikMalapati
Copy link
Contributor Author

I think these scripts should be retested

  • camViewer
  • ioctool
  • ipmConfigEpics
  • makepeds
  • makepeds_psana
  • motorInfo
  • pcds_conda
  • restartdaq
  • serverStat
  • startami
  • wherepsana

@ZLLentz
Copy link
Member

ZLLentz commented Oct 7, 2024

I skimmed the PR again and I think I agree with those choices, some may not necessarily need it but it's better to be thorough.
The only questions are then:

  • Who should test these? Maybe we can split up the work a bit?
  • How should each be tested?
  • Do we need to split up the PR to get in the simple ones first, or is that not worth the effort?

@tangkong
Copy link
Contributor

tangkong commented Oct 7, 2024

I'm in favor of splitting these up, which to me doesn't sound like too much git-fu but I realize it could be annoying.

I can't say that I'd be very useful in testing these scripts, but I do dream of a day when the test procedure is a little more robust than "run the script and see if it breaks". I assume there's been no real testing procedure in place? Is there even a way to test these without building mock services for all the things these scripts touch?

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.

4 participants