-
Notifications
You must be signed in to change notification settings - Fork 18
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
Enable perlcritic checks in CI #31
Conversation
I think the git commit message checker can be replaced with what we have in openQA: https://github.com/os-autoinst/openQA/blob/master/.github/workflows/commit-message-checker.yml |
i guess the errors are not by my PR??! |
I think the isotovideo tests have been broken for a long time. I don't know anything about them, I think they were even there before I joined. Maybe someone else can say something about it, but I would say they can be ignored for this PR. |
i will have to take a look on that |
.github/workflows/check_critic.yml
Outdated
run: | | ||
git config --global --add safe.directory '*' | ||
zypper -n install perl-Perl-Critic | ||
perlcritic $(git ls-files -- '*.p[ml]') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wonder whether i have to use https://github.com/os-autoinst/os-autoinst-common/blob/master/tools/perlcritic somehow here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe @josegomezr or @okurz can answer that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perlcritic
kinda "knows" what's a perl file, you can pass just the directories where it needs to be invoked.
In fact, the check is in the files you're pulling from os-autoinst-common
. Use that as much as possible.
# [...]
container:
image: perldocker/perl-tester # this is now provided by os_autoinst dev container iirc
steps:
- uses: actions/checkout@v4
- run: ./tools/perlcritic --quiet
# [...]
Yes, the isotovideo checks were failing before as @perlpunk mentioned. And for the commit message check see her comment as well. |
b560bfc
to
e7d9ba1
Compare
subrepo: subdir: "external/os-autoinst-common" merged: "e167bdf" upstream: origin: "https://github.com/os-autoinst/os-autoinst-common.git" branch: "master" commit: "e167bdf" git-subrepo: version: "0.4.6" origin: "???" commit: "???" Signed-off-by: ybonatakis <[email protected]>
Run perlcritic against all the perl git files. https://progress.opensuse.org/issues/138416 Signed-off-by: ybonatakis <[email protected]>
`.tidyallrc` doesnt work properly as a symlink, thus the new file is an actual copy from the external/os-autoinst-common. Signed-off-by: ybonatakis <[email protected]>
0a11b01
to
a4b69f8
Compare
please do not merge yet. I am working on isotovideo failures |
Yeah, you don't need to fix the isotovideo tests in this PR. sorry if that wasn't clear |
Signed-off-by: ybonatakis <[email protected]>
f269a41
to
3946b97
Compare
isotovideo-action.yml uses a isotovideo version with already jq installed. fixed grep which excluded the expected output in success and changed logical and to logical or, which will reached when grep fails. Signed-off-by: ybonatakis <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice that you've also been able to fix the isotovideo checks.
run: podman run --rm -it -v .:/tests:Z --entrypoint '' registry.opensuse.org/devel/openqa/containers/isotovideo:qemu-x86-jq /bin/sh -c 'isotovideo qemu_no_kvm=1 casedir=/tests && jq .result testresults/result-*.json | grep -v ok && echo "Test modules failed" && exit 1' | ||
env: | ||
image: registry.opensuse.org/devel/openqa/containers/isotovideo:qemu-x86-jq | ||
isotovideo: isotovideo qemu_no_kvm=1 casedir=/tests | ||
jq_filter: jq .result testresults/result-*.json | ||
err_msg: Test modules failed | ||
run: docker run --rm -it -v .:/tests:Z --entrypoint '' $image /bin/sh -c '$isotovideo && $jq_filter | grep ok || (echo "$err_msg" && exit 1)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this change related to perlcritic checks?
Is the switch from podman to docker intended? I thought podman is the preferred way.
Also, you probably do not want the exit in subshell and rather use grep ok || { echo "$err_msg" && exit 1; }
- name: Validate yamls | ||
run: | | ||
git config --global --add safe.directory '*' | ||
yamllint --strict $(git ls-files "*.yml" "*.yaml" 2> /dev/null || find . -name '*.y*ml') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*.y*ml
will match a lot of different things, maybe you want find . -name '*.yaml' -o -name '*.yml'
to have closer match to the list used in git? Also 2> /dev/null
might be good addition for the find as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yamllint actually has a configuration file where you can specify the matching glob, and by default it will match .yaml and .yml.
You only need to pass it a directory name.
Please just use the same as in here https://github.com/os-autoinst/os-autoinst-common/blob/master/.github/workflows/yamllint.yml
@@ -9,11 +9,9 @@ jobs: | |||
image: "registry.opensuse.org/devel/openqa/containers/isotovideo:qemu-x86-jq" | |||
steps: | |||
- uses: actions/checkout@v2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also change the action to actions/checkout@v4
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That change should get rid of the deprecation warning seen in https://github.com/os-autoinst/os-autoinst-distri-example/actions/runs/7831480244
|
||
- name: fail if any test module failed | ||
run: jq .result testresults/result-*.json | grep -v ok && echo "Test modules failed" && exit 1 | ||
run: jq .result testresults/result-*.json | grep ok || (echo "Test modules failed" && exit 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned elsewhere, you probably do not want subshell here, the exit will only exit the subshell.
grep ok || { echo "Test modules failed" && exit 1; }
@@ -8,4 +8,4 @@ jobs: | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- name: Run isotovideo against test code in happy-path scenario | |||
run: podman run --rm -it -v .:/tests:Z registry.opensuse.org/devel/openqa/containers/isotovideo:qemu-x86 qemu_no_kvm=1 casedir=/tests | |||
run: docker run --rm -v .:/tests:Z registry.opensuse.org/devel/openqa/containers/isotovideo:qemu-x86 qemu_no_kvm=1 casedir=/tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the removal of -i
and -t
, why the podman -> docker change?
registry.opensuse.org/devel/openqa/containers/isotovideo:qemu-x86-jq /bin/sh \ | ||
-c 'isotovideo qemu_no_kvm=1 casedir=/tests \ | ||
&& jq .result testresults/result-*.json | grep ok \ | ||
|| (echo "Test modules failed" && exit 1)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again the subshell.
|
||
- name: fail if any test module failed | ||
run: jq .result testresults/result-*.json | grep -v ok && echo "Test modules failed" && exit 1 | ||
run: jq .result testresults/result-*.json | grep ok || (echo "Test modules failed" && exit 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously the grep was looking for any line not matching ok
, so any failed test would make the workflow fail.
Now you are only ensuring that there is at least one line matching ok
. So there could be failed modules and it would still succeed.
I don't know how many testmodules this workflow runs, but I think the logic should be kept as before, or look at @josegomezr ' PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks for commenting that. I also noticed that but forget to note down that grep -v ok
is not the exact opposite of grep ok
(I got sidetracked by the subshell 😄 ). I also vote for the previous logic; I believe the motivation was to avoid the non-zero exit code provided by grep on "success". We might want to use grep -v ok && { echo "Test modules failed" && exit 1; } || true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are already a lot of comments in this PR, so I suggest to keep the isotovideo checks out of here. It's unrelated and should be in its own PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please split this PR into separate ones based on the commits you created. Consider https://progress.opensuse.org/projects/qa/wiki/Tools#Collaboration-best-practices
After that I would like to review the individual parts in more details
this is outdated. other PRs provided and merged |
Run perlcritic against all the perl git files.