Skip to content

elastic/otel-upload-test-artifact-action

 
 

Repository files navigation

Open Telemetry Upload Test Artifact Action

NOTE: This action is a forked version of opentelemetry-upload-trace-artifact.

This action is a companion Action to otel-export-trace-action.

This Action will transform a Test Report to an OTLP Trace log file and Upload as a Github Artifact so that otel-export-trace-action can download and link to the Github Workflow step span that produced it before exporting to the OTLP destination.

Usage

code-quality-pr-check.yml

name: "code quality PR check"

on:
  pull_request:
    branches: [main]

jobs:
  lint-and-test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
      - name: Install Dependencies
        run: npm ci --ignore-scripts
      - name: lint
        run: npm run lint:ci
      - name: run tests
        run: npm run test:ci
      - uses: elastic/otel-upload-test-artifact-action@latest
        if: always()
        continue-on-error: true
        with:
          jobName: "lint-and-test"
          stepName: "run tests"
          path: "junit.xml"
          type: "junit"
          githubToken: ${{ secrets.GITHUB_TOKEN }}

otel-export-trace.yml

name: OpenTelemetry Export Trace

on:
  workflow_run:
    workflows:
      - "code quality PR check"
    types: [completed]

jobs:
  otel-export-trace:
    name: OpenTelemetry Export Trace
    runs-on: ubuntu-latest
    steps:
      - name: export trace
        uses: elastic/otel-export-trace-action@latest
        with:
          otlpEndpoint: ${{ secrets.OTLP_ENDPOINT }}
          otlpHeaders: ${{ secrets.OTLP_HEADERS }}
          otelServiceName: ${{ github.repository }}
          githubToken: ${{ secrets.GITHUB_TOKEN }}
          runId: ${{ github.event.workflow_run.id }}

With Matrix Strategy

When using this action with a Matrix strategy you will need to append the matrix outputs to the jobName input argument surrounded by parenthesis. Tip: if you struggle to get the right formatting look at workflow run in Actions and see what the display name is for the matrix builds.

name: "code quality PR check"

on:
  pull_request:
    branches: [main]

jobs:
  lint-and-test:
    strategy:
      matrix:
        os: ["ubuntu-latest", "windows-latest", "macos-latest"]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
      - name: Install Dependencies
        run: npm ci --ignore-scripts
      - name: lint
        run: npm run lint:ci
      - name: run tests
        run: npm run test:ci
      - uses: elastic/otel-upload-test-artifact-action@latest
        if: always()
        continue-on-error: true
        with:
          jobName: "lint-and-test (${{ matrix.os }})"
          stepName: "run tests"
          path: "junit.xml"
          type: "junit"
          githubToken: ${{ secrets.GITHUB_TOKEN }}

Using Glob pattern matching

You can target multiple test reports using Glob filter pattern syntax. This will allow you to trace test reports that are segmented into different files by Test Suite.

name: "code quality PR check"

on:
  pull_request:
    branches: [main]

jobs:
  lint-and-test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
      - name: Install Dependencies
        run: npm ci --ignore-scripts
      - name: lint
        run: npm run lint:ci
      - name: run tests
        run: npm run test:ci
      - uses: elastic/otel-upload-test-artifact-action@latest
        if: always()
        continue-on-error: true
        with:
          jobName: "lint-and-test"
          stepName: "run tests"
          path: "junit-reports/*.xml"
          type: "junit"
          githubToken: ${{ secrets.GITHUB_TOKEN }}

Action Inputs

name description required default
jobName The name of the Job that produced the file to upload true
stepName The name of the Step that produced the file to upload true
path The path to the file to Upload true
type The type of artifact to upload. Currently only supports, junit false junit

Trace Unique Fields

name type description
name string Test Run/Suite/Case name
error string Test Run/Suite/Case name
test.id string Test Scope ID
test.name string Test Run/Suite/Case name
test.source string Test source: Junit, xUnit, ngunit
test.scope string Scope of the Test Span: Run, Suite, Case
test.tests integer Number of Tests
test.failures integer Number of Test Failures
test.errors integer Number of Test Errors
test.disables integer Number of Tests Disabled
test.skips integer Number of Tests Skipped
test.time float Duration of the Test Scope
test.timestamp string Start Timestamp for the Test Scope
test.hostname string Test Scope hostname
test.package string Test Scope package
test.classname string Test Scope Classname
test.system.out string Test Scope System Out
test.system.err string Test Scope System Error
test.status string Test Case Status: PASS, FAIL
test.assertions integer Number of Test Assertions
test.skipped.{index}.message string Test Skipped Message
test.error.{index}.message string Test Error Message
test.error.{index}.type string Test Error Type
test.error.{index}.inner string Test Error System Out
test.failure.{index}.message string Test Failure Message
test.failure.{index}.type string Test Failure Type
test.failure.{index}.inner string Test Failure System Out

Limitations

Currently only supports Junit Test Reports

About

No description, website, or topics provided.

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 98.6%
  • JavaScript 1.1%
  • Shell 0.3%