Skip to content

Commit 03a6659

Browse files
authored
Improve cache management (#946)
Run pre-commit and tests on schedule to build caches.
1 parent b0b6734 commit 03a6659

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

.github/workflows/test.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
pull_request:
99
branches:
1010
- master
11+
schedule:
12+
- cron: "0 5 * * *"
1113

1214
concurrency:
1315
group: unit-${{ github.head_ref }}
@@ -17,9 +19,10 @@ jobs:
1719
pre-commit:
1820
runs-on: ubuntu-latest
1921
if: >
20-
github.event.pull_request.draft == false &&
21-
!contains(github.event.pull_request.labels.*.name, 'ci/skip') &&
22-
!contains(github.event.pull_request.head.ref, 'datadog-api-spec/test/')
22+
(github.event.pull_request.draft == false &&
23+
!contains(github.event.pull_request.labels.*.name, 'ci/skip') &&
24+
!contains(github.event.pull_request.head.ref, 'datadog-api-spec/test/')) ||
25+
github.event_name == 'schedule'
2326
steps:
2427
# Run only in this repository
2528
- name: Get GitHub App token
@@ -37,7 +40,7 @@ jobs:
3740
token: ${{ steps.get_token.outputs.token }}
3841
- uses: actions/setup-python@v4
3942
with:
40-
python-version: '3.10'
43+
python-version: '3.11'
4144
# Fetch a fork of the repo
4245
- uses: actions/checkout@v3
4346
if: github.event.pull_request.head.repo.full_name != github.repository
@@ -48,7 +51,7 @@ jobs:
4851
run: python -m pip install pre-commit
4952
- name: set PY
5053
run: echo "PY=$(python -c 'import hashlib, sys, platform;print(hashlib.sha256(platform.python_version().encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV
51-
- uses: actions/cache@v2
54+
- uses: actions/cache@v3
5255
with:
5356
path: ~/.cache/pre-commit
5457
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
@@ -71,20 +74,19 @@ jobs:
7174
exit 1
7275
env:
7376
HEAD_REF: ${{ github.event.pull_request.head.ref }}
77+
- id: pre_commit_schedule
78+
name: Run pre-commit in schedule
79+
if: github.event_name == 'schedule'
80+
run: |
81+
pre-commit run --all-files --show-diff-on-failure --color=always
7482
7583
test:
7684
strategy:
7785
matrix:
7886
node-version: ["16", "18"]
79-
platform: [ubuntu-latest] # , macos-latest, windows-latest]
80-
# test only latest version on macos and windows
81-
# exclude:
82-
# - platform: macos-latest
83-
# node-version: '12'
84-
# - platform: windows-latest
85-
# node-version: '12'
87+
platform: [ubuntu-latest]
8688
runs-on: ${{ matrix.platform }}
87-
if: github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'ci/skip') && !contains(github.event.pull_request.head.ref, 'datadog-api-spec/test/')
89+
if: (github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'ci/skip') && !contains(github.event.pull_request.head.ref, 'datadog-api-spec/test/')) || github.event_name == 'schedule'
8890
steps:
8991
- uses: actions/checkout@v3
9092
- name: Set up Node ${{ matrix.node-version }}
@@ -98,7 +100,7 @@ jobs:
98100

99101
examples:
100102
runs-on: ubuntu-latest
101-
if: github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'ci/skip') && !contains(github.event.pull_request.head.ref, 'datadog-api-spec/test/')
103+
if: (github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'ci/skip') && !contains(github.event.pull_request.head.ref, 'datadog-api-spec/test/')) || github.event_name == 'schedule'
102104
steps:
103105
- uses: actions/checkout@v3
104106
- name: Set up Node 16

0 commit comments

Comments
 (0)