-
Notifications
You must be signed in to change notification settings - Fork 9
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reusable Workflow Experiment: Upstreaming commit message checks #28
Reusable Workflow Experiment: Upstreaming commit message checks #28
Conversation
e766cc0
to
96cf0da
Compare
This pull request is now in conflicts. Could you fix it? 馃檹 |
d0ebcb5
to
a05602b
Compare
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 incorporate the changes from #29 . Idea looks nice
The expressions are already present here (rebased after #29 got merged). It'd be great if we can come up with a list of general Checks to add them here at once and go then over the downstream repositories referring to the checks defined here. |
Well, I guess that's the idea of the PR and I like the idea of the PR or what do you mean? |
What checks can be generalized so they apply to all repos? Like the commit message one is a simple task, that's even agnostic of the language. How about
? Addenda:
|
There was an attempt to also put tools/tidy in here, but it's not that trivial because of the way os-autoinst-distri-opensuse is using this script: https://progress.opensuse.org/issues/110142 |
.perltidyrc
Outdated
# # See <https://github.com/houseabsolute/perl-code-tidyall/issues/84>. | ||
--character-encoding=none | ||
--no-valign | ||
# TBD: openqa defines: -l=120 vs -l=160 in os-autoinst-distri-opensuse |
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.
Lets stick to 160, we're not in the 80's anymore, screens are bigger and I don't expect people to do a proper review using their phones.
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.
Despite hearing that argument very often, the restricted line length is not about the screen width, but also about horizontal eye movement, and additionally side by side diff views are harder with longer lines.
But in my team I'm in the minority, most prefer longer lines anyway ;-)
bin/perlcritic
Outdated
# This script will either be called directly from this project or symlinked from | ||
# downstream projects. | ||
|
||
OS_AUTOINST_COMMONS_DIR=$(dirname $(dirname $(readlink -e "$0"))) |
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.
why the double dirname?
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.
readlink $0
will resolve the path of the specific file including symlinks.
that's a/b/c/os-autoinst-common/bin/perlcritic
but we need what's on a/b/c/os-autoinst-common/lib/perlcritic
.
First dirname
deletes perlcritic
, the second deletes bin
and we end up with the desired path.
See:
dirname a/b/c/os-autoinst-common/bin/perlcritic
#> a/b/c/os-autoinst-common/bin
dirname a/b/c/os-autoinst-common/bin
#> a/b/c/os-autoinst-common
bin/tidyall
Outdated
printf STDERR "Please install the appropriate version of perltidy.\n"; | ||
printf STDERR "If you want to proceed anyways, re run with --force flag.\n"; |
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 this can be formatted to make it pop up on GH workflows (https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message)
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.
This is a local-only tool, tools/tidy
is not run in any workflow that I can find, perlcritic
does through run_unit_tests.sh
and Makefile targets.
The idea is that is a transparent wrapper over tidyall
so no special text processing is needed on ever divergent bash scripts.
In this implementation, how When it's not installed then:
If a more graceful error is expected, maybe beginning with: eval { require Perl::Tidy; };
if($@){
die "Perl::Tidy is not installed";
} Would allow to report more gracefully that perltidy is not installed? I lean towards avoiding it. The setup guides should get each developer to a point where all perl dependencies are installed properly. |
bin/tidyall
Outdated
@@ -0,0 +1,32 @@ | |||
#!/usr/bin/env perl |
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.
tidyall
is a script provided by the perl module Code::TidyAll, so I think creating a script with the same name is unfortunate.
Like I said, tidyall provides tidy tools for several languages/tools, including perltidy.
We use it mainly because it has a caching functionality, so it is faster to use locally.
In CI we are using https://github.com/os-autoinst/openQA/blob/master/t/00-tidy.t and https://github.com/os-autoinst/os-autoinst/blob/master/xt/00-tidy.t (and yes, it's unfortunate that they are different :)
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'm very open to suggestions on naming, the goal with this is to minimize scattering across repos and differences.
from your examples I see two ways of approaching linter checks:
- Run it as a test in
t/
(which I guessprove
runs). - Run it as a standalone command (which is what the
openQA
version is doing).
I simplified the latter, as I see there are may versions of the same script. But I don't know if either of the versions is more or less beneficial.
I guess it's also team agreement on which strategy to pick.
IMHO: I lean for the standalone command because it looks more similar to how other stacks work:
- in Ruby you'd install dependencies &
bundle exec rubocop
- in Python you'd install dependencies, virtualenv [with your favourite virtualenv tool] &
{black|flake8|pylint}
. - in JS you install dependencies &
eslint
.
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.
But I'm also wondering about other things.
I use tools/tidy -o
to only tidy changed files.
Also it has a check-only mode.
And tools for development shouldn't be in bin/
, as this is usually the directory that contains scripts that are packaged.
.perltidyrc
Outdated
@@ -0,0 +1,18 @@ | |||
# Workaround needed for handling non-ASCII in files. |
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.
See https://github.com/os-autoinst/os-autoinst/blob/master/xt/00-tidy.t vs. https://github.com/os-autoinst/openQA/blob/master/.perltidyrc
So we would have to decide about which config we want to use in the future.
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.
Looks like tidyall_ok
uses the default config file:
looks like it'd be a matter of providing this one as a symlink and that would be it ?
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.
Yeah, the point is, if we use the symlink to this one here, we would first need to decide which of the two different configs we want.
I think it's better if we do that first by providing single PRs to both repos with the suggested new config and look at the tidy changes, so we can decide.
Can you please make seperate pull requests for all these concerns? The sharing of the workflow was a good idea and seems to work. The other things are a bit more complicated because some things are also used from os-autoinst-distri-opensuse. |
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 like the overall approach very much but I don't think it's feasible to bring in all those rules at once. Let's please start with the common ground of git commit message check and see that this is applied in all relevant downstream projects first. Then we can extend to tidy+perlcritic, etc. You can keep this PR as is and split out the git commit message check for a start into a separate PR and then rebase here, ok?
6677812
to
f06acfe
Compare
This pull request is now in conflicts. Could you fix it? 馃檹 |
e0f2008
to
797d222
Compare
- Bringing checks from os-autoinst/openQA#5343. - Setting up reusable workflows [0]. [0]: https://docs.github.com/en/actions/using-workflows/reusing-workflows Reusable Workflow Experiment: Upstreaming commit message checks - Bringing checks from os-autoinst/openQA#5343. - Setting up reusable workflows [0]. [0]: https://docs.github.com/en/actions/using-workflows/reusing-workflows
797d222
to
d23cda4
Compare
Done, took a bit of problems with my local copy but it's there. There's one thing that doesn't look quite right: the workflow for commit needs an approval. That's a fairly trivial check that can run automatically. Any idea how to make that? Nothing in the YAML's says anything about manual workflows |
For everyone who does their first contribution on a github repo, workflow runs need to be approved. This was introduced by Github a while ago to prevent crypto miners from using resources. |
This is an experiment 馃ゼ
First Error:
There's a successful schedule of the check: https://github.com/os-autoinst/os-autoinst-common/actions/runs/6626891884
Proposed Agreement:
base-%{check-name}.yml
into.github/workflows
.%{check-name}.yml
in.github/workflows
.Reusable Workflow usage on downstream repos: