[libvirt PATCH 00/33] ci: Unify the GitLab CI jobs with local executions && adopt lcitool container executions

Erik Skultety posted 33 patches 8 months, 1 week ago
Failed in applying to current master (apply log)
There is a newer version of this series
.gitlab-ci.yml |  47 +++++++------
ci/build.sh    | 105 +++++++++++++++++++++++++----
ci/helper      | 176 ++++++++++++++++++++++++++++---------------------
3 files changed, 218 insertions(+), 110 deletions(-)
[libvirt PATCH 00/33] ci: Unify the GitLab CI jobs with local executions && adopt lcitool container executions
Posted by Erik Skultety 8 months, 1 week ago
Technically a v2 of:
https://listman.redhat.com/archives/libvir-list/2023-February/237552.html

However, the approach here is slightly different and what that series said
about migration to lcitool container executions as a replacement for
ci/Makefile is actually done here. One of the core problems of the above
pointed out in review was that more Shell logic was introduced including CLI
parsing, conditional executions, etc. which we fought hard to get rid of in the
past. I reworked the Shell functions quite a bit and dropped whatever extra
Shell logic the original series added.
Obviously we can't get rid of Shell completely because of .gitlab-ci.yml and so
I merely extracted the recipes into functions which are then sourced as
ci/build.sh and executed. Now, that on its own would hide the actual commands
being run in the GitLab job log, so before any command is actually executed, it
is formatted with a color sequence so we don't miss that information as that
would be a regression to the status quo.

Lastly, this series then takes the effort inside the ci/build.sh script and
basically mirrors whatever GitLab would do to run a job inside a local
container which is executed by lcitool (yes, we already have that capability).

Please give this a try and I'm already looking forward to comments as I'd like
to expand this effort to local VM executions running the TCK integration tests,
so this series is quite important in that regard.

Erik Skultety (33):
  ci: build.sh: Add variables from .gitlab-ci.yml
  ci: build.sh: Add GIT_ROOT env helper variable
  ci: build.sh: Don't mention that MESON_ARGS are available via CLI
  ci: build.sh: Add a wrapper function over meson's setup
  ci: build.sh: Add a wrapper function executing 'shell' commands
  ci: build.sh: Add a wrapper function over the 'build' job
  ci: build.sh: Add a helper function to create the dist tarball
  ci: build.sh: Add a wrapper function over the 'test' job
  ci: build.sh: Add a wrapper function over the 'codestyle' job
  ci: build.sh: Add a wrapper function over the 'potfile' job
  ci: build.sh: Add a wrapper function over the 'rpmbuild' job
  ci: build.sh: Add a wrapper function over the 'website' job
  ci: build.sh: Drop changing working directory to CI_CONT_DIR
  ci: build.sh: Drop direct invocation of meson/ninja commands
  ci: build.sh: Drop MESON_ARGS definition from global level
  gitlab-ci.yml: Add 'after_script' stage to prep for artifact
    collection
  .gitlab-ci.yml: Convert the native build job to the build.sh usage
  .gitlab-ci.yml: Convert the cross build job to the build.sh usage
  .gitlab-ci.yml: Convert the website build job to the build.sh usage
  .gitlab-ci.yml: Convert the codestyle job to the build.sh usage
  .gitlab-ci.yml: Convert the potfile job to the build.sh usage
  ci: helper: Drop _lcitool_get_targets method
  ci: helper: Don't make ':' literal a static part of the image tag
  ci: helper: Add --lcitool-path CLI option
  ci: helper: Add a job argparse subparser
  ci: helper: Add a required_deps higher order helper/decorator
  ci: helper: Add Python code hangling git clones
  ci: helper: Add a helper to create a local repo clone Pythonic way
  ci: helper: Rework _lcitool_run method logic
  ci: helper: Add an action to run the container workload via lcitool
  ci: helper: Drop original actions
  ci: helper: Drop the --meson-args/--ninja-args CLI options
  ci: helper: Drop the _make_run method

 .gitlab-ci.yml |  47 +++++++------
 ci/build.sh    | 105 +++++++++++++++++++++++++----
 ci/helper      | 176 ++++++++++++++++++++++++++++---------------------
 3 files changed, 218 insertions(+), 110 deletions(-)

-- 
2.41.0
Re: [libvirt PATCH 00/33] ci: Unify the GitLab CI jobs with local executions && adopt lcitool container executions
Posted by Daniel P. Berrangé 8 months, 1 week ago
On Fri, Aug 25, 2023 at 07:55:08PM +0200, Erik Skultety wrote:
> Technically a v2 of:
> https://listman.redhat.com/archives/libvir-list/2023-February/237552.html
> 
> However, the approach here is slightly different and what that series said
> about migration to lcitool container executions as a replacement for
> ci/Makefile is actually done here. One of the core problems of the above
> pointed out in review was that more Shell logic was introduced including CLI
> parsing, conditional executions, etc. which we fought hard to get rid of in the
> past. I reworked the Shell functions quite a bit and dropped whatever extra
> Shell logic the original series added.
> Obviously we can't get rid of Shell completely because of .gitlab-ci.yml and so
> I merely extracted the recipes into functions which are then sourced as
> ci/build.sh and executed. Now, that on its own would hide the actual commands
> being run in the GitLab job log, so before any command is actually executed, it
> is formatted with a color sequence so we don't miss that information as that
> would be a regression to the status quo.
> 
> Lastly, this series then takes the effort inside the ci/build.sh script and
> basically mirrors whatever GitLab would do to run a job inside a local
> container which is executed by lcitool (yes, we already have that capability).
> 
> Please give this a try and I'm already looking forward to comments as I'd like
> to expand this effort to local VM executions running the TCK integration tests,
> so this series is quite important in that regard.

Do you have a gitlab branch with this contnt somewhere. When i tried to
apply the patches to current git, it was unhappy on the 3rd patch

$ git am -3 ~/cibuild
Applying: ci: build.sh: Add variables from .gitlab-ci.yml
Applying: ci: build.sh: Add GIT_ROOT env helper variable
Applying: ci: build.sh: Don't mention that MESON_ARGS are available via CLI
error: sha1 information is lacking or useless (ci/build.sh).
error: could not build fake ancestor
Patch failed at 0003 ci: build.sh: Don't mention that MESON_ARGS are available via CLI
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Re: [libvirt PATCH 00/33] ci: Unify the GitLab CI jobs with local executions && adopt lcitool container executions
Posted by Erik Skultety 8 months ago
On Thu, Aug 31, 2023 at 05:17:13PM +0100, Daniel P. Berrangé wrote:
> On Fri, Aug 25, 2023 at 07:55:08PM +0200, Erik Skultety wrote:
> > Technically a v2 of:
> > https://listman.redhat.com/archives/libvir-list/2023-February/237552.html
> > 
> > However, the approach here is slightly different and what that series said
> > about migration to lcitool container executions as a replacement for
> > ci/Makefile is actually done here. One of the core problems of the above
> > pointed out in review was that more Shell logic was introduced including CLI
> > parsing, conditional executions, etc. which we fought hard to get rid of in the
> > past. I reworked the Shell functions quite a bit and dropped whatever extra
> > Shell logic the original series added.
> > Obviously we can't get rid of Shell completely because of .gitlab-ci.yml and so
> > I merely extracted the recipes into functions which are then sourced as
> > ci/build.sh and executed. Now, that on its own would hide the actual commands
> > being run in the GitLab job log, so before any command is actually executed, it
> > is formatted with a color sequence so we don't miss that information as that
> > would be a regression to the status quo.
> > 
> > Lastly, this series then takes the effort inside the ci/build.sh script and
> > basically mirrors whatever GitLab would do to run a job inside a local
> > container which is executed by lcitool (yes, we already have that capability).
> > 
> > Please give this a try and I'm already looking forward to comments as I'd like
> > to expand this effort to local VM executions running the TCK integration tests,
> > so this series is quite important in that regard.
> 
> Do you have a gitlab branch with this contnt somewhere. When i tried to
> apply the patches to current git, it was unhappy on the 3rd patch
> 
> $ git am -3 ~/cibuild
> Applying: ci: build.sh: Add variables from .gitlab-ci.yml
> Applying: ci: build.sh: Add GIT_ROOT env helper variable
> Applying: ci: build.sh: Don't mention that MESON_ARGS are available via CLI
> error: sha1 information is lacking or useless (ci/build.sh).
> error: could not build fake ancestor
> Patch failed at 0003 ci: build.sh: Don't mention that MESON_ARGS are available via CLI
> hint: Use 'git am --show-current-patch=diff' to see the failed patch
> When you have resolved this problem, run "git am --continue".
> If you prefer to skip this patch, run "git am --skip" instead.
> To restore the original branch and stop patching, run "git am --abort".

Yeah, I had a different merge conflict locally, but I guess both related to
b68d253c4603a041cb993fa133ba25e610a78929 not having been pushed yet and the
time I posted the series.

Here's the fixed branch:
https://gitlab.com/eskultety/libvirt/-/commits/helper-lcitool

