Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 190 additions & 0 deletions .github/actions/setup-ddev/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
name: Setup ddev
description: Install uv, restore the shared Python dependency cache, and install ddev.

inputs:
install-mode:
description: >-
Install source for ddev. Allowed values: local (install editable ddev and
datadog_checks_dev from this checkout), pypi (install ddev from PyPI).
required: false
default: local
cache-profile:
description: >-
Cache key profile to restore for local installs. Ignored when install-mode
is pypi. Allowed values: local-ddev-base (local ddev, datadog_checks_dev,
and datadog_checks_base dependencies), local-ddev (local ddev and
datadog_checks_dev dependencies).
required: false
default: local-ddev-base
ddev-version:
description: Optional PyPI ddev version specifier, for example ==16.0.0.
required: false
default: ""

runs:
using: composite
steps:
- name: Validate inputs
shell: bash
env:
CACHE_PROFILE: ${{ inputs.cache-profile }}
INSTALL_MODE: ${{ inputs.install-mode }}
run: |-
case "$INSTALL_MODE" in
local|pypi) ;;
*)
echo "::error::Invalid install-mode '$INSTALL_MODE'. Allowed values: local, pypi."
exit 1
;;
esac

case "$CACHE_PROFILE" in
local-ddev-base|local-ddev) ;;
*)
echo "::error::Invalid cache-profile '$CACHE_PROFILE'. Allowed values: local-ddev-base, local-ddev."
exit 1
;;
esac

- name: Compute cache date
id: cache-date
shell: bash
run: echo "date=$(date -u +%Y-%m-%d)" >> "$GITHUB_OUTPUT"

- name: Install uv
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
with:
enable-cache: false

- name: Restore local ddev cache
if: ${{ inputs.install-mode == 'local' && inputs.cache-profile == 'local-ddev-base' }}
id: restore-local-ddev-base-cache
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: |
${{ runner.os == 'Windows' && '~\AppData\Local\uv\cache' || runner.os == 'macOS' && '~/Library/Caches/uv' || '~/.cache/uv' }}
${{ runner.os == 'Windows' && '~\AppData\Local\pip\Cache' || runner.os == 'macOS' && '~/Library/Caches/pip' || '~/.cache/pip' }}
key: >-
${{ format(
'v02-uv-{0}-{1}-{2}-{3}-{4}',
env.pythonLocation,
hashFiles('datadog_checks_base/pyproject.toml'),
hashFiles('datadog_checks_dev/pyproject.toml'),
hashFiles('ddev/pyproject.toml'),
steps.cache-date.outputs.date
)}}
restore-keys: |-
${{ format(
'v02-uv-{0}-{1}-{2}-{3}-',
env.pythonLocation,
hashFiles('datadog_checks_base/pyproject.toml'),
hashFiles('datadog_checks_dev/pyproject.toml'),
hashFiles('ddev/pyproject.toml')
)}}
${{ format(
'v02-uv-{0}-{1}-{2}-{3}',
env.pythonLocation,
hashFiles('datadog_checks_base/pyproject.toml'),
hashFiles('datadog_checks_dev/pyproject.toml'),
hashFiles('ddev/pyproject.toml')
)}}
v02-uv-${{ env.pythonLocation }}

- name: Restore local ddev cache without base package
if: ${{ inputs.install-mode == 'local' && inputs.cache-profile == 'local-ddev' }}
id: restore-local-ddev-cache
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: |
${{ runner.os == 'Windows' && '~\AppData\Local\uv\cache' || runner.os == 'macOS' && '~/Library/Caches/uv' || '~/.cache/uv' }}
${{ runner.os == 'Windows' && '~\AppData\Local\pip\Cache' || runner.os == 'macOS' && '~/Library/Caches/pip' || '~/.cache/pip' }}
key: >-
${{ format(
'v02-uv-local-ddev-{0}-{1}-{2}-{3}',
env.pythonLocation,
hashFiles('datadog_checks_dev/pyproject.toml'),
hashFiles('ddev/pyproject.toml'),
steps.cache-date.outputs.date
)}}
restore-keys: |-
${{ format(
'v02-uv-local-ddev-{0}-{1}-{2}-',
env.pythonLocation,
hashFiles('datadog_checks_dev/pyproject.toml'),
hashFiles('ddev/pyproject.toml')
)}}
${{ format(
'v02-uv-local-ddev-{0}-{1}-{2}',
env.pythonLocation,
hashFiles('datadog_checks_dev/pyproject.toml'),
hashFiles('ddev/pyproject.toml')
)}}
v02-uv-local-ddev-${{ env.pythonLocation }}

