From 5d1a8b4cfbb397210879e8932c5c0e51a72239e6 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sun, 12 May 2024 19:13:18 +0800 Subject: [PATCH] CI: Set environment cache key based on current week of year to avoid outdated cache in the "Setup Micromamba" step (#3234) --- .github/workflows/ci_docs.yml | 6 ++++++ .github/workflows/ci_tests.yaml | 6 ++++++ .github/workflows/ci_tests_dev.yaml | 6 ++++++ .github/workflows/ci_tests_legacy.yaml | 2 -- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_docs.yml b/.github/workflows/ci_docs.yml index 4f886a67b69..ae16cdad084 100644 --- a/.github/workflows/ci_docs.yml +++ b/.github/workflows/ci_docs.yml @@ -74,6 +74,10 @@ jobs: # fetch all history so that setuptools-scm works fetch-depth: 0 + - name: Get current week number of year + id: date + run: echo "date=$(date +%Y-W%W)" >> $GITHUB_OUTPUT # e.g., 2024-W19 + # Install Micromamba with conda-forge dependencies - name: Setup Micromamba uses: mamba-org/setup-micromamba@v1.8.1 @@ -85,6 +89,8 @@ jobs: - nodefaults cache-downloads: false cache-environment: true + # environment cache is persistent for one week. + cache-environment-key: micromamba-environment-${{ steps.date.outputs.date }} create-args: >- python=3.12 gmt=6.5.0 diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index 5c6ec2c948e..edced909a0f 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -99,6 +99,10 @@ jobs: # fetch all history so that setuptools-scm works fetch-depth: 0 + - name: Get current week number of year + id: date + run: echo "date=$(date +%Y-W%W)" >> $GITHUB_OUTPUT # e.g., 2024-W19 + # Install Micromamba with conda-forge dependencies - name: Setup Micromamba uses: mamba-org/setup-micromamba@v1.8.1 @@ -110,6 +114,8 @@ jobs: - nodefaults cache-downloads: false cache-environment: true + # environment cache is persistent for one week. + cache-environment-key: micromamba-environment-${{ steps.date.outputs.date }} create-args: >- python=${{ matrix.python-version }}${{ matrix.optional-packages }} gmt=6.5.0 diff --git a/.github/workflows/ci_tests_dev.yaml b/.github/workflows/ci_tests_dev.yaml index 020e08ec958..f7505109348 100644 --- a/.github/workflows/ci_tests_dev.yaml +++ b/.github/workflows/ci_tests_dev.yaml @@ -52,6 +52,10 @@ jobs: # fetch all history so that setuptools-scm works fetch-depth: 0 + - name: Get current week number of year + id: date + run: echo "date=$(date +%Y-W%W)" >> $GITHUB_OUTPUT # e.g., 2024-W19 + # Install Micromamba with conda-forge dependencies - name: Setup Micromamba uses: mamba-org/setup-micromamba@v1.8.1 @@ -63,6 +67,8 @@ jobs: - nodefaults cache-downloads: false cache-environment: true + # environment cache is persistent for one week. + cache-environment-key: micromamba-environment-${{ steps.date.outputs.date }} create-args: >- python=3.12 cmake diff --git a/.github/workflows/ci_tests_legacy.yaml b/.github/workflows/ci_tests_legacy.yaml index a2d6357ef1c..8e857e24d24 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -58,8 +58,6 @@ jobs: channels: - conda-forge - nodefaults - cache-downloads: false - cache-environment: true create-args: >- python=3.10 gmt=${{ matrix.gmt_version }}