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
103 changes: 103 additions & 0 deletions .github/workflows/reusable-python-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Reusable Python Testing Workflow

on:
workflow_call:
inputs:
python-versions:
description: 'JSON array of Python versions to test against'
required: false
type: string
default: '["3.8", "3.12"]'
platforms:
description: 'JSON array of platforms to run tests on'
required: false
type: string
default: '["ubuntu-22.04", "ubuntu-latest", "macos-latest"]'
matrix-exclude:
description: 'JSON array of matrix combinations to exclude'
required: false
type: string
default: '[{"platform": "macos-latest", "python-version": "3.8"}, {"platform": "ubuntu-latest", "python-version": "3.8"}, {"platform": "ubuntu-22.04", "python-version": "3.12"}]'
enable-status-reporting:
description: 'Whether to post status checks to datadog-api-spec repo'
required: false
type: boolean
default: false
status-context:
description: 'Context for status checks'
required: false
type: string
default: 'master/unit'
secrets:
PIPELINE_GITHUB_APP_ID:
required: false
PIPELINE_GITHUB_APP_PRIVATE_KEY:
required: false

jobs:
test:
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJSON(inputs.python-versions) }}
platform: ${{ fromJSON(inputs.platforms) }}
exclude: ${{ fromJSON(inputs.matrix-exclude) }}
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
pip install --upgrade wheel setuptools build
- name: Install
run: pip install --disable-pip-version-check -e .[tests]
- name: Test
run: ./run-tests.sh
shell: bash

examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
cache: "pip"
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
pip install --upgrade wheel setuptools build
- name: Install
run: pip install --disable-pip-version-check pyflakes
- name: Check examples
run: ./check-examples.sh
shell: bash

report:
runs-on: ubuntu-latest
if: always() && github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/') && inputs.enable-status-reporting
needs:
- test
- examples
steps:
- name: Get GitHub App token
if: github.event_name == 'pull_request'
id: get_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.PIPELINE_GITHUB_APP_ID }}
private-key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}
repositories: datadog-api-spec
- name: Post status check
uses: DataDog/github-actions/post-status-check@v2
with:
github-token: ${{ steps.get_token.outputs.token }}
repo: datadog-api-spec
status: ${{ (needs.test.result == 'cancelled' || needs.examples.result == 'cancelled') && 'pending' || needs.test.result == 'success' && needs.examples.result == 'success' && 'success' || 'failure' }}
context: ${{ inputs.status-context }}
94 changes: 15 additions & 79 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,82 +75,18 @@ jobs:
pre-commit run --all-files --show-diff-on-failure --color=always

test:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.12"]
platform: [ubuntu-22.04, ubuntu-latest, macos-latest] # windows-latest
# test only latest version on macos and windows
exclude:
- platform: macos-latest
python-version: "3.8"
- platform: ubuntu-latest
python-version: "3.8"
- platform: ubuntu-22.04
python-version: "3.12"
# TODO enable once dd-trace-py is updated
# - platform: windows-latest
# python-version: 3.8
# - platform: windows-latest
# python-version: 3.8
runs-on: ${{ matrix.platform }}
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'
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
pip install --upgrade wheel setuptools build
- name: Install
run: pip install --disable-pip-version-check -e .[tests]
- name: Test
run: ./run-tests.sh
shell: bash

examples:
runs-on: ubuntu-latest
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'
steps:
- uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
cache: "pip"
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
pip install --upgrade wheel setuptools build
- name: Install
run: pip install --disable-pip-version-check pyflakes
- name: Check examples
run: ./check-examples.sh
shell: bash

report:
runs-on: ubuntu-latest
if: always() && github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')
needs:
- test
- examples
steps:
- name: Get GitHub App token
if: github.event_name == 'pull_request'
id: get_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.PIPELINE_GITHUB_APP_ID }}
private-key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}
repositories: datadog-api-spec
- name: Post status check
uses: DataDog/github-actions/post-status-check@v2
with:
github-token: ${{ steps.get_token.outputs.token }}
repo: datadog-api-spec
status: ${{ (needs.test.result == 'cancelled' || needs.examples.result == 'cancelled') && 'pending' || needs.test.result == 'success' && needs.examples.result == 'success' && 'success' || 'failure' }}
context: master/unit
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'
uses: ./.github/workflows/reusable-python-test.yml
with:
python-versions: '["3.8", "3.12"]'
platforms: '["ubuntu-22.04", "ubuntu-latest", "macos-latest"]'
matrix-exclude: '[{"platform": "macos-latest", "python-version": "3.8"}, {"platform": "ubuntu-latest", "python-version": "3.8"}, {"platform": "ubuntu-22.04", "python-version": "3.12"}]'
enable-status-reporting: true
status-context: 'master/unit'
secrets:
PIPELINE_GITHUB_APP_ID: ${{ secrets.PIPELINE_GITHUB_APP_ID }}
PIPELINE_GITHUB_APP_PRIVATE_KEY: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}
Loading