Add PR validation for staging Pulumi component references#9
Conversation
Co-authored-by: sekka1 <575972+sekka1@users.noreply.github.com>
Co-authored-by: sekka1 <575972+sekka1@users.noreply.github.com>
|
@copilot the github actions file looks good. Lets put a new line in the pulumi vpc instantiation file to test this out. |
Co-authored-by: sekka1 <575972+sekka1@users.noreply.github.com>
Added a test comment line to the VPC Pulumi.yaml file in commit 65f8de4. This change will trigger the workflow validation, which should detect and fail on:
The workflow will demonstrate all three validation checks working correctly. |
🍹
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a GitHub Actions workflow to enforce component versioning standards in staging Pulumi environments. The workflow prevents merging PRs that contain development-only references (local paths and 0.0.0 versions), ensuring staging uses production-ready versioned components from git URLs.
Key Changes:
- Created automated PR validation workflow with three checks: local path detection, SDK filename version validation, and SDK content version validation
- Added test comment to VPC Pulumi.yaml to demonstrate workflow triggering
- Implemented GitHub Actions security best practices with pinned action SHAs and minimal permissions
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
.github/workflows/check-staging-pulumi-references.yaml |
New workflow that validates Pulumi component references on PRs, checking for local paths and 0.0.0 versions in staging |
pulumi/environments/aws/staging/40-vpc/Pulumi.yaml |
Added comment line to trigger workflow for testing purposes |
Critical Issue Identified: The staging VPC Pulumi.yaml file currently contains a local path reference with version 0.0.0 (line 6), which is exactly what the new workflow is designed to prevent. This must be updated to a git URL reference with a proper semantic version before merging, otherwise the workflow will fail on all future PRs touching this file.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| runtime: yaml | ||
| # Testing PR validation workflow for local path references | ||
| packages: | ||
| vpc: ../../../../components/aws/vpc@0.0.0 |
There was a problem hiding this comment.
This staging Pulumi.yaml file contains a local path reference with version 0.0.0, which is exactly what the new workflow is designed to prevent. If this PR is merged with this local reference, the new workflow will fail on all future PRs that touch this file. This should be changed to use a git URL reference with a proper semantic version (e.g., "https://github.com/ManagedKube/devops-with-ai.git/pulumi/components/aws/vpc@0.0.1") before merging, as shown in the github-oidc example.
| vpc: ../../../../components/aws/vpc@0.0.0 | |
| vpc: https://github.com/ManagedKube/devops-with-ai.git/pulumi/components/aws/vpc@0.0.1 |
| check-references: | ||
| name: Validate Pulumi Component References | ||
| runs-on: ubuntu-latest |
There was a problem hiding this comment.
The job is missing a timeout-minutes configuration. According to GitHub Actions best practices, adding a timeout prevents hung workflows from consuming resources indefinitely. Consider adding "timeout-minutes: 10" to the job definition, similar to the test-sg-component workflow.
| echo "" | ||
| EXIT_CODE=1 | ||
| fi | ||
| done < <(find pulumi/environments/aws -type f -name "Pulumi.yaml") |
There was a problem hiding this comment.
The find command searches all Pulumi.yaml files under "pulumi/environments/aws/" but the workflow is specifically for staging validation. If other environments (like dev or prod) are added in the future, this check will incorrectly validate them too. Consider restricting the search to staging only by changing the path to "pulumi/environments/aws/staging".
| done < <(find pulumi/environments/aws -type f -name "Pulumi.yaml") | |
| done < <(find pulumi/environments/aws/staging -type f -name "Pulumi.yaml") |
| # Check if the file contains packages with relative paths (starting with ../ or ./) | ||
| if grep -E '^\s+\w+:\s+\.\.' "$file"; then | ||
| echo "❌ ERROR: Found local path reference in $file" | ||
| echo "Local path references (e.g., ../../../../components/aws/vpc@0.0.0) are not allowed in staging." |
There was a problem hiding this comment.
The error message states "are not allowed in staging" but the check on line 41 scans all files under "pulumi/environments/aws/", not just staging. This creates a mismatch between what the message says and what is actually checked. The message should either be updated to match the broader scope, or the search path should be restricted to staging only.
| if grep -E '^\s+\w+:\s+\.\.' "$file"; then | ||
| echo "❌ ERROR: Found local path reference in $file" | ||
| echo "Local path references (e.g., ../../../../components/aws/vpc@0.0.0) are not allowed in staging." |
There was a problem hiding this comment.
The comment mentions checking for both "../" and "./" but the regex pattern on line 34 only checks for ".." (parent directory references). If the intention is to also block same-directory references starting with "./", the regex pattern should be updated to match both patterns.
| if grep -E '^\s+\w+:\s+\.\.' "$file"; then | |
| echo "❌ ERROR: Found local path reference in $file" | |
| echo "Local path references (e.g., ../../../../components/aws/vpc@0.0.0) are not allowed in staging." | |
| if grep -E '^\s+\w+:\s+\.(\.|/)+' "$file"; then | |
| echo "❌ ERROR: Found local path reference in $file" | |
| echo "Local path references (e.g., ../../../../components/aws/vpc@0.0.0 or ./components/aws/vpc@0.0.0) are not allowed in staging." |
Implementation Complete ✅
pulumi/environments/aws/**-0.0.0.yamlinpulumi/environments/aws/staging/**/sdks/**/*Summary
Created
.github/workflows/check-staging-pulumi-references.yamlthat validates Pulumi component references in staging environments on every PR.Three Validation Checks:
vpc: ../../../../components/aws/vpc@0.0.0*-0.0.0.yamlversion: 0.0.0Security & Quality:
Testing:
vpc: ../../../../components/aws/vpc@0.0.0vpc-0.0.0.yamlversion: 0.0.0This workflow prevents merging PRs with development-only references (local paths and 0.0.0 versions) in staging, ensuring production-ready versioned components are used.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.