diff mbox series

[XEN,v2,3/3] CI: New stage "containers" to rebuild some containers

Message ID 20241119101449.49747-4-anthony.perard@vates.tech (mailing list archive)
State New
Headers show
Series CI: Allow automatic rebuild of rolling release containers | expand

Commit Message

Anthony PERARD Nov. 19, 2024, 10:15 a.m. UTC
Rebuild rolling release containers when XEN_CI_REBUILD_CONTAINERS is
set. This is to be use with a scheduled pipeline.

Signed-off-by: Anthony PERARD <anthony.perard@vates.tech>
---

Notes:
    v2:
    - remove the logic to test containers once rebuilt.
    - only include the config with jobs for the "containers" stage wen
      XEN_CI_REBUILD_CONTAINERS is set.

 .gitlab-ci.yml                       | 16 ++++++++++++---
 automation/gitlab-ci/containers.yaml | 29 ++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 3 deletions(-)
 create mode 100644 automation/gitlab-ci/containers.yaml

Comments

Stefano Stabellini Nov. 19, 2024, 9:47 p.m. UTC | #1
On Tue, 19 Nov 2024, Anthony PERARD wrote:
> Rebuild rolling release containers when XEN_CI_REBUILD_CONTAINERS is
> set. This is to be use with a scheduled pipeline.
> 
> Signed-off-by: Anthony PERARD <anthony.perard@vates.tech>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
> 
> Notes:
>     v2:
>     - remove the logic to test containers once rebuilt.
>     - only include the config with jobs for the "containers" stage wen
>       XEN_CI_REBUILD_CONTAINERS is set.
> 
>  .gitlab-ci.yml                       | 16 ++++++++++++---
>  automation/gitlab-ci/containers.yaml | 29 ++++++++++++++++++++++++++++
>  2 files changed, 42 insertions(+), 3 deletions(-)
>  create mode 100644 automation/gitlab-ci/containers.yaml
> 
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index 941e5822e8..5a9b8b7228 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -8,11 +8,21 @@ workflow:
>      - when: always
>  
>  stages:
> +  - containers
>    - analyze
>    - build
>    - test
>  
>  include:
> -  - 'automation/gitlab-ci/analyze.yaml'
> -  - 'automation/gitlab-ci/build.yaml'
> -  - 'automation/gitlab-ci/test.yaml'
> +  - local: 'automation/gitlab-ci/containers.yaml'
> +    rules:
> +      - if: $XEN_CI_REBUILD_CONTAINERS
> +  - local: 'automation/gitlab-ci/analyze.yaml'
> +    rules:
> +      - if: $XEN_CI_REBUILD_CONTAINERS == null
> +  - local: 'automation/gitlab-ci/build.yaml'
> +    rules:
> +      - if: $XEN_CI_REBUILD_CONTAINERS == null
> +  - local: 'automation/gitlab-ci/test.yaml'
> +    rules:
> +      - if: $XEN_CI_REBUILD_CONTAINERS == null
> diff --git a/automation/gitlab-ci/containers.yaml b/automation/gitlab-ci/containers.yaml
> new file mode 100644
> index 0000000000..25e8bdc34b
> --- /dev/null
> +++ b/automation/gitlab-ci/containers.yaml
> @@ -0,0 +1,29 @@
> +.container-build-tmpl:
> +  stage: containers
> +  image: docker:stable
> +  tags:
> +    - container-builder
> +  rules:
> +    - if: $XEN_CI_REBUILD_CONTAINERS
> +  services:
> +    - docker:dind
> +  before_script:
> +    - apk add make
> +    - docker info
> +    - docker login -u $CI_DEPLOY_USER -p $CI_DEPLOY_PASSWORD $CI_REGISTRY
> +  script:
> +    - make -C automation/build PUSH=1 REGISTRY=${XEN_REGISTRY} ${CONTAINER/:/\/}
> +  after_script:
> +    - docker logout
> +
> +container-archlinux-current:
> +  extends:
> +    - .container-build-tmpl
> +  variables:
> +    CONTAINER: "archlinux:current"
> +
> +container-opensuse-tumbleweed-x86_64:
> +  extends:
> +    - .container-build-tmpl
> +  variables:
> +    CONTAINER: "opensuse:tumbleweed-x86_64"
> -- 
> 
> 
> Anthony Perard | Vates XCP-ng Developer
> 
> XCP-ng & Xen Orchestra - Vates solutions
> 
> web: https://vates.tech
>
Anthony PERARD Nov. 20, 2024, 10:36 a.m. UTC | #2
On Tue, Nov 19, 2024 at 01:47:16PM -0800, Stefano Stabellini wrote:
> On Tue, 19 Nov 2024, Anthony PERARD wrote:
> > Rebuild rolling release containers when XEN_CI_REBUILD_CONTAINERS is
> > set. This is to be use with a scheduled pipeline.
> > 
> > Signed-off-by: Anthony PERARD <anthony.perard@vates.tech>
> 
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

Thanks!

I've scheduled a pipeline to run once a month so the Arch Linux and
Tumbleweed containers we'll get rebuilt regularly. Both container are
already up-to-date because I failed to use a different registry during
one of my test, but the build-jobs still works.

Cheers,
diff mbox series

Patch

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 941e5822e8..5a9b8b7228 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -8,11 +8,21 @@  workflow:
     - when: always
 
 stages:
+  - containers
   - analyze
   - build
   - test
 
 include:
-  - 'automation/gitlab-ci/analyze.yaml'
-  - 'automation/gitlab-ci/build.yaml'
-  - 'automation/gitlab-ci/test.yaml'
+  - local: 'automation/gitlab-ci/containers.yaml'
+    rules:
+      - if: $XEN_CI_REBUILD_CONTAINERS
+  - local: 'automation/gitlab-ci/analyze.yaml'
+    rules:
+      - if: $XEN_CI_REBUILD_CONTAINERS == null
+  - local: 'automation/gitlab-ci/build.yaml'
+    rules:
+      - if: $XEN_CI_REBUILD_CONTAINERS == null
+  - local: 'automation/gitlab-ci/test.yaml'
+    rules:
+      - if: $XEN_CI_REBUILD_CONTAINERS == null
diff --git a/automation/gitlab-ci/containers.yaml b/automation/gitlab-ci/containers.yaml
new file mode 100644
index 0000000000..25e8bdc34b
--- /dev/null
+++ b/automation/gitlab-ci/containers.yaml
@@ -0,0 +1,29 @@ 
+.container-build-tmpl:
+  stage: containers
+  image: docker:stable
+  tags:
+    - container-builder
+  rules:
+    - if: $XEN_CI_REBUILD_CONTAINERS
+  services:
+    - docker:dind
+  before_script:
+    - apk add make
+    - docker info
+    - docker login -u $CI_DEPLOY_USER -p $CI_DEPLOY_PASSWORD $CI_REGISTRY
+  script:
+    - make -C automation/build PUSH=1 REGISTRY=${XEN_REGISTRY} ${CONTAINER/:/\/}
+  after_script:
+    - docker logout
+
+container-archlinux-current:
+  extends:
+    - .container-build-tmpl
+  variables:
+    CONTAINER: "archlinux:current"
+
+container-opensuse-tumbleweed-x86_64:
+  extends:
+    - .container-build-tmpl
+  variables:
+    CONTAINER: "opensuse:tumbleweed-x86_64"