| title | Pull Request Validation Workflow | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| description | GitHub Actions workflow for comprehensive pull request validation, testing, and quality assurance | ||||||||||||||||
| author | Edge AI Team | ||||||||||||||||
| ms.date | 2025-06-06 | ||||||||||||||||
| ms.topic | concept | ||||||||||||||||
| estimated_reading_time | 7 | ||||||||||||||||
| keywords |
|
The Pull Request Validation workflow is a comprehensive CI/CD pipeline that runs on pull requests to ensure code quality, validate infrastructure changes, and verify readiness for merging to the main branch. It intelligently detects changed files to run the appropriate validation steps, focusing computational resources on relevant components.
- Intelligent detection of changed files to determine necessary validation steps
- Static code analysis with individual lint jobs across multiple languages and file formats
- Strict documentation standards validation for Terraform and Bicep configurations
- Terraform validation including init, validate, plan, and test operations
- Azure IoT Operations component version checking
- Resource provider script testing for PowerShell and bash
- Matrix-based testing for efficient validation of multiple components
- Dependency scanning for security vulnerabilities
When triggered automatically by pull requests, this workflow doesn't require inputs. When manually triggered using workflow_dispatch, it accepts:
| Input | Description | Required | Default |
|---|---|---|---|
includeAllTerraformFolders |
Include all folders in the matrix check instead of only changed ones | No | false |
This workflow doesn't produce any direct output variables, but it generates the following:
- GitHub annotations for issues found during validation
- Pull request comments with linting and validation results
- Comprehensive test results for infrastructure code
The workflow is automatically triggered on pull requests targeting the main branch and doesn't need manual invocation.
The workflow can also be triggered manually from the GitHub Actions tab:
- Navigate to the "Actions" tab in the repository
- Select the "PR Validation" workflow
- Click "Run workflow"
- Configure the optional inputs:
- Select whether to include all terraform folders in validation (not just changed ones)
- Click "Run workflow"
The workflow consists of multiple jobs that run in a specific sequence:
- Dependency Scan: Analyzes project dependencies for security issues
- Lint Jobs: Performs comprehensive linting and static analysis
- Terraform Documentation Check: Validates Terraform documentation consistency with strict validation
- Bicep Documentation Check: Validates Bicep documentation consistency with strict validation
- AIO Version Check: Verifies Azure IoT Operations component versions
- Matrix Changes Detection: Determines which folders have changes to optimize testing
- PowerShell Provider Tests: Tests resource provider scripts when relevant
- Terraform Variable Compliance: Ensures consistent Terraform variable definitions
- Terraform Module Tests: Runs tests for changed Terraform modules
- Checks out the repository code
- Performs dependency review for security vulnerabilities
- Reports findings as GitHub annotations
Runs dedicated lint jobs for shell scripts, YAML, Python, PowerShell, Bicep, Terraform, documentation, and code quality analysis with PR comment reporting for linting results.
Calls the reusable docs-check-terraform.yml workflow with:
break_build: true- Documentation issues will fail the workflowterraformDocsVersion: 'v0.19.0'- Specifies the version of terraform-docs to use
Calls the reusable docs-check-bicep.yml workflow with:
break_build: true- Documentation issues will fail the workflow
Calls the reusable aio-version-checker.yml workflow with:
iac-type: all- Checks versions in all IaC types (Terraform and Bicep)break-build: false- Version warnings won't fail the build
Calls the reusable matrix-folder-check.yml workflow to:
- Detect which specific folders have changes in the pull request
- Create a matrix of changed folders for subsequent test steps
- Output boolean flags indicating changes in specific areas
- Optionally include all folders when manually triggered with that option
Calls the reusable resource-provider-pwsh-tests.yml workflow when relevant changes are detected:
- Only runs if PowerShell resource provider scripts were changed
- Tests Azure resource provider registration scripts
Calls the reusable variable-compliance-terraform.yml workflow to:
- Ensure consistent Terraform variable definitions across modules
- Report any inconsistencies as warnings
Uses the cluster-test-terraform.yml workflow with a matrix strategy to:
- Run tests for each changed Terraform module individually
- Use a specific Terraform version (1.9.8)
- Test without actually applying the changes
-
Lint Job Failures:
- Solution: Review the lint job logs in PR comments or workflow artifacts and fix identified issues
-
Documentation Validation Issues:
- Solution: Use the documentation generation scripts (
update-all-terraform-docs.shorupdate-all-bicep-docs.sh) to regenerate documentation, then commit changes
- Solution: Use the documentation generation scripts (
-
Matrix Changes Detection Issues:
- Solution: If tests aren't running for your changes, check the
matrix-changesjob output to ensure changes were properly detected
- Solution: If tests aren't running for your changes, check the
-
Terraform Variable Compliance Failures:
- Solution: Use the
tf-vars-compliance-check.pyscript to identify and fix variable inconsistencies
- Solution: Use the
To enhance this workflow:
-
To add additional validation steps:
- Add new jobs after existing checks
- Use the
needsparameter to ensure proper sequencing
-
To modify detection thresholds:
- Edit the
matrix-folder-check.ymlworkflow to adjust change detection logic
- Edit the
- main.yml: Main branch CI/CD workflow that runs after PRs are merged
- docs-check-terraform.yml: Terraform documentation validation
- docs-check-bicep.yml: Bicep documentation validation
- matrix-folder-check.yml: Changes detection workflow
- variable-compliance-terraform.yml: Terraform variable compliance check
- cluster-test-terraform.yml: Terraform module testing workflow
This workflow requires these permissions to function correctly:
contents: write: Required for checking out code and potentially making annotationspull-requests: write: Required for commenting on pull requestsstatuses: write: Required for setting PR status checks
The workflow uses secrets inheritance (secrets: inherit) to pass repository secrets to called workflows.
🤖 Crafted with precision by ✨Copilot following brilliant human instruction, then carefully refined by our team of discerning human reviewers.