Skip to content
Merged
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
35 changes: 32 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Upload reports using a glob pattern
uses: ./
with:
api-key: ${{secrets.DD_API_KEY_CI_VISIBILITY}}
api_key: ${{secrets.DD_API_KEY_CI_VISIBILITY}}
logs: "true"
files: '**/fixtures/**'
service: junit-upload-github-action-tests
Expand All @@ -46,11 +46,40 @@ jobs:
- name: Upload reports using a glob pattern
uses: ./
with:
# should still work with api-key as input
api-key: ${{secrets.DD_API_KEY_CI_VISIBILITY}}
logs: "true"
files: '**/fixtures/**'
service: junit-upload-github-action-tests
env: ci
tags: "foo:bar,alpha:bravo"
tags: "foo:previous,alpha:previous"
datadog-ci-version: ${{ env.SECOND_LATEST_VERSION }}

- name: Check that test data can be queried
run: |
npm install @datadog/datadog-api-client
node ./check-junit-upload.js
env:
EXTRA_TAGS: "@foo:previous @alpha:previous"
DD_API_KEY: ${{ secrets.DD_API_KEY_CI_VISIBILITY }}
DD_APP_KEY: ${{ secrets.DD_APP_KEY_CI_VISIBILITY }}
DD_SERVICE: junit-upload-github-action-tests

test-should-complain-about-missing-api-key:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Upload reports using a glob pattern
uses: ./
id: test_step
with:
logs: "true"
files: '**/fixtures/**'
service: junit-upload-github-action-tests
env: ci
tags: "foo:bar,alpha:bravo"
continue-on-error: true
- name: Check that previous step failed
if: steps.test_step.outcome == 'success'
run: |
echo "The previous step did not fail as expected"
exit 1
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- run: make tests
- uses: datadog/junit-upload-github-action@v1
with:
api-key: ${{ secrets.DD_API_KEY }}
api_key: ${{ secrets.DD_API_KEY }}
service: my-app
files: ./reports/
```
Expand All @@ -29,9 +29,9 @@ The action has the following options:

| Name | Description | Required | Default |
| ---- | ----------- | -------- | ------- |
| `api-key` | Datadog API key to use to upload the junit files. | True | |
| `api_key` | Datadog API key to use to upload the junit files. | True | |
| `service` | Service name to use with the uploaded test results. | True | |
| `datadog-site` | The Datadog site to upload the files to. | True | `datadoghq.com` |
| `site` | The Datadog site to upload the files to. | True | `datadoghq.com` |
| `files` | Path to file or folder containing XML files to upload | True | `.` |
| `concurrency` | Controls the maximum number of concurrent file uploads | True | `20` |
| `node-version` | The node version to use to install the datadog-ci. It must be `>=14` | True | `20` |
Expand Down
28 changes: 22 additions & 6 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@ name: "Datadog JUnitXML Upload"
description: "Upload JUnitXML reports files to Datadog CI Visibility"
inputs:
api-key:
required: true
required: false
description: (Deprecated) Datadog API key to use to upload the junit files.
Comment thread
juan-fernandez marked this conversation as resolved.
deprecationMessage: "This input is deprecated. Use `api_key` instead."
api_key:
required: false
description: Datadog API key to use to upload the junit files.
service:
required: true
description: Service name to use with the uploaded test results.
datadog-site:
required: true
required: false
default: datadoghq.com
description: (Deprecated) The Datadog site to upload the files to.
deprecationMessage: "This input is deprecated. Use `site` instead."
site:
required: false
default: datadoghq.com
description: The Datadog site to upload the files to.
files:
Expand Down Expand Up @@ -48,6 +57,13 @@ runs:
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
- name: Check if input values are correct
shell: bash
run: |
if [ -z "${{ inputs.api_key }}" ] && [ -z "${{ inputs.api-key }}" ]; then
echo "Error: Both api_key and api-key are undefined. At least one must be defined."
exit 1
fi
- name: Upload the JUnit files
if: ${{ inputs.logs == 'true' }}
shell: bash
Expand All @@ -59,8 +75,8 @@ runs:
${{ inputs.extra-args }} \
${{ inputs.files }}
env:
DATADOG_API_KEY: ${{ inputs.api-key }}
DATADOG_SITE: ${{ inputs.datadog-site }}
DATADOG_API_KEY: ${{ inputs.api_key != '' && inputs.api_key || inputs.api-key }}
DATADOG_SITE: ${{ inputs.site != '' && inputs.site || inputs.datadog-site }}
DD_ENV: ${{ inputs.env }}
DD_TAGS: ${{ inputs.tags }}
- name: Upload the JUnit files
Expand All @@ -73,7 +89,7 @@ runs:
${{ inputs.extra-args }} \
${{ inputs.files }}
env:
DATADOG_API_KEY: ${{ inputs.api-key }}
DATADOG_SITE: ${{ inputs.datadog-site }}
DATADOG_API_KEY: ${{ inputs.api_key != '' && inputs.api_key || inputs.api-key }}
DATADOG_SITE: ${{ inputs.site != '' && inputs.site || inputs.datadog-site }}
DD_ENV: ${{ inputs.env }}
DD_TAGS: ${{ inputs.tags }}