Sync OpenAPI specification for (spec-v1-shared.yaml) #14831
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Tests | |
permissions: | |
contents: read | |
env: | |
GIT_AUTHOR_EMAIL: "[email protected]" | |
GIT_AUTHOR_NAME: "ci.datadog-api-spec" | |
on: | |
pull_request: | |
branches: | |
- v2 | |
schedule: | |
- cron: "0 5 * * *" | |
concurrency: | |
group: unit-split-package-${{ github.head_ref }} | |
cancel-in-progress: true | |
jobs: | |
pre-commit: | |
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: | |
# Run only in this repository | |
- name: Get GitHub App token | |
id: get_token | |
if: github.event.pull_request.head.repo.full_name == github.repository | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ secrets.PIPELINE_GITHUB_APP_ID }} | |
private-key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }} | |
- uses: actions/checkout@v3 | |
if: github.event.pull_request.head.repo.full_name == github.repository | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
token: ${{ steps.get_token.outputs.token }} | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
# Fetch a fork of the repo | |
- uses: actions/checkout@v3 | |
if: github.event.pull_request.head.repo.full_name != github.repository | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Install pre-commit | |
run: python -m pip install pre-commit | |
- name: set PY | |
run: echo "PY=$(python -c 'import hashlib, sys, platform;print(hashlib.sha256(platform.python_version().encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pre-commit | |
key: pre-commit|split-package|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} | |
- id: pre_commit | |
name: Run generate to fix lint and format | |
if: github.event.action != 'closed' && github.event.pull_request.merged != true | |
run: bash -c "./generate.sh" | |
- name: Commit changes | |
if: github.event.pull_request.head.repo.full_name == github.repository && failure() | |
run: |- | |
git add -A | |
git config user.name "${GIT_AUTHOR_NAME}" | |
git config user.email "${GIT_AUTHOR_EMAIL}" | |
git commit -m "pre-commit fixes" | |
git push origin "HEAD:${HEAD_REF}" | |
exit 1 | |
env: | |
HEAD_REF: ${{ github.event.pull_request.head.ref }} | |
- id: pre_commit_schedule | |
name: Run pre-commit in schedule | |
if: github.event_name == 'schedule' | |
run: | | |
pre-commit run --all-files --show-diff-on-failure --color=always | |
test: | |
strategy: | |
matrix: | |
node-version: ["18", "20"] | |
platform: [ubuntu-latest] | |
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: Enable Corepack | |
run: corepack enable | |
env: | |
COREPACK_ENABLE_DOWNLOAD_PROMPT: 0 | |
- name: Set up Node ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'yarn' | |
- 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: Set up Node 16 | |
# uses: actions/setup-node@v3 | |
# with: | |
# node-version: 16 | |
# cache: 'yarn' | |
# - 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/v2/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: Get pull request number | |
id: get_pr_number | |
run: | | |
spec_pr=$(echo "${{ github.event.pull_request.head.ref }}" | sed 's/.*generated\/\([0-9]*\).*/\1/') | |
echo "spec_pr=${spec_pr}" >> $GITHUB_OUTPUT | |
- 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' }} | |
status: ${{ needs.test.result == 'cancelled' && 'pending' || needs.test.result == 'success' && 'success' || 'failure' }} | |
context: v2/unit | |
pull-request: ${{ steps.get_pr_number.outputs.spec_pr }} |