Skip to content

Commit 7c58203

Browse files
committed
add new draft and extension to find unlisted pages
1 parent bfa7341 commit 7c58203

File tree

3 files changed

+174
-1
lines changed

3 files changed

+174
-1
lines changed

antora-playbook.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,7 @@ asciidoc:
6464
urls:
6565
latest_version_segment: latest
6666
latest_version_segment_strategy: redirect:to
67-
html_extension_style: indexify
67+
html_extension_style: indexify
68+
antora:
69+
extensions:
70+
- ./extensions/unlisted-pages-extension.js
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
= Agentic flaky test resolution
2+
:page-platform: Cloud
3+
:page-description: Learn about CircleCI agents and how they can automatically identify and fix flaky tests in your CI/CD pipelines.
4+
:experimental:
5+
6+
CircleCI agents provide automated capabilities to identify and resolve common issues in your CI/CD pipelines. Agents can automatically detect flaky tests and generate fixes to help you ship code with confidence by reducing time spent debugging intermittent failures.
7+
8+
== Introduction
9+
10+
Flaky tests are one of the most frustrating challenges in continuous integration. These tests pass and fail inconsistently, creating uncertainty about code quality and slowing down development workflows. CircleCI agents address this problem by using artificial intelligence to analyze test patterns, identify root causes of flakiness, and propose validated solutions.
11+
12+
The agent integrates seamlessly with your existing CircleCI workflows and GitHub repositories. When configured, it runs automatically on a schedule you define, continuously monitoring your test suite for signs of flakiness. When issues are detected, the agent generates potential fixes, validates them through multiple test runs, and creates pull requests with recommended changes.
13+
14+
This automation helps development teams focus on building features rather than debugging test infrastructure, improving both productivity and confidence in your deployment pipeline.
15+
16+
== Quickstart
17+
18+
To get started with CircleCI agents for flaky test fixes, you need to complete several setup steps:
19+
20+
. Obtain an API key from either Anthropic or OpenAI for the agent to process and generate fixes.
21+
. Ensure your CircleCI jobs store test results using the `store_test_results` step.
22+
. Navigate to the CircleCI web app and access your organization settings.
23+
. Install the CircleCI GitHub App in your GitHub organization.
24+
. Configure the agent with your preferred settings for run frequency and fix parameters.
25+
26+
For a detailed walkthrough of each step, refer to the xref:guides:agents:setup-flaky-test-agent.adoc[Setting up CircleCI agents for flaky tests] guide.
27+
28+
== How CircleCI agents work
29+
30+
CircleCI agents operate through an automated analysis and remediation process that runs independently of your regular CI/CD workflows.
31+
32+
=== Test analysis and detection
33+
34+
The agent continuously monitors test results stored in CircleCI to identify patterns of flakiness. It analyzes historical test data to distinguish between genuine failures caused by code issues and intermittent failures that indicate flaky behavior. Tests are flagged as flaky when they show inconsistent pass/fail patterns across multiple runs with the same code.
35+
36+
The detection process considers factors such as failure frequency, timing patterns, and error message consistency. This helps the agent focus on tests that genuinely exhibit flaky behavior rather than tests that fail consistently due to code problems.
37+
38+
=== Solution generation
39+
40+
When a flaky test is identified, the agent generates potential solutions based on common flaky test patterns and best practices. The agent can create multiple solution approaches for each test, allowing it to try different fixes if the first attempt does not resolve the issue.
41+
42+
Solutions may include adding explicit waits, improving element selectors, handling race conditions, or stabilizing test data setup. The agent tailors its recommendations to the specific failure patterns observed in your test.
43+
44+
=== Validation process
45+
46+
Before proposing any changes, the agent validates potential solutions through multiple test runs in an isolated environment. This validation process ensures that proposed fixes actually resolve the flakiness without breaking existing functionality.
47+
48+
The agent runs the modified test multiple times to confirm consistent passing behavior. Only solutions that demonstrate reliable improvement are included in pull requests. If validation fails or the agent lacks confidence in a solution, no pull request is created, but analysis logs remain available for review.
49+
50+
=== Pull request creation
51+
52+
When the agent successfully validates a solution, it automatically creates a pull request in your GitHub repository. Each pull request includes detailed information about the changes made and the reasoning behind them.
53+
54+
Pull requests contain code diffs showing exactly what changes the agent recommends, along with logs that explain the agent's analysis and decision-making process. This transparency allows your team to understand and review the proposed fixes before merging.
55+
56+
== Using tables
57+
58+
The following table shows the configuration options available when setting up a CircleCI agent:
59+
60+
.Agent configuration options
61+
[cols="1,2,1"]
62+
|===
63+
|Setting |Description |Default
64+
65+
|Run frequency
66+
|How often the agent analyzes and fixes flaky tests
67+
|Weekly
68+
69+
|Maximum tests to fix per run
70+
|Limits the number of tests the agent will attempt to fix in a single execution
71+
|5
72+
73+
|Number of solutions to try per test
74+
|How many different fix approaches the agent will generate for each flaky test
75+
|3
76+
77+
|Number of validation runs per test
78+
|How many times the agent runs a test to validate that a fix works consistently
79+
|10
80+
81+
|Maximum concurrent open PRs
82+
|Limits the number of pull requests the agent can have open at one time
83+
|5
84+
|===
85+
86+
== Limitations
87+
88+
CircleCI agents have several current limitations that users should be aware of:
89+
90+
**Configuration editing**: You cannot directly edit setup scripts or post-run commands once an agent task is created. To modify these settings, you must delete the existing agent task and create a new one.
91+
92+
**OpenAI logs**: Agent logs are not currently available when using OpenAI as your model provider. This feature is available only when using Anthropic.
93+
94+
**Platform support**: The agent currently runs only in Linux Machine VM environments with basic software installed by default.
95+
96+
== Troubleshooting
97+
98+
=== Unable to run verification tests
99+
100+
If the agent cannot run verification tests, this typically indicates missing dependencies or environment configuration issues. The agent runs in a Linux Machine VM and may need additional software to execute your tests properly.
101+
102+
Check the agent task logs in the CircleCI web app by expanding all log sections and searching for "attempt" to see what the agent tried to do. Use the setup script feature during agent configuration to install required dependencies or environment requirements.
103+
104+
Consider adding a markdown file to your repository with instructions for running tests locally. The agent will automatically detect and use this information to better understand your test environment.
105+
106+
=== Agent execution errors
107+
108+
When the agent encounters execution errors, review the logs to understand what went wrong. Common issues include missing API keys, insufficient permissions, or problems accessing your repository.
109+
110+
Verify that your API key is valid and has the necessary permissions for your chosen model provider. Ensure that the CircleCI GitHub App has been installed with appropriate access to your organization and repositories.
111+
112+
== Frequently asked questions
113+
114+
=== Does CircleCI use my data to train AI models?
115+
116+
No, CircleCI does not store your source code or use it for training purposes. The agent processes your code temporarily to generate fixes but does not retain or share this information with model providers for training.
117+
118+
=== How long are agent logs stored?
119+
120+
Agent logs are stored in CircleCI and remain available for review through the web app. The specific retention period for these logs follows CircleCI's standard data retention policies.
121+
122+
=== What if my OpenAI organization cannot be verified?
123+
124+
If you cannot get your OpenAI organization verified, consider using Anthropic as your model provider instead. Alternatively, contact OpenAI support for assistance with the verification process, or reach out to CircleCI support for alternative options.
125+
126+
== Next steps
127+
128+
* xref:guides:agents:setup-flaky-test-agent.adoc[Set up CircleCI agents for flaky tests]
129+
* xref:guides:testing:collect-test-data.adoc[Learn about collecting test data]
130+
* xref:guides:insights:test-insights.adoc[Understanding test insights and flaky test detection]
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
module.exports.register = function ({ config }) {
2+
const { addToNavigation, unlistedPagesHeading = 'Unlisted Pages' } = config
3+
const logger = this.getLogger('unlisted-pages-extension')
4+
this
5+
.on('navigationBuilt', ({ contentCatalog }) => {
6+
contentCatalog.getComponents().forEach(({ versions }) => {
7+
versions.forEach(({ name: component, version, navigation: nav, url: defaultUrl }) => {
8+
const navEntriesByUrl = getNavEntriesByUrl(nav)
9+
const unlistedPages = contentCatalog
10+
.findBy({ component, version, family: 'page' })
11+
.filter((page) => page.out)
12+
.reduce((collector, page) => {
13+
if ((page.pub.url in navEntriesByUrl) || page.pub.url === defaultUrl) return collector
14+
logger.warn({ file: page.src, source: page.src.origin }, 'detected unlisted page')
15+
return collector.concat(page)
16+
}, [])
17+
if (unlistedPages.length && addToNavigation) {
18+
nav.push({
19+
content: unlistedPagesHeading,
20+
items: unlistedPages.map((page) => {
21+
const title = 'navtitle' in page.asciidoc
22+
? page.asciidoc.navtitle
23+
: (page.src.module === 'ROOT' ? '' : page.src.module + ':') + page.src.relative
24+
return { content: title, url: page.pub.url, urlType: 'internal' }
25+
}),
26+
root: true,
27+
})
28+
}
29+
})
30+
})
31+
})
32+
}
33+
34+
function getNavEntriesByUrl (items = [], accum = {}) {
35+
items.forEach((item) => {
36+
if (item.urlType === 'internal') accum[item.url.split('#')[0]] = item
37+
getNavEntriesByUrl(item.items, accum)
38+
})
39+
return accum
40+
}

0 commit comments

Comments
 (0)