Skip to content

Improve json formatting#1

Merged
sebastienros merged 3 commits into
UseSchemaGeneratorEverywherefrom
sebros/formatting
Dec 16, 2023
Merged

Improve json formatting#1
sebastienros merged 3 commits into
UseSchemaGeneratorEverywherefrom
sebros/formatting

Conversation

@sebastienros

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread src/Tools/ConfigurationSchemaGenerator/ConfigSchemaEmitter.cs Outdated
Comment thread src/Tools/ConfigurationSchemaGenerator/ConfigSchemaEmitter.cs Outdated

foreach (var match in Indentation().EnumerateMatches(value))
{
if (match.Index > index)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what case is match.Index <= index possible?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the first match is at the beginning of the line.

Comment thread Aspire.sln Outdated
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.MongoDB.Driver.Tests", "tests\Aspire.MongoDB.Driver.Tests\Aspire.MongoDB.Driver.Tests.csproj", "{E592E447-BA3C-44FA-86C1-EBEDC864A644}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.MongoDB.Driver.Tests", "tests\Aspire.MongoDB.Driver.Tests\Aspire.MongoDB.Driver.Tests.csproj", "{E592E447-BA3C-44FA-86C1-EBEDC864A644}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfigurationSchemaGenerator.Tests", "tests\ConfigurationSchemaGenerator.Tests\ConfigurationSchemaGenerator.Tests.csproj", "{00FEA181-84C9-42A7-AC81-29A9F176A1A0}"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 9A19103F right?

@sebastienros
sebastienros merged commit e67d071 into UseSchemaGeneratorEverywhere Dec 16, 2023
@sebastienros
sebastienros deleted the sebros/formatting branch December 16, 2023 00:52
eerhardt added a commit that referenced this pull request Jan 2, 2024
…icrosoft#1423)

* Update the rest of the components to use the ConfigSchemaGenerator.

Also fixing a couple bugs in the generator:

- Allow for just a LoggingCategories attribute
- Fix a bug in the exclusion paths, which needs the node to be hooked to the parent to get the full path
- Skip unsupported collections
- Add some more int types

* Improve json formatting (#1)

---------

Co-authored-by: Sébastien Ros <sebastienros@gmail.com>
eerhardt pushed a commit that referenced this pull request Feb 26, 2025
eerhardt pushed a commit that referenced this pull request Feb 26, 2025
eerhardt pushed a commit that referenced this pull request Feb 26, 2025
eerhardt added a commit that referenced this pull request Jul 15, 2025
There are expectations in other integrations that primitive environment variables are serialized to strings and not random objects like enums and bools.

Fix microsoft#10432

Related Work Items: #1
eerhardt pushed a commit that referenced this pull request Apr 27, 2026
…osoft#16446)

* feat(ci): add test failure retry patterns with config validation and pattern matching

Add eng/test-retry-patterns.json with initial transient failure patterns
(ECONNRESET, DNS failures, SSL errors, timeouts, Windows 0xC0000142).

Add pattern matching functions to auto-rerun-transient-ci-failures.js:
- loadRetryPatternsConfig: reads and validates JSON config
- validateRetryPatternsConfig: schema validation + regex compilation
- extractFailedTestsFromTrx: regex-based TRX XML parsing
- matchesRetryPattern: string/regex matching with case-insensitive support
- matchTestFailurePatterns: AND-within/OR-across rule matching
- matchJobLogPattern: job name + log text pattern matching

Add 30 tests in Infrastructure.Tests covering:
- Config JSON structure and schema validation (C#)
- Regex compilation validation via Node.js harness (V8 engine)
- Pattern matching: substring, regex, AND/OR logic, disabled rules
- TRX parsing: failed test extraction, output cap, XML entity decoding
- Validation edge cases: unknown props, wrong version, missing reason

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* feat(ci): add test failure retry support to auto-rerun workflow

Extend the auto-rerun-transient-ci-failures workflow to detect transient
test failures in addition to infrastructure failures. Two new matching
paths:

1. Job log pattern matching: analyzeFailedJobs now accepts an optional
   retryPatternsConfig and runs a 3rd classification pass using
   matchJobLogPattern for test-execution-failure jobs.

2. TRX-based pattern matching: After job classification, the YAML
   workflow downloads the All-TestResults artifact, extracts .trx files,
   and matches failed test output against testFailurePatterns from
   eng/test-retry-patterns.json. When matches are found, all skipped
   test-execution-failure jobs are promoted to retryable.

New exported JS functions:
- hasTestExecutionFailureStep: checks if a job has test execution steps
- analyzeTrxFiles: parses TRX contents, matches against patterns, dedupes
- promoteTestExecutionFailureJobs: pure function to move jobs to retryable
- selectTestResultsArtifact: picks newest non-expired artifact under cap

Safety rails:
- Existing maxRetryableJobs cap (default 5) applies to promoted jobs
- 3-attempt budget shared with infrastructure retries
- Artifact download failures are non-fatal
- 100MB artifact size cap, 200 TRX file limit, 50MB per-file limit

Updated summary and PR comment formatting to distinguish infrastructure
retries from test-pattern retries.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* docs(ci): rewrite auto-rerun CI docs with practical how-to guide

Restructure the documentation from a behavior contract into a
user-facing guide that explains:

- How the rerun system works at a glance (flow diagram)
- The four analysis passes and what each does
- When it triggers (automatic vs manual)
- How to add/modify test failure retry patterns in
  eng/test-retry-patterns.json with worked examples
- Rule field reference tables for both pattern types
- Matching semantics (AND/OR, substring vs regex, dedup)
- Tips for writing good patterns
- How to verify with dry run
- Safety rails summarized in a table
- Architecture and file layout
- How to run the tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* feat(ci): add MCR rate limiting patterns to test-retry-patterns.json

Add patterns to detect transient MCR (mcr.microsoft.com) rate limiting
failures that cause both test and infrastructure CI failures:

testFailurePatterns:
- MCR 403 Forbidden (regex scoped to mcr.microsoft.com)
- MCR 'The request is blocked' HTML response (regex scoped)
- CONTAINER1016 (.NET SDK container publish failure)
- 'pull access denied for mcr.microsoft.com' (Docker pull denial)

jobFailurePatterns:
- MCR 403 Forbidden (regex scoped to mcr.microsoft.com)
- MCR 'The request is blocked' HTML response (regex scoped)

Regex patterns use [\s\S]{0,500} to require mcr.microsoft.com within
500 chars of the error text, preventing false matches on non-MCR 403s.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: decodeXmlEntities double-decoding and sanitize markdown in PR comments

- Fix decodeXmlEntities replacement ordering: move &amp; decode to last
  position to prevent double-decoding of &amp;quot; and &amp;apos;
- Add sanitizeMarkdown helper to escape backticks/pipes in test names
  rendered in PR comment markdown (defense-in-depth)
- Add test covering double-encoded XML entity decoding

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Address PR review feedback

- Precompile regex patterns during config load instead of on every match;
  invalid patterns log warnings and disable the rule (comments #2-3)
- Add note to doc examples clarifying they are snippets, not standalone
  configs (comment #1)
- Dispose JsonDocument with 'using' in 3 test methods (comments #4-6)
- Guard artifact extraction against zip-slip and symlink attacks by
  skipping symlinks and verifying resolved paths stay within trxDir
  (comment #7)
- Cap test_pattern_matched_tests output to 50 entries and drop unused
  testProject field to avoid GH Actions size limits (comment #8)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants