# CI Flaky Test Trend API (`afkdigital/newapi94-ci-flaky-test-trend`) Actor

Analyze JUnit evidence across exact commits and environments. Separate retries, skipped outcomes and independent flaky candidates without executing tests.

- **URL**: https://apify.com/afkdigital/newapi94-ci-flaky-test-trend.md
- **Developed by:** [AFK Digital](https://apify.com/afkdigital) (community)
- **Categories:** Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.00 / 1,000 inspected test results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## CI Flaky Test Trend API

Analyze JUnit XML reports across CI runs without connecting a repository or executing customer code. Identify mixed pass/fail evidence on the same commit and environment, inspect retry effort, and export reviewable results.

### Quick start

Run with an empty input for the built-in 12-result demo (normally seconds). For your own reports supply junitFiles: \[{name: "run1.xml", xml: "<testsuite>...</testsuite>"}] and runsManifest: \[{file: "run1.xml", run_id: "build-1", commit: "full-commit-sha", attempt: 0, environment: {platform: "linux", runtime: "3.12"}, parameters: {}}].
Alternatively provide reportsZip: {base64: "..."} with matching manifest entries for every XML member. Reports are inline file contents/base64, not URLs. No CI/repository credentials needed. Do not include access tokens in metadata.

### Identity and comparisons

The test_id is a deterministic SHA-256 based ID from classname, complete test name (parameters retained), testcase properties, manifest parameters, file attribute and suite ancestry. File and suite inclusion can be disabled explicitly using testIdentityRules.includeFile/includeSuite; class/name/properties/parameters are always preserved. IDs are hashed to protect names; locate the test by applying the same identity to your source report, then use evidence_runs run_id and attempt to inspect original evidence. Ambiguous repeated identities within a report are rejected. Preserve parameter labels in JUnit names/properties or manifest parameters.
Each row is one test, commit and exact environment object. environmentDimensions specifies REQUIRED keys, never discarded keys. Include platform, OS, browser, runtime, dependency and relevant config versions. Unknown commit or environment is rejected rather than pooled.

Each independent run has a unique run_id and attempt=0. Retries use the SAME run_id and explicit attempt>=1. Shards of one attempt share the run_id/attempt and have separate manifest file mappings. Retry attempts cannot inflate comparable_runs. Surefire flakyFailure/flakyError describe failures before the final passing testcase; rerunFailure/rerunError describe failures after the initial failing testcase. Both preserve their distinct duration semantics. Overlapping embedded and separate manifest retries for a test/run are rejected; choose one representation. Other vendor retry formats are unsupported; normalize those into separate manifest attempts. Missing tests do not imply pass or skip. An orphan retry cannot supply independent evidence.

### Candidate statuses

- stable_pass / stable_fail: at least minComparableRuns (default 3) non-skipped independent initial outcomes all agree, within supplied scope.
- flaky_candidate: both passed and failed independent initial outcomes, with enough non-skipped evidence. A candidate is not causal proof of flakiness.
- retry_instability_candidate: pass/fail variation within a retry chain; separate from independent-run proof.
- insufficient_evidence: too few comparable non-skipped observations.
- skipped_only: independent initial observations are all skipped.

passed_runs, failed_runs and skipped_runs count initial outcomes only. comparable_runs includes skipped observations; the evidence threshold uses non-skipped observations. Skipped is never successful. Commit changes are presented as separate rows, never evidence of same-code flakiness. This tool does not determine why a test is unstable or compare branch performance causally.

### Output and trend summary

Default Dataset: JSON and CSV exports. Each row contains test_id, commit, environment_group, comparable_runs, passed_runs, failed_runs, skipped_runs, candidate_status, retry_duration, retry_results and evidence_runs. Key-value records RESULTS, RESULTS.csv and SUMMARY provide complete exports and counts by status across supplied groups.
No chronological ordering is inferred from opaque run IDs or commits. The summary describes the supplied cross-run evidence and per-commit rows; supply repeated windows to monitor trends. No test history is fetched externally.
retry_duration is the sum of reported retry test durations in seconds only when ALL retry durations are available; otherwise null. No retry also yields null. Initial attempt duration is excluded. This is neither CI wall-clock time nor a billing/savings estimate: parallel tests and runner overhead prevent that interpretation.

### Privacy and safety

redactFailureMessages=true by default omits all failure messages and traces. Set false ONLY to expose up to 1000 characters from each failure message/body. system-out/system-err are never returned. Metadata commit/environment/run_id is customer supplied and retained; sanitize it before submission. Reports may contain sensitive data and are uploaded to Apify as Actor input subject to your Apify retention policy. No customer code or tests are executed.
defusedxml rejects DTDs and external/internal entities. ZIP members are read in memory; no filesystem extraction, absolute paths, traversal, links or non-XML files. Limits: 500 files/members, 32 MiB total expanded XML, 32 MiB compressed archive, 100000 unique outcomes, 100000 total XML nodes and depth 64, soft analysis limit 120 seconds plus hard wrapper limit 150 seconds. Actor default timeout is 240 seconds. UTF-8 XML only in ZIP. Reject over-limit/invalid inputs before result-event charging.

### Pricing

USD 1 per 1000 unique inspected test outcomes ($0.001 each), exactly prorated; an initial outcome and every retry outcome are counted, including skipped. Not per output row. Duplicated reports/results for the same run/attempt/test are counted once; identical reports from distinct independent run IDs remain distinct evidence. Deduplication is within one Actor run, not across separate customer invocations.
The price is USD 1 per 1000 unique inspected outcomes, with no startup fee or extra Dataset item fee. Platform compute is included in the event price.
Charging runs only after complete validation. The complete event budget is preflighted before charging; an insufficient budget is rejected with no test-result event charge. A rare concurrent platform limit change can still prevent complete charging; no partial analysis is published. Set an adequate maximum charge before starting. Production requires configured pay-per-event pricing and rejects a missing result event.

### Development

Python 3.12+, pip install -r requirements.txt; python -m unittest discover -s tests -v. Docker runs python -m src. Version 0.1.0. Product NEWAPI94, AFK Digital.

# Actor input Schema

## `demo` (type: `boolean`):

Use included demo when no reports supplied. See README for exact semantics and limits.

## `junitFiles` (type: `array`):

Objects {name, xml}; upload file contents as UTF-8 JSON strings. No URLs or code execution.

## `reportsZip` (type: `object`):

Object {base64: ZIP_BYTES_BASE64}. XML only; max 32 MiB uncompressed, 500 members.

## `runsManifest` (type: `array`):

One mapping per report: file, run_id, commit, attempt (0 initial; 1+ retries sharing run_id), environment. Optional parameters. All environment keys are preserved.

## `testIdentityRules` (type: `object`):

Only includeFile/includeSuite booleans. Class, full parameterized name, properties and manifest parameters always included. Names are hashed.

## `minComparableRuns` (type: `integer`):

Minimum independent comparable runs. See README for exact semantics and limits.

## `environmentDimensions` (type: `array`):

Required keys; never drops other environment keys. Include platform, runtime, browser and relevant dependency/config information in each environment.

## `maxTestResults` (type: `integer`):

Maximum unique test outcomes. See README for exact semantics and limits.

## `redactFailureMessages` (type: `boolean`):

Keep enabled to prevent secrets from failure messages entering outputs. Disabling exposes up to 1000 characters per failure. Console output is never exported.

## Actor input object example

```json
{
  "demo": true,
  "junitFiles": [
    {
      "name": "run0.xml",
      "xml": "<testsuite name=\"demo\"><testcase classname=\"Demo\" name=\"stable-pass\" time=\"0.02\"></testcase><testcase classname=\"Demo\" name=\"stable-fail\" time=\"0.02\"><failure message=\"token=DEMO_SECRET\"/></testcase><testcase classname=\"Demo\" name=\"variable\" time=\"0.02\"></testcase><testcase classname=\"Demo\" name=\"skipped\" time=\"0.02\"><skipped/></testcase></testsuite>"
    },
    {
      "name": "run1.xml",
      "xml": "<testsuite name=\"demo\"><testcase classname=\"Demo\" name=\"stable-pass\" time=\"0.02\"></testcase><testcase classname=\"Demo\" name=\"stable-fail\" time=\"0.02\"><failure message=\"token=DEMO_SECRET\"/></testcase><testcase classname=\"Demo\" name=\"variable\" time=\"0.02\"><failure/></testcase><testcase classname=\"Demo\" name=\"skipped\" time=\"0.02\"><skipped/></testcase></testsuite>"
    },
    {
      "name": "run2.xml",
      "xml": "<testsuite name=\"demo\"><testcase classname=\"Demo\" name=\"stable-pass\" time=\"0.02\"></testcase><testcase classname=\"Demo\" name=\"stable-fail\" time=\"0.02\"><failure message=\"token=DEMO_SECRET\"/></testcase><testcase classname=\"Demo\" name=\"variable\" time=\"0.02\"></testcase><testcase classname=\"Demo\" name=\"skipped\" time=\"0.02\"><skipped/></testcase></testsuite>"
    }
  ],
  "runsManifest": [
    {
      "file": "run0.xml",
      "run_id": "run0",
      "commit": "demo-commit-abc",
      "attempt": 0,
      "environment": {
        "platform": "linux",
        "runtime": "python3.12"
      }
    },
    {
      "file": "run1.xml",
      "run_id": "run1",
      "commit": "demo-commit-abc",
      "attempt": 0,
      "environment": {
        "platform": "linux",
        "runtime": "python3.12"
      }
    },
    {
      "file": "run2.xml",
      "run_id": "run2",
      "commit": "demo-commit-abc",
      "attempt": 0,
      "environment": {
        "platform": "linux",
        "runtime": "python3.12"
      }
    }
  ],
  "testIdentityRules": {
    "includeFile": true,
    "includeSuite": true
  },
  "minComparableRuns": 3,
  "environmentDimensions": [],
  "maxTestResults": 100000,
  "redactFailureMessages": true
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `csv` (type: `string`):

No description

## `summary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "junitFiles": [
        {
            "name": "run0.xml",
            "xml": "<testsuite name=\"demo\"><testcase classname=\"Demo\" name=\"stable-pass\" time=\"0.02\"></testcase><testcase classname=\"Demo\" name=\"stable-fail\" time=\"0.02\"><failure message=\"token=DEMO_SECRET\"/></testcase><testcase classname=\"Demo\" name=\"variable\" time=\"0.02\"></testcase><testcase classname=\"Demo\" name=\"skipped\" time=\"0.02\"><skipped/></testcase></testsuite>"
        },
        {
            "name": "run1.xml",
            "xml": "<testsuite name=\"demo\"><testcase classname=\"Demo\" name=\"stable-pass\" time=\"0.02\"></testcase><testcase classname=\"Demo\" name=\"stable-fail\" time=\"0.02\"><failure message=\"token=DEMO_SECRET\"/></testcase><testcase classname=\"Demo\" name=\"variable\" time=\"0.02\"><failure/></testcase><testcase classname=\"Demo\" name=\"skipped\" time=\"0.02\"><skipped/></testcase></testsuite>"
        },
        {
            "name": "run2.xml",
            "xml": "<testsuite name=\"demo\"><testcase classname=\"Demo\" name=\"stable-pass\" time=\"0.02\"></testcase><testcase classname=\"Demo\" name=\"stable-fail\" time=\"0.02\"><failure message=\"token=DEMO_SECRET\"/></testcase><testcase classname=\"Demo\" name=\"variable\" time=\"0.02\"></testcase><testcase classname=\"Demo\" name=\"skipped\" time=\"0.02\"><skipped/></testcase></testsuite>"
        }
    ],
    "runsManifest": [
        {
            "file": "run0.xml",
            "run_id": "run0",
            "commit": "demo-commit-abc",
            "attempt": 0,
            "environment": {
                "platform": "linux",
                "runtime": "python3.12"
            }
        },
        {
            "file": "run1.xml",
            "run_id": "run1",
            "commit": "demo-commit-abc",
            "attempt": 0,
            "environment": {
                "platform": "linux",
                "runtime": "python3.12"
            }
        },
        {
            "file": "run2.xml",
            "run_id": "run2",
            "commit": "demo-commit-abc",
            "attempt": 0,
            "environment": {
                "platform": "linux",
                "runtime": "python3.12"
            }
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("afkdigital/newapi94-ci-flaky-test-trend").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "junitFiles": [
        {
            "name": "run0.xml",
            "xml": "<testsuite name=\"demo\"><testcase classname=\"Demo\" name=\"stable-pass\" time=\"0.02\"></testcase><testcase classname=\"Demo\" name=\"stable-fail\" time=\"0.02\"><failure message=\"token=DEMO_SECRET\"/></testcase><testcase classname=\"Demo\" name=\"variable\" time=\"0.02\"></testcase><testcase classname=\"Demo\" name=\"skipped\" time=\"0.02\"><skipped/></testcase></testsuite>",
        },
        {
            "name": "run1.xml",
            "xml": "<testsuite name=\"demo\"><testcase classname=\"Demo\" name=\"stable-pass\" time=\"0.02\"></testcase><testcase classname=\"Demo\" name=\"stable-fail\" time=\"0.02\"><failure message=\"token=DEMO_SECRET\"/></testcase><testcase classname=\"Demo\" name=\"variable\" time=\"0.02\"><failure/></testcase><testcase classname=\"Demo\" name=\"skipped\" time=\"0.02\"><skipped/></testcase></testsuite>",
        },
        {
            "name": "run2.xml",
            "xml": "<testsuite name=\"demo\"><testcase classname=\"Demo\" name=\"stable-pass\" time=\"0.02\"></testcase><testcase classname=\"Demo\" name=\"stable-fail\" time=\"0.02\"><failure message=\"token=DEMO_SECRET\"/></testcase><testcase classname=\"Demo\" name=\"variable\" time=\"0.02\"></testcase><testcase classname=\"Demo\" name=\"skipped\" time=\"0.02\"><skipped/></testcase></testsuite>",
        },
    ],
    "runsManifest": [
        {
            "file": "run0.xml",
            "run_id": "run0",
            "commit": "demo-commit-abc",
            "attempt": 0,
            "environment": {
                "platform": "linux",
                "runtime": "python3.12",
            },
        },
        {
            "file": "run1.xml",
            "run_id": "run1",
            "commit": "demo-commit-abc",
            "attempt": 0,
            "environment": {
                "platform": "linux",
                "runtime": "python3.12",
            },
        },
        {
            "file": "run2.xml",
            "run_id": "run2",
            "commit": "demo-commit-abc",
            "attempt": 0,
            "environment": {
                "platform": "linux",
                "runtime": "python3.12",
            },
        },
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("afkdigital/newapi94-ci-flaky-test-trend").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "junitFiles": [
    {
      "name": "run0.xml",
      "xml": "<testsuite name=\\"demo\\"><testcase classname=\\"Demo\\" name=\\"stable-pass\\" time=\\"0.02\\"></testcase><testcase classname=\\"Demo\\" name=\\"stable-fail\\" time=\\"0.02\\"><failure message=\\"token=DEMO_SECRET\\"/></testcase><testcase classname=\\"Demo\\" name=\\"variable\\" time=\\"0.02\\"></testcase><testcase classname=\\"Demo\\" name=\\"skipped\\" time=\\"0.02\\"><skipped/></testcase></testsuite>"
    },
    {
      "name": "run1.xml",
      "xml": "<testsuite name=\\"demo\\"><testcase classname=\\"Demo\\" name=\\"stable-pass\\" time=\\"0.02\\"></testcase><testcase classname=\\"Demo\\" name=\\"stable-fail\\" time=\\"0.02\\"><failure message=\\"token=DEMO_SECRET\\"/></testcase><testcase classname=\\"Demo\\" name=\\"variable\\" time=\\"0.02\\"><failure/></testcase><testcase classname=\\"Demo\\" name=\\"skipped\\" time=\\"0.02\\"><skipped/></testcase></testsuite>"
    },
    {
      "name": "run2.xml",
      "xml": "<testsuite name=\\"demo\\"><testcase classname=\\"Demo\\" name=\\"stable-pass\\" time=\\"0.02\\"></testcase><testcase classname=\\"Demo\\" name=\\"stable-fail\\" time=\\"0.02\\"><failure message=\\"token=DEMO_SECRET\\"/></testcase><testcase classname=\\"Demo\\" name=\\"variable\\" time=\\"0.02\\"></testcase><testcase classname=\\"Demo\\" name=\\"skipped\\" time=\\"0.02\\"><skipped/></testcase></testsuite>"
    }
  ],
  "runsManifest": [
    {
      "file": "run0.xml",
      "run_id": "run0",
      "commit": "demo-commit-abc",
      "attempt": 0,
      "environment": {
        "platform": "linux",
        "runtime": "python3.12"
      }
    },
    {
      "file": "run1.xml",
      "run_id": "run1",
      "commit": "demo-commit-abc",
      "attempt": 0,
      "environment": {
        "platform": "linux",
        "runtime": "python3.12"
      }
    },
    {
      "file": "run2.xml",
      "run_id": "run2",
      "commit": "demo-commit-abc",
      "attempt": 0,
      "environment": {
        "platform": "linux",
        "runtime": "python3.12"
      }
    }
  ]
}' |
apify call afkdigital/newapi94-ci-flaky-test-trend --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,afkdigital/newapi94-ci-flaky-test-trend"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/442yaqiwfMazWxBcY/builds/Cbp0fQLM8Q5K3FswI/openapi.json
