Skip to contentSkip to conversation

Start using GitLab caching capability

PATCH In review Anthony PERARD 2 participants 7 messages Dec 19, 2019 – Jan 8, 2020

lore
Share & tools
lore
#0 lore raw

cover Start using GitLab caching capability

Patch series available in this git branch:
https://xenbits.xen.org/git-http/people/aperard/xen-unstable.git br.ci-caching-v1

This is only a small improvement to the GitLab CI. It only caches git clone that Xen's makefile creates and not submodules needed by those clones.

It doesn't cache the different tarballs that the makefiles downloads, that could be another improvement.

Cheers,

Anthony PERARD (2):
tools: Allow to make *-dir-force-update without ./configure
automation: Cache sub-project git tree in build jobs

 automation/gitlab-ci/build.yaml     |  8 +++++
 automation/scripts/prepare-cache.sh | 52 +++++++++++++++++++++++++++++
 tools/Rules.mk                      |  3 +-
 3 files changed, 62 insertions(+), 1 deletion(-)
 create mode 100755 automation/scripts/prepare-cache.sh
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

PATCH 1/2 tools: Allow to make *-dir-force-update without ./configure

This also allows to run make src-tarball without first having to run ./configure.

---
 tools/Rules.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/Rules.mk +2 -1
index cf8935d6a3ea..31cf419ef4f5 100644
@@ -239,7 +239,8 @@ subdir-all-% subdir-clean-% subdir-install-% subdir-uninstall-%: .phony
 subdir-distclean-%: .phony
 	$(MAKE) -C $* distclean
 
-ifeq (,$(findstring clean,$(MAKECMDGOALS)))
+no-configure-targets := clean subtree-force-update-all %-dir-force-update
+ifeq (,$(filter $(no-configure-targets),$(MAKECMDGOALS)))
 $(XEN_ROOT)/config/Tools.mk:
 	$(error You have to run ./configure before building or installing the tools)
 endif
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#3 lore raw

PATCH 2/2 automation: Cache sub-project git tree in build jobs

In reply to Anthony PERARD

GitLab have a caching capability, see [1]. Let's use it to avoid using Internet too often.

The cache is setup so that when xen.git/Config.mk is changed, the cache will need to be recreated. This has been chosen because that is where the information about how to clone sub-project trees is encoded (revisions). That may not work for qemu-xen tree which usually is `master', but that should be fine for now.

The cache is populated of "git bundle" which will contain a mirror of the original repo, and can be cloned from. If the bundle exist, the script have the Xen makefiles clone from it, otherwise it will clone from the original URL and the bundles will be created just after.

We have more than one runner in GitLab, and no shared cache between them, so every build jobs will be responsible to create the cache.

[1] https://docs.gitlab.com/ee/ci/yaml/README.html#cache

---
 automation/gitlab-ci/build.yaml     |  8 +++++
 automation/scripts/prepare-cache.sh | 52 +++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)
 create mode 100755 automation/scripts/prepare-cache.sh
automation/gitlab-ci/build.yaml +8 -0
index 1e61d30c8545..8f9f53a4222f 100644
@@ -1,6 +1,14 @@
 .build-tmpl: &build
   stage: build
   image: registry.gitlab.com/xen-project/xen/${CONTAINER}
+  cache:
+    key:
+      files:
+        - Config.mk
+    paths:
+      - ci_cache
+  before_script:
+    - ./automation/scripts/prepare-cache.sh
   script:
     - ./automation/scripts/build 2>&1 | tee build.log
   artifacts:
automation/scripts/prepare-cache.sh new file +52 -0

52 lines not on this page · raw message

Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#4 lore raw

Re: [Xen-devel] [XEN PATCH 2/2] automation: Cache sub-project git tree in build jobs

Quoted 14 lines · Anthony PERARD

GitLab have a caching capability, see [1]. Let's use it to avoid using Internet too often.

The cache is setup so that when xen.git/Config.mk is changed, the cache will need to be recreated. This has been chosen because that is where the information about how to clone sub-project trees is encoded (revisions). That may not work for qemu-xen tree which usually is `master', but that should be fine for now.

