diff --git a/.github/workflows/reusable-ci.yml b/.github/workflows/reusable-ci.yml new file mode 100644 index 00000000000..ca82a181837 --- /dev/null +++ b/.github/workflows/reusable-ci.yml @@ -0,0 +1,104 @@ +name: Reusable Complete CI Workflow + +on: + workflow_call: + inputs: + target-branch: + description: 'Branch to checkout and test (defaults to the calling branch)' + required: false + type: string + default: '' + java-versions: + description: 'JSON array of Java versions to test against' + required: false + type: string + default: '["8", "16", "18", "19"]' + platforms: + description: 'JSON array of platforms to run tests on' + required: false + type: string + default: '["ubuntu-latest"]' + test-script: + description: 'Test script to execute' + required: false + type: string + default: './run-tests.sh' + examples-script: + description: 'Examples script to execute' + required: false + type: string + default: './check-examples.sh' + secrets: + PIPELINE_GITHUB_APP_ID: + required: false + PIPELINE_GITHUB_APP_PRIVATE_KEY: + required: false + # Integration test secrets + DD_API_KEY: + required: false + DD_CLIENT_API_KEY: + required: false + DD_CLIENT_APP_KEY: + required: false + SLEEP_AFTER_REQUEST: + required: false + +jobs: + pre-commit: + uses: ./.github/workflows/reusable-pre-commit.yml + with: + target-branch: ${{ inputs.target-branch }} + enable-commit-changes: false # Don't auto-commit in external CI + secrets: + PIPELINE_GITHUB_APP_ID: ${{ secrets.PIPELINE_GITHUB_APP_ID }} + PIPELINE_GITHUB_APP_PRIVATE_KEY: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }} + + javadoc: + uses: ./.github/workflows/reusable-javadoc.yml + with: + target-branch: ${{ inputs.target-branch }} + secrets: + PIPELINE_GITHUB_APP_ID: ${{ secrets.PIPELINE_GITHUB_APP_ID }} + PIPELINE_GITHUB_APP_PRIVATE_KEY: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }} + + shading: + uses: ./.github/workflows/reusable-shading.yml + with: + target-branch: ${{ inputs.target-branch }} + secrets: + PIPELINE_GITHUB_APP_ID: ${{ secrets.PIPELINE_GITHUB_APP_ID }} + PIPELINE_GITHUB_APP_PRIVATE_KEY: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }} + + test: + uses: ./.github/workflows/reusable-java-test.yml + with: + target-branch: ${{ inputs.target-branch }} + java-versions: ${{ inputs.java-versions }} + platforms: ${{ inputs.platforms }} + test-script: ${{ inputs.test-script }} + secrets: + PIPELINE_GITHUB_APP_ID: ${{ secrets.PIPELINE_GITHUB_APP_ID }} + PIPELINE_GITHUB_APP_PRIVATE_KEY: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }} + DD_API_KEY: ${{ secrets.DD_API_KEY }} + + examples: + uses: ./.github/workflows/reusable-examples.yml + with: + target-branch: ${{ inputs.target-branch }} + examples-script: ${{ inputs.examples-script }} + secrets: + PIPELINE_GITHUB_APP_ID: ${{ secrets.PIPELINE_GITHUB_APP_ID }} + PIPELINE_GITHUB_APP_PRIVATE_KEY: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }} + + integration: + uses: ./.github/workflows/reusable-integration-test.yml + with: + target-branch: ${{ inputs.target-branch }} + secrets: + PIPELINE_GITHUB_APP_ID: ${{ secrets.PIPELINE_GITHUB_APP_ID }} + PIPELINE_GITHUB_APP_PRIVATE_KEY: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }} + DD_API_KEY: ${{ secrets.DD_API_KEY }} + DD_CLIENT_API_KEY: ${{ secrets.DD_CLIENT_API_KEY }} + DD_CLIENT_APP_KEY: ${{ secrets.DD_CLIENT_APP_KEY }} + SLEEP_AFTER_REQUEST: ${{ secrets.SLEEP_AFTER_REQUEST }} + diff --git a/.github/workflows/reusable-examples.yml b/.github/workflows/reusable-examples.yml new file mode 100644 index 00000000000..0edefa7febe --- /dev/null +++ b/.github/workflows/reusable-examples.yml @@ -0,0 +1,44 @@ +name: Reusable Examples Workflow + +on: + workflow_call: + inputs: + target-branch: + description: 'Branch to checkout and test (defaults to the calling branch)' + required: false + type: string + default: '' + examples-script: + description: 'Examples script to execute' + required: false + type: string + default: './check-examples.sh' + java-version: + description: 'Java version to use for examples' + required: false + type: string + default: '16' + secrets: + PIPELINE_GITHUB_APP_ID: + required: false + PIPELINE_GITHUB_APP_PRIVATE_KEY: + required: false + +jobs: + 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 + with: + repository: DataDog/datadog-api-client-java + ref: ${{ inputs.target-branch || github.ref }} + - name: Install Java + uses: actions/setup-java@v3 + with: + java-version: ${{ inputs.java-version }} + distribution: "temurin" + cache: "maven" + - name: Check examples + run: ${{ inputs.examples-script }} + shell: bash \ No newline at end of file diff --git a/.github/workflows/test_integration.yml b/.github/workflows/reusable-integration-test.yml similarity index 62% rename from .github/workflows/test_integration.yml rename to .github/workflows/reusable-integration-test.yml index 0748a451f3c..0d343a7d1a3 100644 --- a/.github/workflows/test_integration.yml +++ b/.github/workflows/reusable-integration-test.yml @@ -1,4 +1,4 @@ -name: Run Integration Tests +name: Reusable Integration Test Workflow permissions: contents: read @@ -16,6 +16,41 @@ on: - master schedule: - cron: "0 3 * * *" + workflow_call: + inputs: + target-branch: + description: 'Branch to checkout and test (defaults to the calling branch)' + required: false + type: string + default: '' + 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: 'integration' + target-repo: + description: 'Repository to post status to' + required: false + type: string + default: 'datadog-api-spec' + secrets: + PIPELINE_GITHUB_APP_ID: + required: false + PIPELINE_GITHUB_APP_PRIVATE_KEY: + required: false + DD_API_KEY: + required: true + DD_CLIENT_API_KEY: + required: true + DD_CLIENT_APP_KEY: + required: true + SLEEP_AFTER_REQUEST: + required: false concurrency: group: integration-${{ github.head_ref }} @@ -48,17 +83,20 @@ jobs: with: app-id: ${{ secrets.PIPELINE_GITHUB_APP_ID }} private-key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }} - repositories: datadog-api-spec + repositories: ${{ inputs.target-repo || 'datadog-api-spec' }} - name: Checkout code uses: actions/checkout@v3 + with: + repository: DataDog/datadog-api-client-java + ref: ${{ inputs.target-branch || github.ref }} - name: Post pending status check - if: github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/') + if: github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/') && (inputs.enable-status-reporting || github.event_name != 'workflow_call') uses: DataDog/github-actions/post-status-check@v2 with: github-token: ${{ steps.get_token.outputs.token }} - repo: datadog-api-spec + repo: ${{ inputs.target-repo || 'datadog-api-spec' }} status: pending - context: integration + context: ${{ inputs.status-context || 'integration' }} - name: Install Java uses: actions/setup-java@v3 with: @@ -85,18 +123,18 @@ jobs: RECORD: "none" SLEEP_AFTER_REQUEST: "${{ vars.SLEEP_AFTER_REQUEST }}" - name: Post failure status check - if: failure() && github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/') + if: failure() && github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/') && (inputs.enable-status-reporting || github.event_name != 'workflow_call') uses: DataDog/github-actions/post-status-check@v2 with: github-token: ${{ steps.get_token.outputs.token }} - repo: datadog-api-spec + repo: ${{ inputs.target-repo || 'datadog-api-spec' }} status: failure - context: integration + context: ${{ inputs.status-context || 'integration' }} - name: Post success status check - if: "!failure() && github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')" + if: "!failure() && github.event_name == 'pull_request' && contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/') && (inputs.enable-status-reporting || github.event_name != 'workflow_call')" uses: DataDog/github-actions/post-status-check@v2 with: github-token: ${{ steps.get_token.outputs.token }} - repo: datadog-api-spec + repo: ${{ inputs.target-repo || 'datadog-api-spec' }} status: success - context: integration + context: ${{ inputs.status-context || 'integration' }} diff --git a/.github/workflows/reusable-java-test.yml b/.github/workflows/reusable-java-test.yml new file mode 100644 index 00000000000..f2bb06e5523 --- /dev/null +++ b/.github/workflows/reusable-java-test.yml @@ -0,0 +1,62 @@ +name: Reusable Java Testing Workflow + +on: + workflow_call: + inputs: + target-branch: + description: 'Branch to checkout and test (defaults to the calling branch)' + required: false + type: string + default: '' + java-versions: + description: 'JSON array of Java versions to test against' + required: false + type: string + default: '["8", "16", "18", "19"]' + platforms: + description: 'JSON array of platforms to run tests on' + required: false + type: string + default: '["ubuntu-latest"]' + test-script: + description: 'Test script to execute' + required: false + type: string + default: './run-tests.sh' + secrets: + PIPELINE_GITHUB_APP_ID: + required: false + PIPELINE_GITHUB_APP_PRIVATE_KEY: + required: false + DD_API_KEY: + required: false + +jobs: + test: + strategy: + matrix: + java-version: ${{ fromJSON(inputs.java-versions) }} + platform: ${{ fromJSON(inputs.platforms) }} + 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: + - name: Checkout code + uses: actions/checkout@v3 + with: + repository: DataDog/datadog-api-client-java + ref: ${{ inputs.target-branch || github.ref }} + - name: Install Java + uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java-version }} + distribution: "temurin" + cache: "maven" + - name: Configure Datadog Test Optimization + uses: datadog/test-visibility-github-action@v2 + with: + languages: java + api_key: ${{ secrets.DD_API_KEY }} + - name: Test + run: ${{ inputs.test-script }} + env: + DD_CIVISIBILITY_COMPILER_PLUGIN_AUTO_CONFIGURATION_ENABLED: "false" \ No newline at end of file diff --git a/.github/workflows/reusable-javadoc.yml b/.github/workflows/reusable-javadoc.yml new file mode 100644 index 00000000000..21fe7690a8f --- /dev/null +++ b/.github/workflows/reusable-javadoc.yml @@ -0,0 +1,39 @@ +name: Reusable Javadoc Workflow + +on: + workflow_call: + inputs: + target-branch: + description: 'Branch to checkout and test (defaults to the calling branch)' + required: false + type: string + default: '' + java-version: + description: 'Java version to use for javadoc' + required: false + type: string + default: '8' + secrets: + PIPELINE_GITHUB_APP_ID: + required: false + PIPELINE_GITHUB_APP_PRIVATE_KEY: + required: false + +jobs: + javadoc: + 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 + with: + repository: DataDog/datadog-api-client-java + ref: ${{ inputs.target-branch || github.ref }} + - name: Install Java + uses: actions/setup-java@v3 + with: + java-version: ${{ inputs.java-version }} + distribution: "temurin" + cache: "maven" + - name: Build javadoc + run: mvn javadoc:javadoc + shell: bash \ No newline at end of file diff --git a/.github/workflows/reusable-pre-commit.yml b/.github/workflows/reusable-pre-commit.yml new file mode 100644 index 00000000000..97461939f94 --- /dev/null +++ b/.github/workflows/reusable-pre-commit.yml @@ -0,0 +1,93 @@ +name: Reusable Pre-commit Workflow + +on: + workflow_call: + inputs: + target-branch: + description: 'Branch to checkout and test (defaults to the calling branch)' + required: false + type: string + default: '' + enable-commit-changes: + description: 'Whether to commit and push pre-commit fixes' + required: false + type: boolean + default: true + secrets: + PIPELINE_GITHUB_APP_ID: + required: false + PIPELINE_GITHUB_APP_PRIVATE_KEY: + required: false + +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: + - name: Get GitHub App token + if: inputs.enable-commit-changes && github.event.pull_request.head.repo.full_name == github.repository + 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 }} + - uses: actions/checkout@v3 + if: github.event.pull_request.head.repo.full_name == github.repository + with: + fetch-depth: 0 + repository: DataDog/datadog-api-client-java + ref: ${{ inputs.target-branch || github.event.pull_request.head.sha || github.ref }} + token: ${{ inputs.enable-commit-changes && steps.get_token.outputs.token || github.token }} + - uses: actions/checkout@v3 + if: github.event.pull_request.head.repo.full_name != github.repository + with: + repository: DataDog/datadog-api-client-java + ref: ${{ inputs.target-branch || github.ref }} + - uses: actions/setup-python@v4 + with: + python-version: '3.11' + - name: Install pre-commit + run: python -m pip install pre-commit + - name: set PY + run: echo "PY=$(python -c 'import platform;print(platform.python_version())')" >> $GITHUB_ENV + - uses: actions/cache@v3 + with: + path: ~/.cache/pre-commit + key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} + - name: Install Java + uses: actions/setup-java@v3 + with: + java-version: "16" + distribution: "temurin" + cache: "maven" + - id: pre_commit + name: Run pre-commit + if: github.event.action != 'closed' && github.event.pull_request.merged != true + run: | + wget https://github.com/google/google-java-format/releases/download/v1.16.0/google-java-format-1.16.0-all-deps.jar -O google-java-format.jar + pre-commit run --verbose --from-ref "${FROM_REF}" --to-ref "${TO_REF}" --show-diff-on-failure --color=always + env: + FROM_REF: ${{ github.event.pull_request.base.sha }} + TO_REF: ${{ github.event.pull_request.head.sha }} + - name: Commit changes + if: failure() && inputs.enable-commit-changes && github.event.pull_request.head.repo.full_name == github.repository + 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 }} + GIT_AUTHOR_EMAIL: "packages@datadoghq.com" + GIT_AUTHOR_NAME: "ci.datadog-api-spec" + - 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 \ No newline at end of file diff --git a/.github/workflows/reusable-shading.yml b/.github/workflows/reusable-shading.yml new file mode 100644 index 00000000000..eac1e6eef8a --- /dev/null +++ b/.github/workflows/reusable-shading.yml @@ -0,0 +1,38 @@ +name: Reusable Shading Workflow + +on: + workflow_call: + inputs: + target-branch: + description: 'Branch to checkout and test (defaults to the calling branch)' + required: false + type: string + default: '' + java-version: + description: 'Java version to use for shading check' + required: false + type: string + default: '8' + secrets: + PIPELINE_GITHUB_APP_ID: + required: false + PIPELINE_GITHUB_APP_PRIVATE_KEY: + required: false + +jobs: + shading: + 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 + with: + repository: DataDog/datadog-api-client-java + ref: ${{ inputs.target-branch || github.ref }} + - name: Install Java + uses: actions/setup-java@v3 + with: + java-version: ${{ inputs.java-version }} + distribution: "temurin" + cache: "maven" + - name: Check all dependencies shaded + run: ./shade-test.sh \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b7ad2fda798..963431dedb1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,138 +20,60 @@ concurrency: 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: - - name: Get GitHub App token - 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 }} - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.sha }} - token: ${{ steps.get_token.outputs.token }} - - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - name: Install pre-commit - run: python -m pip install pre-commit - - name: set PY - run: echo "PY=$(python -c 'import platform;print(platform.python_version())')" >> $GITHUB_ENV - - uses: actions/cache@v3 - with: - path: ~/.cache/pre-commit - key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} - - name: Install Java - uses: actions/setup-java@v3 - with: - java-version: "16" - distribution: "temurin" - cache: "maven" - - id: pre_commit - name: Run pre-commit - if: github.event.action != 'closed' && github.event.pull_request.merged != true - run: | - wget https://github.com/google/google-java-format/releases/download/v1.16.0/google-java-format-1.16.0-all-deps.jar -O google-java-format.jar - pre-commit run --verbose --from-ref "${FROM_REF}" --to-ref "${TO_REF}" --show-diff-on-failure --color=always - env: - FROM_REF: ${{ github.event.pull_request.base.sha }} - TO_REF: ${{ github.event.pull_request.head.sha }} - - name: Commit changes - if: ${{ 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 + uses: ./.github/workflows/reusable-pre-commit.yml + with: + enable-commit-changes: true + secrets: + PIPELINE_GITHUB_APP_ID: ${{ secrets.PIPELINE_GITHUB_APP_ID }} + PIPELINE_GITHUB_APP_PRIVATE_KEY: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }} javadoc: - 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 Java - uses: actions/setup-java@v3 - with: - java-version: "8" - distribution: "temurin" - cache: "maven" - - name: Build javadoc - run: mvn javadoc:javadoc - shell: bash + 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-javadoc.yml shading: - 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 Java - uses: actions/setup-java@v3 - with: - java-version: "8" - distribution: "temurin" - cache: "maven" - - name: Check all dependencies shaded - run: ./shade-test.sh + 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-shading.yml test: - strategy: - matrix: - # see DEVELOPMENT.md for information why we're using this specific combination - # of JDKs to run unit tests on - java-version: ["8", "16", "18", "19"] - - 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: - - name: Checkout code - uses: actions/checkout@v3 - - name: Install Java - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java-version }} - distribution: "temurin" - cache: "maven" - - name: Configure Datadog Test Optimization - uses: datadog/test-visibility-github-action@v2 - with: - languages: java - api_key: ${{ secrets.DD_API_KEY }} - - name: Test - run: ./run-tests.sh - env: - DD_CIVISIBILITY_COMPILER_PLUGIN_AUTO_CONFIGURATION_ENABLED: "false" - + 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-java-test.yml + with: + java-versions: '["8", "16", "18", "19"]' + platforms: '["ubuntu-latest"]' + test-script: './run-tests.sh' + secrets: + PIPELINE_GITHUB_APP_ID: ${{ secrets.PIPELINE_GITHUB_APP_ID }} + PIPELINE_GITHUB_APP_PRIVATE_KEY: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }} + DD_API_KEY: ${{ secrets.DD_API_KEY }} + 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 Java - uses: actions/setup-java@v3 - with: - java-version: "16" - distribution: "temurin" - cache: "maven" - - name: Check examples - run: ./check-examples.sh - shell: bash + 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-examples.yml + with: + examples-script: './check-examples.sh' + java-version: '16' report: runs-on: ubuntu-latest @@ -160,6 +82,7 @@ jobs: - test - examples - javadoc + - shading steps: - name: Get GitHub App token if: github.event_name == 'pull_request' @@ -174,6 +97,5 @@ jobs: with: github-token: ${{ steps.get_token.outputs.token }} repo: datadog-api-spec - status: ${{ (needs.javadoc.result == 'cancelled' || needs.test.result == 'cancelled' || needs.examples.result == 'cancelled') && 'pending' || needs.javadoc.result == 'success' && needs.test.result == 'success' && needs.examples.result - == 'success' && 'success' || 'failure' }} + status: ${{ (needs.javadoc.result == 'cancelled' || needs.test.result == 'cancelled' || needs.examples.result == 'cancelled' || needs.shading.result == 'cancelled') && 'pending' || (needs.javadoc.result == 'success' && needs.test.result == 'success' && needs.examples.result == 'success' && needs.shading.result == 'success') && 'success' || 'failure' }} context: master/unit