fmidue / logic-tasks

0 stars 1 forks source link

Consistency check for .cabal file #117

Closed nimec01 closed 5 months ago

nimec01 commented 6 months ago

This adds a new GitHub Action workflow that checks whether the .cabal file is consistent with the package.yml file.

A sample run can be found here.

jvoigtlaender commented 6 months ago

The linter is still complaining about a few aspects of the workflow file.

Other than that: Have you done some experiments with how it behaves when there are changes (like manually changing the hpack version number mentioned in the .cabal, or changing some compiler option in package.yaml without also changing the .cabal file)?

nimec01 commented 6 months ago

I removed some ghc-options and the workflow correctly detected the mismatch between the files. Manually changing the version in the .cabal file did not lead to a mismatch error.

nimec01 commented 6 months ago

There is one linter error left:

Useless echo? Instead of 'echo $(cmd)', just use 'cmd' 

However, this is a false positive. Changing it to only use cmd breaks the workflow when there is a mismatch between the files.

jvoigtlaender commented 6 months ago

Okay, can you find out how to let the linter ignore that occurrence?

Possibly either using BASH_SEVERITY in https://github.com/fmidue/logic-tasks/blob/4b6373327538fad87a0e2e6bd62d7b9db31e221c/.github/workflows/linter.yml#L29-L32 or adding an edited version of https://github.com/super-linter/super-linter/blob/main/TEMPLATES/.shellcheckrc to the .github/linters directory in this repo.

jvoigtlaender commented 6 months ago

... or GITHUB_ACTIONS_CONFIG_FILE or GITHUB_ACTIONS_COMMAND_ARGS ...

... or simply "disguising" the echo call somehow, so that the linter doesn't see the pattern it is looking for. :smile:

jvoigtlaender commented 6 months ago

Have you seen this? https://github.com/koalaman/shellcheck/wiki/SC2005#exceptions

Maybe the cmd || true suggestion would have been appropriate here.

(Mainly asking because if we take over this PR for other repos, we would now also always have to somewhat globally change the linter configuration, which might be undesirable in some settings.)

nimec01 commented 5 months ago

I think ChatGPT's suggestion led me the wrong way. We can simply call diff [...]. This prints the differences and exits with code 1 if there are any.

I tested it with a consistent and inconsistent .cabal file, and it worked as expected.