From fd97d05b540b20836e00210cd91eb8af2cbe17f5 Mon Sep 17 00:00:00 2001 From: "Xuan (Sean) Hu" Date: Tue, 7 May 2024 16:04:03 +0800 Subject: [PATCH] ci: enable cache in GitLab CI/CD (#529) --- .gitlab/workflows/ci.yml | 7 +++++++ .gitlab/workflows/release.yml | 8 ++++++++ .../workflows/ci.yml.jinja | 7 +++++++ .../workflows/release.yml.jinja | 8 ++++++++ 4 files changed, 30 insertions(+) diff --git a/.gitlab/workflows/ci.yml b/.gitlab/workflows/ci.yml index 21d0090d..29ac5f6f 100644 --- a/.gitlab/workflows/ci.yml +++ b/.gitlab/workflows/ci.yml @@ -4,6 +4,13 @@ ci: coverage_report: coverage_format: cobertura path: coverage.xml + cache: + paths: + - .venv + key: + files: + - pdm.lock + prefix: venv-${PYTHON_VERSION} coverage: /(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/ image: ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} interruptible: true diff --git a/.gitlab/workflows/release.yml b/.gitlab/workflows/release.yml index 736f2dfa..b279803a 100644 --- a/.gitlab/workflows/release.yml +++ b/.gitlab/workflows/release.yml @@ -4,6 +4,14 @@ pages-build: - public - docs/changelog.md - release-notes.md + cache: + paths: + - .venv + key: + files: + - pdm.lock + prefix: venv-${PYTHON_VERSION} + policy: pull rules: - if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/ script: diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja index 7c8bc5e4..f8e5ef16 100644 --- a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja +++ b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja @@ -5,6 +5,13 @@ ci: coverage_report: coverage_format: cobertura path: coverage.xml + cache: + paths: + - .venv + key: + files: + - pdm.lock + prefix: venv-${PYTHON_VERSION} coverage: /(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/ image: ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} interruptible: true diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja index e98392be..eda5da8c 100644 --- a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja +++ b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja @@ -5,6 +5,14 @@ pages-build: - public - docs/changelog.md - release-notes.md + cache: + paths: + - .venv + key: + files: + - pdm.lock + prefix: venv-${PYTHON_VERSION} + policy: pull rules: - if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/ script: