From f5a61999a6ff608eb1aff2d705a74864abdd0fc9 Mon Sep 17 00:00:00 2001 From: Juan Fernandez Date: Tue, 28 May 2024 13:26:20 +0200 Subject: [PATCH 1/2] add version option --- .github/workflows/test.yaml | 22 +++++++++++++++++++++- README.md | 3 ++- action.yaml | 8 ++++++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 24b6072..4e9ccd4 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -34,4 +34,24 @@ jobs: EXTRA_TAGS: "@foo:bar @alpha:bravo @test.node.version:${{ matrix.version}}" 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 \ No newline at end of file + DD_SERVICE: junit-upload-github-action-tests + test-older-datadog-ci-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Grab second latest version of @datadog/datadog-ci + run: | + SECOND_LATEST_VERSION=$(curl -s "https://api.github.com/repos/datadog/datadog-ci/releases" | jq '[.[] | {tag_name: .tag_name, published_at: .published_at}] | sort_by(.published_at) | reverse | .[:2] | .[1] | .tag_name') + CLEAN_TAG_NAME=${SECOND_LATEST_VERSION#v} + echo "CLEAN_TAG_NAME=$CLEAN_TAG_NAME" >> $GITHUB_ENV + - name: Upload reports using a glob pattern + uses: ./ + with: + 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" + datadog-ci-version: ${{ env.CLEAN_TAG_NAME }} + \ No newline at end of file diff --git a/README.md b/README.md index 0f3d3d9..d2e1b51 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This action downloads the [datadog-ci](https://github.com/DataDog/datadog-ci) and uses it to upload JUnitXML files to the [CI Visibility product](https://docs.datadoghq.com/continuous_integration/). -This action sets up node and requires node `>=10.24.1`. You can configure a specific version of node to use. +This action sets up node and requires node `>=14`. You can configure a specific version of node to use. Note that if you have setup another version already it will override it. ## Usage @@ -38,4 +38,5 @@ The action has the following options: | `tags` | Optional extra tags to add to the tests | False | | | `env` | Optional environment to add to the tests | False | | | `logs` | When set to "true" enables forwarding content from the XML reports as Logs. The content inside ``, ``, and `` is collected as logs. Logs from elements inside a `` are automatically connected to the test. | False | | +| `datadog-ci-version` | Optionally pin the @datadog/datadog-ci version. | False | `latest` | | `extra-args` | Extra args to be passed to the datadog-ci junit upload command.| False | | diff --git a/action.yaml b/action.yaml index f8dac84..c26028a 100644 --- a/action.yaml +++ b/action.yaml @@ -33,6 +33,10 @@ inputs: logs: required: false description: Set to "true" to enable forwarding content from XML reports as logs. + datadog-ci-version: + required: false + description: The version of the @datadog/datadog-ci package to use. It defaults to the latest release (`latest`). + default: "latest" extra-args: default: "" description: Extra args to be passed to the datadog-ci cli. @@ -48,7 +52,7 @@ runs: if: ${{ inputs.logs == 'true' }} shell: bash run: | - npx @datadog/datadog-ci junit upload \ + npx @datadog/datadog-ci@${{ inputs.datadog-ci-version}} junit upload \ --service ${{ inputs.service }} \ --logs \ --max-concurrency ${{ inputs.concurrency }} \ @@ -63,7 +67,7 @@ runs: if: ${{ inputs.logs != 'true' }} shell: bash run: | - npx @datadog/datadog-ci junit upload \ + npx @datadog/datadog-ci@${{ inputs.datadog-ci-version}} junit upload \ --service ${{ inputs.service }} \ --max-concurrency ${{ inputs.concurrency }} \ ${{ inputs.extra-args }} \ From 76c9ae0bc6b706102fa71fe5a12edffa1e727b95 Mon Sep 17 00:00:00 2001 From: Juan Fernandez Date: Tue, 28 May 2024 13:57:19 +0200 Subject: [PATCH 2/2] remove unnecessary logic --- .github/workflows/test.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4e9ccd4..ed8c581 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -42,8 +42,7 @@ jobs: - name: Grab second latest version of @datadog/datadog-ci run: | SECOND_LATEST_VERSION=$(curl -s "https://api.github.com/repos/datadog/datadog-ci/releases" | jq '[.[] | {tag_name: .tag_name, published_at: .published_at}] | sort_by(.published_at) | reverse | .[:2] | .[1] | .tag_name') - CLEAN_TAG_NAME=${SECOND_LATEST_VERSION#v} - echo "CLEAN_TAG_NAME=$CLEAN_TAG_NAME" >> $GITHUB_ENV + echo "SECOND_LATEST_VERSION=$SECOND_LATEST_VERSION" >> $GITHUB_ENV - name: Upload reports using a glob pattern uses: ./ with: @@ -53,5 +52,5 @@ jobs: service: junit-upload-github-action-tests env: ci tags: "foo:bar,alpha:bravo" - datadog-ci-version: ${{ env.CLEAN_TAG_NAME }} + datadog-ci-version: ${{ env.SECOND_LATEST_VERSION }} \ No newline at end of file