forked from DataDog/integrations-core
-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (64 loc) · 2.48 KB
/
cache-shared-deps.yml
File metadata and controls
75 lines (64 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Cache shared Python dependencies
on:
workflow_call:
defaults:
run:
shell: bash
jobs:
cache:
name: Cache Python dependencies for ${{ startsWith(matrix.os, 'windows-') && 'Windows' || startsWith(matrix.os, 'macos-') && 'macOS' || 'Linux' }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, windows-2022]
env:
PYTHON_VERSION: "3.13"
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
id: python
with:
python-version: "${{ env.PYTHON_VERSION }}"
- name: Check cache
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
id: cache
with:
path: ${{ runner.os == 'Windows' && '~\AppData\Local\pip\Cache' || runner.os == 'macOS' && '~/Library/Caches/pip' || '~/.cache/pip' }}
key: >-
${{ format(
'v01-python-{0}-{1}-{2}-{3}',
env.pythonLocation,
hashFiles('datadog_checks_base/pyproject.toml'),
hashFiles('datadog_checks_dev/pyproject.toml'),
hashFiles('ddev/pyproject.toml')
)}}
lookup-only: true
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |-
pip install ./ddev
pip install ./datadog_checks_dev[cli]
pip install ./datadog_checks_base[deps]
- name: Set up Python 2.7
if: steps.cache.outputs.cache-hit != 'true'
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt update
sudo apt install python2 python2-dev
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
elif [ "$RUNNER_OS" == "Windows" ]; then
choco install python2
else
echo "$RUNNER_OS not supported"
exit 1
fi
- name: Install dependencies for Python 2.7
if: steps.cache.outputs.cache-hit != 'true'
run: pip install ./datadog_checks_base[deps] ./datadog_checks_dev
- name: Cache dependencies
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
if: steps.cache.outputs.cache-hit != 'true'
with:
path: ${{ runner.os == 'Windows' && '~\AppData\Local\pip\Cache' || runner.os == 'macOS' && '~/Library/Caches/pip' || '~/.cache/pip' }}
key: ${{ steps.cache.outputs.cache-primary-key }}