Skip to content

Commit a5c3fd4

Browse files
akihironittanicolai86
authored andcommitted
CI: Reuse clear cache (#14593)
* Remove existing weekly reset logic * clear cache every week * Use main tag
1 parent f2d76e4 commit a5c3fd4

7 files changed

+25
-34
lines changed

.github/workflows/ci-app-examples.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ jobs:
4949
open(fpath, 'w').write(req)
5050
shell: python
5151

52-
- run: echo "::set-output name=period::$(python -c 'import time ; days = time.time() / 60 / 60 / 24 ; print(int(days / 7))' 2>&1)"
53-
if: matrix.requires == 'latest'
54-
id: times
55-
5652
# Note: This uses an internal pip API and may not always work
5753
# https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow
5854
- name: Get pip cache
@@ -64,8 +60,8 @@ jobs:
6460
uses: actions/cache@v3
6561
with:
6662
path: ${{ steps.pip-cache.outputs.dir }}
67-
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ matrix.requires }}-td${{ steps.times.outputs.period }}-${{ hashFiles('requirements/app/base.txt') }}
68-
restore-keys: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ matrix.requires }}-td${{ steps.times.outputs.period }}-
63+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ matrix.requires }}-${{ hashFiles('requirements/app/base.txt') }}
64+
restore-keys: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ matrix.requires }}-
6965

7066
- name: Install dependencies
7167
run: |

.github/workflows/ci-app-tests.yml

+2-8
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ jobs:
4646
open(fpath, 'w').write(req)
4747
shell: python
4848

49-
- run: echo "::set-output name=period::$(python -c 'import time ; days = time.time() / 60 / 60 / 24 ; print(int(days / 7))' 2>&1)"
50-
if: matrix.requires == 'latest'
51-
id: times
52-
53-
# Note: This uses an internal pip API and may not always work
54-
# https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow
5549
- name: Get pip cache
5650
id: pip-cache
5751
run: |
@@ -61,8 +55,8 @@ jobs:
6155
uses: actions/cache@v3
6256
with:
6357
path: ${{ steps.pip-cache.outputs.dir }}
64-
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ matrix.requires }}-td${{ steps.times.outputs.period }}-${{ hashFiles('requirements/app/base.txt') }}
65-
restore-keys: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ matrix.requires }}-td${{ steps.times.outputs.period }}-
58+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ matrix.requires }}-${{ hashFiles('requirements/app/base.txt') }}
59+
restore-keys: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ matrix.requires }}-
6660

6761
- name: Install dependencies
6862
run: |

.github/workflows/ci-lite-test-full.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ jobs:
4545
with:
4646
python-version: ${{ matrix.python-version }}
4747

48-
- name: Reset caching
49-
run: python -c "import time; days = time.time() / 60 / 60 / 24; print(f'TIME_PERIOD=d{int(days / 2) * 2}')" >> $GITHUB_ENV
50-
5148
- name: basic setup
5249
run: |
5350
pip --version
@@ -73,9 +70,9 @@ jobs:
7370
uses: actions/cache@v3
7471
with:
7572
path: ${{ steps.pip-cache.outputs.dir }}
76-
key: ${{ runner.os }}-pip-td${{ env.TIME_PERIOD }}-py${{ matrix.python-version }}-${{ matrix.release }}-${{ matrix.requires }}-${{ hashFiles('requirements/lite/*.txt') }}
73+
key: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ matrix.release }}-${{ matrix.requires }}-${{ hashFiles('requirements/lite/*.txt') }}
7774
restore-keys: |
78-
${{ runner.os }}-pip-td${{ env.TIME_PERIOD }}-py${{ matrix.python-version }}-${{ matrix.release }}-${{ matrix.requires }}-
75+
${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ matrix.release }}-${{ matrix.requires }}-
7976
8077
- name: Install dependencies
8178
env:

.github/workflows/ci-pytorch-test-full.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ jobs:
6060
with:
6161
python-version: ${{ matrix.python-version }}
6262

63-
- name: Reset caching
64-
run: python -c "import time; days = time.time() / 60 / 60 / 24; print(f'TIME_PERIOD=d{int(days / 2) * 2}')" >> $GITHUB_ENV
65-
6663
- name: basic setup
6764
run: |
6865
pip --version
@@ -91,9 +88,9 @@ jobs:
9188
uses: actions/cache@v3
9289
with:
9390
path: ${{ steps.pip-cache.outputs.dir }}
94-
key: ${{ runner.os }}-pip-td${{ env.TIME_PERIOD }}-py${{ matrix.python-version }}-${{ matrix.release }}-${{ matrix.requires }}-${{ hashFiles('requirements/pytorch/*.txt') }}
91+
key: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ matrix.release }}-${{ matrix.requires }}-${{ hashFiles('requirements/pytorch/*.txt') }}
9592
restore-keys: |
96-
${{ runner.os }}-pip-td${{ env.TIME_PERIOD }}-py${{ matrix.python-version }}-${{ matrix.release }}-${{ matrix.requires }}-
93+
${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ matrix.release }}-${{ matrix.requires }}-
9794
9895
- name: Pull legacy checkpoints
9996
run: bash .actions/pull_legacy_checkpoints.sh

.github/workflows/ci-pytorch-test-slow.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ jobs:
4141
with:
4242
python-version: ${{ matrix.python-version }}
4343

44-
- name: Reset caching
45-
run: python -c "import time; days = time.time() / 60 / 60 / 24; print(f'TIME_PERIOD=d{int(days / 2) * 2}')" >> $GITHUB_ENV
46-
4744
- name: Get pip cache
4845
id: pip-cache
4946
run: |
@@ -53,9 +50,9 @@ jobs:
5350
uses: actions/cache@v3
5451
with:
5552
path: ${{ steps.pip-cache.outputs.dir }}
56-
key: ${{ runner.os }}-pip-td${{ env.TIME_PERIOD }}-py${{ matrix.python-version }}-${{ hashFiles('requirements/pytorch/base.txt') }}
53+
key: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ hashFiles('requirements/pytorch/base.txt') }}
5754
restore-keys: |
58-
${{ runner.os }}-pip-td${{ env.TIME_PERIOD }}-py${{ matrix.python-version }}-
55+
${{ runner.os }}-pip-py${{ matrix.python-version }}-
5956
6057
- name: Install dependencies
6158
env:

.github/workflows/docs-checks.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,15 @@ jobs:
2727
with:
2828
python-version: 3.9
2929

30-
- name: Reset caching
31-
run: python -c "import time; days = time.time() / 60 / 60 / 24; print(f'TIME_PERIOD=d{int(days / 2) * 2}')" >> $GITHUB_ENV
32-
3330
# Note: This uses an internal pip API and may not always work
3431
# https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow
3532
- name: Cache pip
3633
uses: actions/cache@v3
3734
with:
3835
path: ~/.cache/pip
39-
key: ${{ runner.os }}-docs-test-pip-td${{ env.TIME_PERIOD }}-${{ hashFiles('requirements/${{ matrix.pkg }}/*.txt') }}
36+
key: ${{ runner.os }}-docs-test-pip-${{ hashFiles('requirements/${{ matrix.pkg }}/*.txt') }}
4037
restore-keys: |
41-
${{ runner.os }}-docs-test-pip-td${{ env.TIME_PERIOD }}-
38+
${{ runner.os }}-docs-test-pip-
4239
4340
- name: Install dependencies
4441
env:
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Clear cache weekly
2+
3+
on:
4+
schedule:
5+
# on Sundays
6+
- cron: "0 0 * * 0"
7+
8+
jobs:
9+
clear-cache:
10+
if: ${{ github.repository_owner == 'Lightning-AI' }}
11+
uses: Lightning-AI/utilities/.github/workflows/clear-cache.yml@main
12+
with:
13+
pattern: 'latest|docs'

0 commit comments

Comments
 (0)