And here's a pipeline (with the fix posted for patch 11):
https://gitlab.com/eskultety/libvirt/-/pipelines/988871113

Erik

Re: [libvirt PATCH 00/33] ci: Unify the GitLab CI jobs with local executions && adopt lcitool container executions
Posted by Daniel P. Berrangé 8 months ago
On Fri, Sep 01, 2023 at 11:21:04AM +0200, Erik Skultety wrote:
> On Thu, Aug 31, 2023 at 05:17:13PM +0100, Daniel P. Berrangé wrote:
> > On Fri, Aug 25, 2023 at 07:55:08PM +0200, Erik Skultety wrote:
> > > Technically a v2 of:
> > > https://listman.redhat.com/archives/libvir-list/2023-February/237552.html
> > > 
> > > However, the approach here is slightly different and what that series said
> > > about migration to lcitool container executions as a replacement for
> > > ci/Makefile is actually done here. One of the core problems of the above
> > > pointed out in review was that more Shell logic was introduced including CLI
> > > parsing, conditional executions, etc. which we fought hard to get rid of in the
> > > past. I reworked the Shell functions quite a bit and dropped whatever extra
> > > Shell logic the original series added.
> > > Obviously we can't get rid of Shell completely because of .gitlab-ci.yml and so
> > > I merely extracted the recipes into functions which are then sourced as
> > > ci/build.sh and executed. Now, that on its own would hide the actual commands
> > > being run in the GitLab job log, so before any command is actually executed, it
> > > is formatted with a color sequence so we don't miss that information as that
> > > would be a regression to the status quo.
> > > 
> > > Lastly, this series then takes the effort inside the ci/build.sh script and
> > > basically mirrors whatever GitLab would do to run a job inside a local
> > > container which is executed by lcitool (yes, we already have that capability).
> > > 
> > > Please give this a try and I'm already looking forward to comments as I'd like
> > > to expand this effort to local VM executions running the TCK integration tests,
> > > so this series is quite important in that regard.
> > 
> > Do you have a gitlab branch with this contnt somewhere. When i tried to
> > apply the patches to current git, it was unhappy on the 3rd patch
> > 
> > $ git am -3 ~/cibuild
> > Applying: ci: build.sh: Add variables from .gitlab-ci.yml
> > Applying: ci: build.sh: Add GIT_ROOT env helper variable
> > Applying: ci: build.sh: Don't mention that MESON_ARGS are available via CLI
> > error: sha1 information is lacking or useless (ci/build.sh).
> > error: could not build fake ancestor
> > Patch failed at 0003 ci: build.sh: Don't mention that MESON_ARGS are available via CLI
> > hint: Use 'git am --show-current-patch=diff' to see the failed patch
> > When you have resolved this problem, run "git am --continue".
> > If you prefer to skip this patch, run "git am --skip" instead.
> > To restore the original branch and stop patching, run "git am --abort".
> 
> Yeah, I had a different merge conflict locally, but I guess both related to
> b68d253c4603a041cb993fa133ba25e610a78929 not having been pushed yet and the
> time I posted the series.

Yeah, I eventually figured out b68d253c4603a041cb993fa133ba25e610a78929 was
the problem and applied your series before that commit to test it.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Re: [libvirt PATCH 00/33] ci: Unify the GitLab CI jobs with local executions && adopt lcitool container executions
Posted by Daniel P. Berrangé 8 months, 1 week ago
On Fri, Aug 25, 2023 at 07:55:08PM +0200, Erik Skultety wrote:
> Technically a v2 of:
> https://listman.redhat.com/archives/libvir-list/2023-February/237552.html
> 
> However, the approach here is slightly different and what that series said
> about migration to lcitool container executions as a replacement for
> ci/Makefile is actually done here. One of the core problems of the above
> pointed out in review was that more Shell logic was introduced including CLI
> parsing, conditional executions, etc. which we fought hard to get rid of in the
> past. I reworked the Shell functions quite a bit and dropped whatever extra
> Shell logic the original series added.
> Obviously we can't get rid of Shell completely because of .gitlab-ci.yml and so
> I merely extracted the recipes into functions which are then sourced as
> ci/build.sh and executed. Now, that on its own would hide the actual commands
> being run in the GitLab job log, so before any command is actually executed, it
> is formatted with a color sequence so we don't miss that information as that
> would be a regression to the status quo.
> 
> Lastly, this series then takes the effort inside the ci/build.sh script and
> basically mirrors whatever GitLab would do to run a job inside a local
> container which is executed by lcitool (yes, we already have that capability).
> 
> Please give this a try and I'm already looking forward to comments as I'd like
> to expand this effort to local VM executions running the TCK integration tests,
> so this series is quite important in that regard.

Overall I'm fine with what's proposed here.

Two general thoughts

 * ci/Makefile appears pretty much redundant - ci/helper can provide
   the same level of functionality AFAICT, and it'd be nice to kill
   an outstanding usage of 'make' given our goal to standardize on
   meson + python

 * ci/helper looks almost entirely independent of libvirt, aside
   from the list of 'choices' for the --job arg, and the --namespace
   arg default value, it would work with any virt project we have if
   the project created its own ci/build.sh file

   Can we fold all its logic into lcitool, and just have that as
   the entrypoint ? In ci/manifest.yml we can get the project
   namespace, and we could possibly just extra the commands by
   crudely regex matching 'ci/build.sh' content against the
   pattern '^run_.*\(\)$ {'


The removal of ci/Makefil feels like it could be done in this series,
but its fine if the ci/helper suggestion is left as separate future
work.


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Re: [libvirt PATCH 00/33] ci: Unify the GitLab CI jobs with local executions && adopt lcitool container executions
Posted by Erik Skultety 8 months ago
On Thu, Aug 31, 2023 at 06:28:16PM +0100, Daniel P. Berrangé wrote:
> On Fri, Aug 25, 2023 at 07:55:08PM +0200, Erik Skultety wrote:
> > Technically a v2 of:
> > https://listman.redhat.com/archives/libvir-list/2023-February/237552.html
> > 
> > However, the approach here is slightly different and what that series said
> > about migration to lcitool container executions as a replacement for
> > ci/Makefile is actually done here. One of the core problems of the above
> > pointed out in review was that more Shell logic was introduced including CLI
> > parsing, conditional executions, etc. which we fought hard to get rid of in the
> > past. I reworked the Shell functions quite a bit and dropped whatever extra
> > Shell logic the original series added.
> > Obviously we can't get rid of Shell completely because of .gitlab-ci.yml and so
> > I merely extracted the recipes into functions which are then sourced as
> > ci/build.sh and executed. Now, that on its own would hide the actual commands
> > being run in the GitLab job log, so before any command is actually executed, it
> > is formatted with a color sequence so we don't miss that information as that
> > would be a regression to the status quo.
> > 
> > Lastly, this series then takes the effort inside the ci/build.sh script and
> > basically mirrors whatever GitLab would do to run a job inside a local
> > container which is executed by lcitool (yes, we already have that capability).
> > 
> > Please give this a try and I'm already looking forward to comments as I'd like
> > to expand this effort to local VM executions running the TCK integration tests,
> > so this series is quite important in that regard.
> 
> Overall I'm fine with what's proposed here.
> 
> Two general thoughts
> 
>  * ci/Makefile appears pretty much redundant - ci/helper can provide
>    the same level of functionality AFAICT, and it'd be nice to kill
>    an outstanding usage of 'make' given our goal to standardize on
>    meson + python

Huh, the fact that removal of Makefile isn't part of this series is a mistake
on my side - I worked on this on 2 parallel branches trying out 2 slightly
different approaches. I did drop it on one branch but not the other which I
ultimately decided to go with. Since I'll be sending a v2, I'll add that patch.

> 
>  * ci/helper looks almost entirely independent of libvirt, aside
>    from the list of 'choices' for the --job arg, and the --namespace
>    arg default value, it would work with any virt project we have if
>    the project created its own ci/build.sh file
> 
>    Can we fold all its logic into lcitool, and just have that as
>    the entrypoint ? In ci/manifest.yml we can get the project
>    namespace, and we could possibly just extra the commands by
>    crudely regex matching 'ci/build.sh' content against the
>    pattern '^run_.*\(\)$ {'

Technically we could. Extracting the code and injecting it into lcitool is not
a problem, in fact, it would be quite straight forward. The problem is
designing a CLI interface that would make sense for the use case without
breaking the existing one too much. Ideally by introducing just a bunch of
optional args which I don't think is very realistic. Since that will require
thorough thinking and designing I did not want to dive right into that as I
wasn't even sure whether I'd be able to push this conversion through upstream.

> 
> 
> The removal of ci/Makefil feels like it could be done in this series,
> but its fine if the ci/helper suggestion is left as separate future
> work.

Yeah, like I said above, incorporating ci/helper into lcitool is likely going
to be again one of the bigger overhauls so that will be a project on its own.

Thanks for the comments, much appreciated.

Erik