From 98803c56de2582827e192f2f56b35a2d64a5cfe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moreno=20i=20Caireta=2C=20I=C3=B1igo?= <inigo.moreno@tecnalia.com> Date: Thu, 23 Sep 2021 15:11:56 +0200 Subject: [PATCH] Resolve "Support LFS in templates" --- ci-templates/README.adoc | 7 ++++++- ci-templates/examples/include_lfs.yml | 5 +++++ ci-templates/lfs-pull.yml | 12 ++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 ci-templates/examples/include_lfs.yml create mode 100644 ci-templates/lfs-pull.yml diff --git a/ci-templates/README.adoc b/ci-templates/README.adoc index d4f1a0d..f99eb2c 100644 --- a/ci-templates/README.adoc +++ b/ci-templates/README.adoc @@ -28,7 +28,6 @@ The Core pipeline, defined in link:ci-templates/core.yml[], has the following st * Check files have no trailing whitespace and are `UTF-8` encoded * Check that `C++` files follow this link:clang-format[] -It is important to note that both templates set the variable `GIT_LFS_SKIP_SMUDGE`, which means that when the repositories are cloned/fetched, the files hosted using Git LFS will not be downloaded. An example on how to explicitely fetch the files from LFS can be found in the https://git.code.tecnalia.com/tecnalia_robotics/common_config/blob/e93dbe6379d94e6a895a33c59bf17ccab26eacf9/.gitlab-ci.yml#L132[common_config repository]. == Manual Jobs @@ -52,3 +51,9 @@ The auto rules also allow for using variables to explicitely activate each job: ```yml include::examples/build_vars.yml[] ``` + +== LFS +By default, lfs files are not downloaded. If you need to add LFS, include the link:ci-templates/lfs-pull.yml[] along with anything else: +```yml +include::examples/include_lfs.yml[] +``` \ No newline at end of file diff --git a/ci-templates/examples/include_lfs.yml b/ci-templates/examples/include_lfs.yml new file mode 100644 index 0000000..4808de9 --- /dev/null +++ b/ci-templates/examples/include_lfs.yml @@ -0,0 +1,5 @@ +include: + - project: tecnalia_robotics-public/gitlab_templates + file: + - ci-templates/auto-rules/kinetic-default.yml + - ci-templates/lfs-pull.yml diff --git a/ci-templates/lfs-pull.yml b/ci-templates/lfs-pull.yml new file mode 100644 index 0000000..f311da4 --- /dev/null +++ b/ci-templates/lfs-pull.yml @@ -0,0 +1,12 @@ +.lfs-pull-script: &lfs-pull-script + "find $$current_ws -type f -name .lfsconfig -execdir git lfs pull \\; ;\ + find $$current_ws -type f -name .lfsconfig -execdir git lfs ls-files \\; ;" + +.industrial_ci: + variables: + AFTER_INIT: "bash <(curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh);\ + apt install -qq -y git-lfs; \ + git config --global credential.helper store; \ + echo https://$ARTIFACT_CI_USER:$ARTIFACT_CI_TOKEN@artifact.tecnalia.com > ~/.git-credentials ;" + BEFORE_INSTALL_TARGET_DEPENDENCIES: *lfs-pull-script + BEFORE_INSTALL_UPSTREAM_DEPENDENCIES: *lfs-pull-script -- GitLab