The cache is populated of "git bundle" which will contain a mirror of the original repo, and can be cloned from. If the bundle exist, the script have the Xen makefiles clone from it, otherwise it will clone from the original URL and the bundles will be created just after.

Quoted 6 lines

We have more than one runner in GitLab, and no shared cache between them, so every build jobs will be responsible to create the cache.

[1] https://docs.gitlab.com/ee/ci/yaml/README.html#cache

This is a good improvement.

Have you run this in Gitlab CI? Can you point me to a run?

Quoted 34 lines
---
 automation/gitlab-ci/build.yaml     |  8 +++++
 automation/scripts/prepare-cache.sh | 52 +++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)
 create mode 100755 automation/scripts/prepare-cache.sh
automation/gitlab-ci/build.yaml +8 -0
index 1e61d30c8545..8f9f53a4222f 100644
@@ -1,6 +1,14 @@
 .build-tmpl: &build
   stage: build
   image: registry.gitlab.com/xen-project/xen/${CONTAINER}
+  cache:
+    key:
+      files:
+        - Config.mk
+    paths:
+      - ci_cache
+  before_script:
+    - ./automation/scripts/prepare-cache.sh
   script:
     - ./automation/scripts/build 2>&1 | tee build.log
   artifacts:
automation/scripts/prepare-cache.sh new file +3 -0
new file mode 100755
index 000000000000..017f1b8f0672
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+set -ex

automation/scripts/prepare-cache.sh line 13

Quoted 10 lines
automation/scripts/prepare-cache.sh new file +10 -0
+
+cachedir="${CI_PROJECT_DIR:=`pwd`}/ci_cache"
+mkdir -p "$cachedir"
+
+declare -A r
+r[extras/mini-os]=MINIOS_UPSTREAM_URL
+r[tools/qemu-xen-dir]=QEMU_UPSTREAM_URL
+r[tools/qemu-xen-traditional-dir]=QEMU_TRADITIONAL_URL
+r[tools/firmware/ovmf-dir]=OVMF_UPSTREAM_URL
+r[tools/firmware/seabios-dir]=SEABIOS_UPSTREAM_URL

Does this mean if in the future we add or remove trees we will need to modify this part in the same commit?

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw

Re: [Xen-devel] [XEN PATCH 2/2] automation: Cache sub-project git tree in build jobs

Quoted 18 lines · Wei Liu
Quoted 17 lines · Anthony PERARD

GitLab have a caching capability, see [1]. Let's use it to avoid using Internet too often.