- name: Restore PyPI ddev cache
if: ${{ inputs.install-mode == 'pypi' }}
id: restore-pypi-ddev-cache
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: |
${{ runner.os == 'Windows' && '~\AppData\Local\uv\cache' || runner.os == 'macOS' && '~/Library/Caches/uv' || '~/.cache/uv' }}
${{ runner.os == 'Windows' && '~\AppData\Local\pip\Cache' || runner.os == 'macOS' && '~/Library/Caches/pip' || '~/.cache/pip' }}
key: >-
${{ format(
'v02-uv-pypi-ddev-{0}-{1}-{2}',
env.pythonLocation,
inputs.ddev-version || 'latest',
steps.cache-date.outputs.date
)}}
restore-keys: |-
${{ format(
'v02-uv-pypi-ddev-{0}-{1}-',
env.pythonLocation,
inputs.ddev-version || 'latest'
)}}
${{ format(
'v02-uv-pypi-ddev-{0}-{1}',
env.pythonLocation,
inputs.ddev-version || 'latest'
)}}
v02-uv-pypi-ddev-${{ env.pythonLocation }}

- name: Install ddev from local folder
if: ${{ inputs.install-mode == 'local' }}
shell: bash
run: uv pip install --system -e ./datadog_checks_dev[cli] -e ./ddev

- name: Install ddev from PyPI
if: ${{ inputs.install-mode == 'pypi' }}
shell: bash
run: uv pip install --system "ddev${{ inputs.ddev-version }}"

