Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 25, 2025

This documentation provides a comprehensive overview of how samples are validated in the Azure SDK for Go CI pipelines, addressing the question about sample validation processes.

Sample Validation Overview

The Azure SDK for Go employs a multi-layered validation approach for samples through its CI pipeline system:

Pipeline Architecture

  • Main Pipeline: Defined in /eng/pipelines/pullrequest.yml extending archetype-sdk-client.yml
  • Build Stage: Tests across multiple Go versions (1.18, 1.22, 1.23) and platforms (Linux, Windows)
  • Analyze Stage: Comprehensive static analysis and validation

Sample Validation Methods

1. Code Execution Validation

Examples are written as Go test files (example*_test.go) with functions prefixed Example. The CI pipeline:

  • Executes go test via eng/scripts/run_tests.ps1eng/scripts/test.ps1
  • Runs all examples to ensure they compile and execute without errors
  • Generates coverage reports using gocov tools

2. Sample Metadata Validation

  • Uses eng/common/scripts/Test-SampleMetadata.ps1
  • Validates frontmatter in markdown files containing samples
  • Checks product slugs against Microsoft's official taxonomy
  • Called from eng/common/pipelines/templates/steps/verify-samples.yml

3. Static Analysis and Quality Checks

The analyze stage performs comprehensive validation:

  • golangci-lint: Code quality and style validation
  • go mod tidy: Dependency management verification
  • Format checking: Go code formatting standards
  • Copyright header validation: License compliance
  • Documentation validation: Ensures doc.go files exist
  • Link verification: Validates URLs in documentation

4. Package and API Validation

  • Changelog validation: Ensures proper change documentation
  • API review integration: Checks API review approval status
  • Package naming compliance: Validates against Azure SDK standards

Testing Infrastructure

  • Test Proxy: Uses Azure SDK Test Proxy for HTTP recording/playback
  • Environment Configuration: Supports .env files and environment variables
  • Multi-platform Testing: Validates across different operating systems
  • Coverage Reporting: Generates detailed test coverage metrics

Example Standards

Sample code must follow specific patterns:

  • Go example function naming convention (func Example...())
  • Proper error handling with user-customizable TODO comments
  • Environment variable usage for configuration
  • Graceful handling of missing configuration
  • Appropriate // Output: comments for Go's testing framework

This validation system ensures samples are not only syntactically correct but also executable, well-documented, and compliant with Azure SDK standards.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI changed the title [WIP] How are samples validated in CI pipelines? Document sample validation process in Azure SDK for Go CI pipelines Aug 25, 2025
@Copilot Copilot AI requested a review from deyaaeldeen August 25, 2025 22:12
Copilot finished work on behalf of deyaaeldeen August 25, 2025 22:12
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