The cache is setup so that when xen.git/Config.mk is changed, the cache will need to be recreated. This has been chosen because that is where the information about how to clone sub-project trees is encoded (revisions). That may not work for qemu-xen tree which usually is `master', but that should be fine for now.

The cache is populated of "git bundle" which will contain a mirror of the original repo, and can be cloned from. If the bundle exist, the script have the Xen makefiles clone from it, otherwise it will clone from the original URL and the bundles will be created just after.

We have more than one runner in GitLab, and no shared cache between them, so every build jobs will be responsible to create the cache.

Quoted 7 lines
Quoted 3 lines

[1] https://docs.gitlab.com/ee/ci/yaml/README.html#cache

This is a good improvement.

Have you run this in Gitlab CI? Can you point me to a run?

I have use the CI to develop the patch, so yes I have a run of it. But it is a run made with my wip branch, still it should be the same result if it was done with the final patch:
https://gitlab.com/xen-project/people/anthonyper/xen/pipelines/104343621

Quoted 14 lines
Quoted 14 lines
automation/scripts/prepare-cache.sh new file +8 -0
new file mode 100755
index 000000000000..017f1b8f0672
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+set -ex
+
+cachedir="${CI_PROJECT_DIR:=`pwd`}/ci_cache"
+mkdir -p "$cachedir"
+
+declare -A r
Quoted 8 lines

automation/scripts/prepare-cache.sh line 13

Quoted 5 lines
automation/scripts/prepare-cache.sh new file +5 -0
+r[extras/mini-os]=MINIOS_UPSTREAM_URL
+r[tools/qemu-xen-dir]=QEMU_UPSTREAM_URL
+r[tools/qemu-xen-traditional-dir]=QEMU_TRADITIONAL_URL
+r[tools/firmware/ovmf-dir]=OVMF_UPSTREAM_URL
+r[tools/firmware/seabios-dir]=SEABIOS_UPSTREAM_URL

Does this mean if in the future we add or remove trees we will need to modify this part in the same commit?

We would need to modify the script when trees are removed, because I haven't thought of that. But when trees are added, the script can be changed in a follow-up.

Ideally, we would use the Makefiles to discovers the git clones that can be cached, but that's not possible just yet.

In the mean time, I think I should make the script more robust against removal of trees, so it doesn't have to be modified in the same commit.

Thanks,

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#6 lore raw

Re: [Xen-devel] [XEN PATCH 2/2] automation: Cache sub-project git tree in build jobs

Quoted 23 lines · Anthony PERARD
Quoted 22 lines · Wei Liu
Quoted 20 lines · Anthony PERARD

GitLab have a caching capability, see [1]. Let's use it to avoid using Internet too often.

The cache is setup so that when xen.git/Config.mk is changed, the cache will need to be recreated. This has been chosen because that is where the information about how to clone sub-project trees is encoded (revisions). That may not work for qemu-xen tree which usually is `master', but that should be fine for now.

The cache is populated of "git bundle" which will contain a mirror of the original repo, and can be cloned from. If the bundle exist, the script have the Xen makefiles clone from it, otherwise it will clone from the original URL and the bundles will be created just after.

We have more than one runner in GitLab, and no shared cache between them, so every build jobs will be responsible to create the cache.

[1] https://docs.gitlab.com/ee/ci/yaml/README.html#cache

Quoted 8 lines
Quoted 3 lines

This is a good improvement.

Have you run this in Gitlab CI? Can you point me to a run?

I have use the CI to develop the patch, so yes I have a run of it. But it is a run made with my wip branch, still it should be the same result if it was done with the final patch:
https://gitlab.com/xen-project/people/anthonyper/xen/pipelines/104343621

This looks good to me.

Quoted 28 lines
Quoted 15 lines
Quoted 15 lines
automation/scripts/prepare-cache.sh new file +8 -0
new file mode 100755
index 000000000000..017f1b8f0672
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+set -ex
+
+cachedir="${CI_PROJECT_DIR:=`pwd`}/ci_cache"
+mkdir -p "$cachedir"
+
+declare -A r
Quoted 8 lines

automation/scripts/prepare-cache.sh line 13

Quoted 5 lines
automation/scripts/prepare-cache.sh new file +5 -0
+r[extras/mini-os]=MINIOS_UPSTREAM_URL
+r[tools/qemu-xen-dir]=QEMU_UPSTREAM_URL
+r[tools/qemu-xen-traditional-dir]=QEMU_TRADITIONAL_URL
+r[tools/firmware/ovmf-dir]=OVMF_UPSTREAM_URL
+r[tools/firmware/seabios-dir]=SEABIOS_UPSTREAM_URL

Does this mean if in the future we add or remove trees we will need to modify this part in the same commit?

We would need to modify the script when trees are removed, because I haven't thought of that. But when trees are added, the script can be changed in a follow-up.

Quoted 5 lines

Ideally, we would use the Makefiles to discovers the git clones that can be cached, but that's not possible just yet.

In the mean time, I think I should make the script more robust against removal of trees, so it doesn't have to be modified in the same commit.

OK. I'm expecting a new version then.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel