From 590380d4ec79d6279e2cb579f53c1a1199cf9f23 Mon Sep 17 00:00:00 2001 From: Emanuele Aina <emanuele.aina@collabora.com> Date: Mon, 25 Apr 2022 10:51:42 +0200 Subject: [PATCH 1/2] Fetch cached data from GitLab itself Retrieving the published data can be complicated on downstream deployment where the data is auth protected. Since GitLab stores it as an artifact accessible using the job token, use it to side-step the issue. Signed-off-by: Emanuele Aina <emanuele.aina@collabora.com> --- .gitlab-ci.yml | 11 ++++++----- localtest | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8bf8959..572ab66 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,7 +18,6 @@ variables: For instance use `*` to process all updates, `dash` to only process `pkg/dash`. Leave it empty to not trigger any update. value: "" - DASHBOARD_DATA: https://infrastructure.pages.apertis.org/dashboard/packaging.yaml stages: - lint @@ -87,15 +86,17 @@ packaging-data-fetch-downstream: wget script: - CACHE_ARGS="" + - ARTIFACT_URL=${ARTIFACT_URL:-$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/artifacts/$CI_DEFAULT_BRANCH/raw/public/packaging.yaml?job=pages} - | - if [ -n "$DASHBOARD_DATA" ] + if [ "$ARTIFACT_URL" != none ] then - wget "$DASHBOARD_DATA" -O packaging.yaml || true + wget --header "JOB-TOKEN: $CI_JOB_TOKEN" "$ARTIFACT_URL" -O cache.yaml fi - | - if [ -f packaging.yaml ] + if [ -e cache.yaml ] then - CACHE_ARGS="--cache packaging.yaml" + echo Load cacheable data from cache.yaml + CACHE_ARGS="--cache cache.yaml" fi - ./bin/packaging-data-fetch-downstream --gitlab-api-token "${DASHBOARD_GITLAB_API_TOKEN}" diff --git a/localtest b/localtest index 336b963..8e6deb3 100755 --- a/localtest +++ b/localtest @@ -42,6 +42,7 @@ if __name__ == "__main__": print("set -eux") print(f"FILTER=pkg/{args.filter_packages or '*'}") + print("ARTIFACT_URL=none") print("TRIGGER_UPDATES=") print("TRIGGER_FROM_JOB=") print("DASHBOARD_OSCRC=") @@ -49,6 +50,7 @@ if __name__ == "__main__": print("CI_SERVER_URL=") print("CI_PROJECT_URL=") print("CI_JOB_URL=") + print("CI_JOB_TOKEN=") print("CI_PIPELINE_URL=") print("CI_COMMIT_REF_NAME=wip/test") if args.loglevel == logging.DEBUG: -- GitLab From 17ca61a5323757a7093d6ca7ff4a223a5bd98e4b Mon Sep 17 00:00:00 2001 From: Emanuele Aina <emanuele.aina@collabora.com> Date: Mon, 25 Apr 2022 17:18:49 +0200 Subject: [PATCH 2/2] fetch-downstream: Log when the cached data is used Ensure a log message is printed when loading the cache to give a clearer context when debugging issues. Signed-off-by: Emanuele Aina <emanuele.aina@collabora.com> --- bin/packaging-data-fetch-downstream | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/packaging-data-fetch-downstream b/bin/packaging-data-fetch-downstream index f78acc5..df1d52e 100755 --- a/bin/packaging-data-fetch-downstream +++ b/bin/packaging-data-fetch-downstream @@ -399,6 +399,7 @@ if __name__ == "__main__": logging.basicConfig(level=args.loglevel or logging.INFO) if args.cache: + logging.info(f"Loading cacheable data from {args.cache.name}") yaml_import = yaml.safe_load(args.cache) try: cache = yaml_import["packages"] -- GitLab