Skip to content

Commit 7628675

Browse files
Use reports auto-discovery by default. Make service input optional (#25)
1 parent a9080e2 commit 7628675

3 files changed

Lines changed: 42 additions & 62 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea/

README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
# Datadog JUnitXML Upload Actions
1+
# Datadog JUnitXML Upload Action
22

33
This action downloads the [datadog-ci](https://github.com/DataDog/datadog-ci) and uses it to upload JUnitXML files
4-
to the [CI Visibility product](https://docs.datadoghq.com/continuous_integration/).
4+
to the [Test Optimization product](https://docs.datadoghq.com/tests/).
55

66
This action sets up node and requires node `>=14`. You can configure a specific version of node to use.
7-
Note that if you have setup another version already it will override it.
7+
Note that if you have set up another version already it will override it.
88

99
## Usage
1010

1111
```yaml
1212
name: Test Code
13-
on: [push]
13+
on: [ push ]
1414
jobs:
1515
test:
1616
steps:
1717
- uses: actions/checkout@v3
1818
- run: make tests
19-
- uses: datadog/junit-upload-github-action@v1
19+
- uses: datadog/junit-upload-github-action@v2
2020
with:
21-
api_key: ${{ secrets.DD_API_KEY }}
22-
service: my-app
23-
files: ./reports/
21+
api_key: ${{ secrets.DD_API_KEY }}
2422
```
2523
2624
## Inputs
2725
2826
The action has the following options:
2927
30-
| Name | Description | Required | Default |
31-
| ---- | ----------- | -------- | ------- |
32-
| `api_key` | Datadog API key to use to upload the junit files. | True | |
33-
| `service` | Service name to use with the uploaded test results. | True | |
34-
| `site` | The Datadog site to upload the files to. | True | `datadoghq.com` |
35-
| `files` | Path to file or folder containing XML files to upload | True | `.` |
36-
| `concurrency` | Controls the maximum number of concurrent file uploads | True | `20` |
37-
| `node-version` | The node version to use to install the datadog-ci. It must be `>=14` | True | `20` |
38-
| `tags` | Optional extra tags to add to the tests formatted as a comma separated list of tags. Example: `foo:bar,data:dog` | False | |
39-
| `env` | Optional environment to add to the tests | False | |
40-
| `logs` | When set to "true" enables forwarding content from the XML reports as Logs. The content inside `<system-out>`, `<system-err>`, and `<failure>` is collected as logs. Logs from elements inside a `<testcase>` are automatically connected to the test. | False | |
41-
| `datadog-ci-version` | Optionally pin the @datadog/datadog-ci version. | False | `latest` |
42-
| `extra-args` | Extra args to be passed to the datadog-ci junit upload command.| False | |
28+
| Name | Description | Required | Default |
29+
|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|-----------------|
30+
| `api_key` | Datadog API key to use to upload the junit files. | True | |
31+
| `site` | The Datadog site to upload the files to. | False | `datadoghq.com` |
32+
| `files` | Path to file or folder containing XML files to upload | False | `.` |
33+
| `auto-discovery` | Do a recursive search and automatic XML files discovery in the folders provided in `files` input (current folder if omitted). | False | `true` |
34+
| `ignored-paths` | A comma-separated list of paths that are ignored when junit files auto-discovery is done. Glob patterns are supported. | False | |
35+
| `concurrency` | Controls the maximum number of concurrent file uploads | False | `20` |
36+
| `node-version` | The node version to use to install the datadog-ci. It must be `>=14` | False | `20` |
37+
| `tags` | Optional extra tags to add to the tests formatted as a comma separated list of tags. Example: `foo:bar,data:dog` | False | |
38+
| `service` | Service name to use with the uploaded test results. | False | |
39+
| `env` | Optional environment to add to the tests | False | |
40+
| `logs` | When set to "true" enables forwarding content from the XML reports as Logs. The content inside `<system-out>`, `<system-err>`, and `<failure>` is collected as logs. Logs from elements inside a `<testcase>` are automatically connected to the test. | False | |
41+
| `datadog-ci-version` | Optionally pin the @datadog/datadog-ci version. | False | `latest` |
42+
| `extra-args` | Extra args to be passed to the datadog-ci junit upload command. | False | |

action.yaml

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
1-
# Composite action to upload junit test result files to Datadog CI Visibility
1+
# Composite action to upload junit test result files to Datadog Test Optimization
22
name: "Datadog JUnitXML Upload"
3-
description: "Upload JUnitXML reports files to Datadog CI Visibility"
3+
description: "Upload JUnitXML reports files to Datadog Test Optimization"
44
inputs:
5-
api-key:
6-
required: false
7-
description: (Deprecated) Datadog API key to use to upload the junit files.
8-
deprecationMessage: "This input is deprecated. Use `api_key` instead."
95
api_key:
10-
required: false
11-
description: Datadog API key to use to upload the junit files.
12-
service:
136
required: true
14-
description: Service name to use with the uploaded test results.
15-
datadog-site:
16-
required: false
17-
default: datadoghq.com
18-
description: (Deprecated) The Datadog site to upload the files to.
19-
deprecationMessage: "This input is deprecated. Use `site` instead."
7+
description: Datadog API key to use to upload the junit files.
208
site:
219
required: false
2210
default: datadoghq.com
@@ -25,6 +13,13 @@ inputs:
2513
required: true
2614
description: JUnit files to upload.
2715
default: .
16+
auto-discovery:
17+
required: true
18+
description: Do a recursive search and automatic junit files discovery in the folders provided in `files` input (current folder if omitted).
19+
default: 'true'
20+
ignored-paths:
21+
required: false
22+
description: A comma-separated list of paths that are ignored when junit files auto-discovery is done. Glob patterns are supported
2823
concurrency:
2924
required: true
3025
description: Controls the maximum number of concurrent file uploads.
@@ -36,6 +31,9 @@ inputs:
3631
tags:
3732
required: false
3833
description: Datadog tags to associate with the uploaded test results.
34+
service:
35+
required: false
36+
description: Service name to use with the uploaded test results.
3937
env:
4038
required: false
4139
description: Datadog env to use for the tests.
@@ -57,39 +55,20 @@ runs:
5755
uses: actions/setup-node@v4
5856
with:
5957
node-version: ${{ inputs.node-version }}
60-
- name: Check if input values are correct
61-
shell: bash
62-
run: |
63-
if [ -z "${{ inputs.api_key }}" ] && [ -z "${{ inputs.api-key }}" ]; then
64-
echo "Error: Both api_key and api-key are undefined. At least one must be defined."
65-
exit 1
66-
fi
67-
- name: Upload the JUnit files
68-
if: ${{ inputs.logs == 'true' }}
69-
shell: bash
70-
run: |
71-
npx @datadog/datadog-ci@${{ inputs.datadog-ci-version}} junit upload \
72-
--service ${{ inputs.service }} \
73-
--logs \
74-
--max-concurrency ${{ inputs.concurrency }} \
75-
${{ inputs.extra-args }} \
76-
${{ inputs.files }}
77-
env:
78-
DATADOG_API_KEY: ${{ inputs.api_key != '' && inputs.api_key || inputs.api-key }}
79-
DATADOG_SITE: ${{ inputs.site != '' && inputs.site || inputs.datadog-site }}
80-
DD_ENV: ${{ inputs.env }}
81-
DD_TAGS: ${{ inputs.tags }}
58+
8259
- name: Upload the JUnit files
83-
if: ${{ inputs.logs != 'true' }}
8460
shell: bash
8561
run: |
8662
npx @datadog/datadog-ci@${{ inputs.datadog-ci-version}} junit upload \
87-
--service ${{ inputs.service }} \
8863
--max-concurrency ${{ inputs.concurrency }} \
64+
${{ inputs.logs == 'true' && '--logs' || '' }} \
65+
${{ inputs.auto-discovery == 'true' && '--auto-discovery' || '' }} \
66+
${{ inputs.ignored-paths != '' && format('--ignored-paths {0}', inputs.ignored-paths) || '' }} \
67+
${{ inputs.service != '' && format('--service {0}', inputs.service) || '' }} \
8968
${{ inputs.extra-args }} \
9069
${{ inputs.files }}
9170
env:
92-
DATADOG_API_KEY: ${{ inputs.api_key != '' && inputs.api_key || inputs.api-key }}
93-
DATADOG_SITE: ${{ inputs.site != '' && inputs.site || inputs.datadog-site }}
71+
DD_API_KEY: ${{ inputs.api_key }}
72+
DD_SITE: ${{ inputs.site }}
9473
DD_ENV: ${{ inputs.env }}
9574
DD_TAGS: ${{ inputs.tags }}

0 commit comments

Comments
 (0)