- name: Save local ddev cache
if: ${{ inputs.install-mode == 'local' && inputs.cache-profile == 'local-ddev-base' && steps.restore-local-ddev-base-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
continue-on-error: true
with:
path: |
${{ runner.os == 'Windows' && '~\AppData\Local\uv\cache' || runner.os == 'macOS' && '~/Library/Caches/uv' || '~/.cache/uv' }}
${{ runner.os == 'Windows' && '~\AppData\Local\pip\Cache' || runner.os == 'macOS' && '~/Library/Caches/pip' || '~/.cache/pip' }}
key: ${{ steps.restore-local-ddev-base-cache.outputs.cache-primary-key }}

- name: Save local ddev cache without base package
if: ${{ inputs.install-mode == 'local' && inputs.cache-profile == 'local-ddev' && steps.restore-local-ddev-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
continue-on-error: true
with:
path: |
${{ runner.os == 'Windows' && '~\AppData\Local\uv\cache' || runner.os == 'macOS' && '~/Library/Caches/uv' || '~/.cache/uv' }}
${{ runner.os == 'Windows' && '~\AppData\Local\pip\Cache' || runner.os == 'macOS' && '~/Library/Caches/pip' || '~/.cache/pip' }}
key: ${{ steps.restore-local-ddev-cache.outputs.cache-primary-key }}

- name: Save PyPI ddev cache
if: ${{ inputs.install-mode == 'pypi' && steps.restore-pypi-ddev-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
continue-on-error: true
with:
path: |
${{ runner.os == 'Windows' && '~\AppData\Local\uv\cache' || runner.os == 'macOS' && '~/Library/Caches/uv' || '~/.cache/uv' }}
${{ runner.os == 'Windows' && '~\AppData\Local\pip\Cache' || runner.os == 'macOS' && '~/Library/Caches/pip' || '~/.cache/pip' }}
key: ${{ steps.restore-pypi-ddev-cache.outputs.cache-primary-key }}
12 changes: 4 additions & 8 deletions .github/workflows/build-ddev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -738,16 +738,12 @@ jobs:
with:
python-version: "${{ env.PYTHON_VERSION }}"

- name: Install uv
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
continue-on-error: true
with:
enable-cache: false

- name: Install ddev from local folder
continue-on-error: true
working-directory: .
run: uv pip install --system -e ./datadog_checks_dev[cli] -e ./ddev
uses: ./.github/actions/setup-ddev
with:
install-mode: local
cache-profile: local-ddev-base

- name: Configure ddev
continue-on-error: true
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,11 @@ jobs:
with:
python-version: '3.13'

- name: Install uv
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
with:
enable-cache: false

- name: Install ddev
run: |
uv pip install --system -e ./datadog_checks_dev[cli] -e ./ddev
uses: ./.github/actions/setup-ddev
with:
install-mode: local
cache-profile: local-ddev-base

- name: Configure ddev
run: |
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/measure-disk-usage-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ jobs:
policy: integrations-core-api-key

- name: Install ddev
run: |
pip install -e ./datadog_checks_dev[cli]
pip install -e ./ddev
uses: ./.github/actions/setup-ddev
with:
install-mode: local
cache-profile: local-ddev-base

- name: Configure ddev
run: ddev config override
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/measure-disk-usage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ jobs:
policy: integrations-core-api-key

- name: Install ddev
run: |
pip install -e ./datadog_checks_dev[cli]
pip install -e ./ddev
uses: ./.github/actions/setup-ddev
with:
install-mode: local
cache-profile: local-ddev-base

- name: Configure ddev
run: |
Expand Down Expand Up @@ -85,4 +86,4 @@ jobs:
with:
name: status_compressed.json
path: status_compressed.json
if-no-files-found: error
if-no-files-found: error
1 change: 1 addition & 0 deletions .github/workflows/pr-all-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
- '.github/workflows/test-all-windows.yml'
# Also run in the action to install test-target scripts changes
- '.github/actions/setup-test-target-scripts/**'
- '.github/actions/setup-ddev/**'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.head_ref }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:
- '.github/workflows/test-all.yml'
# Also run if the action to install test-target scripts changes
- '.github/actions/setup-test-target-scripts/**'
- '.github/actions/setup-ddev/**'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.head_ref }}
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/release-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ jobs:
run: pip install --disable-pip-version-check --upgrade pip setuptools wheel

- name: Install ddev
run: |
pip install -e ./datadog_checks_dev[cli]
pip install -e ./ddev
uses: ./.github/actions/setup-ddev
with:
install-mode: local
cache-profile: local-ddev-base

- name: Configure ddev
run: |
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/release-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ jobs:
run: pip install --disable-pip-version-check --upgrade pip setuptools wheel

- name: Install ddev
run: |
pip install -e ./datadog_checks_dev[cli]
pip install -e ./ddev
uses: ./.github/actions/setup-ddev
with:
install-mode: local
cache-profile: local-ddev-base

- name: Configure ddev
run: |
Expand Down
29 changes: 28 additions & 1 deletion .github/workflows/release-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ env:
# Default ddev version when callers don't pass `ddev-version`. Tracked by Renovate.
# renovate: datasource=pypi depName=ddev
DEFAULT_DDEV_VERSION: "16.0.0"
PYTHON_VERSION: "3.13"

jobs:
prepare:
Expand All @@ -59,8 +60,34 @@ jobs:
with:
fetch-depth: 0 # ddev needs full tag history

- name: Checkout integrations-core actions
if: github.repository != 'DataDog/integrations-core'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: "DataDog/integrations-core"
ref: master
fetch-depth: 1
sparse-checkout: .github/actions
path: core-temp

- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "${{ env.PYTHON_VERSION }}"

- name: Install ddev
run: pip install "ddev==${{ inputs.ddev-version || env.DEFAULT_DDEV_VERSION }}"
if: github.repository == 'DataDog/integrations-core'
uses: ./.github/actions/setup-ddev
with:
install-mode: pypi
ddev-version: "==${{ inputs.ddev-version || env.DEFAULT_DDEV_VERSION }}"

- name: Install ddev
if: github.repository != 'DataDog/integrations-core'
uses: ./core-temp/.github/actions/setup-ddev
with:
install-mode: pypi
ddev-version: "==${{ inputs.ddev-version || env.DEFAULT_DDEV_VERSION }}"

- name: Configure ddev
env:
Expand Down
22 changes: 18 additions & 4 deletions .github/workflows/run-validations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,34 @@ jobs:
with:
fetch-depth: "0"

- name: Checkout integrations-core actions
if: inputs.repo != 'core'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: "DataDog/integrations-core"
ref: master
fetch-depth: 1
sparse-checkout: .github/actions
path: core-temp

- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "${{ env.PYTHON_VERSION }}"

- name: Install ddev from local folder
if: inputs.repo == 'core'
run: |-
pip install -e ./datadog_checks_dev[cli]
pip install -e ./ddev
uses: ./.github/actions/setup-ddev
with:
install-mode: local
cache-profile: local-ddev-base

- name: Install ddev from PyPI
if: inputs.repo != 'core'
run: pip install ddev${{ inputs.ddev-version }}
uses: ./core-temp/.github/actions/setup-ddev
with:
install-mode: pypi
ddev-version: ${{ inputs.ddev-version }}

- name: Configure ddev
run: |
Expand Down
Loading
Loading