Skip to content

Commit a3a728a

Browse files
ryan-williamsclaude
andcommitted
Add test stack and workflow for exercising pulumi.yml
Lightweight AWS resources (EC2 key pair, IAM role, CW log group) to test `--patch` diff output, job summaries, and PR comments. Caller workflow dispatches against the reusable workflow with `uses: ./.github/...`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 568b0bc commit a3a728a

File tree

5 files changed

+82
-0
lines changed

5 files changed

+82
-0
lines changed

.github/workflows/test.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Test
2+
run-name: 'test: pulumi ${{ inputs.cmd }}'
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
cmd:
8+
description: 'Pulumi command'
9+
required: true
10+
default: 'preview'
11+
type: choice
12+
options:
13+
- preview
14+
- up
15+
- refresh
16+
17+
permissions:
18+
id-token: write
19+
contents: read
20+
pull-requests: write
21+
actions: read
22+
23+
jobs:
24+
pulumi:
25+
uses: ./.github/workflows/pulumi.yml
26+
with:
27+
cmd: ${{ inputs.cmd }}
28+
stack: test
29+
project: pulumi-v1-test
30+
working-directory: test
31+
secrets: inherit

test/Pulumi.test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
config:
2+
aws:region: us-east-1

test/Pulumi.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: pulumi-v1-test
2+
description: Test stack for the pulumi-v1 reusable workflow
3+
runtime: python
4+
backend:
5+
url: gs://oa-pulumi

test/__main__.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""Test stack for the pulumi-v1 reusable workflow.
2+
3+
Creates lightweight, free AWS resources to exercise `pulumi preview --patch`
4+
diff output, job summaries, and PR comments.
5+
"""
6+
import pulumi
7+
import pulumi_aws as aws
8+
import pulumi_tls as tls
9+
10+
config = pulumi.Config()
11+
env = pulumi.get_stack()
12+
13+
# EC2 Key Pair (via TLS-generated key)
14+
key = tls.PrivateKey("test-key", algorithm="ED25519")
15+
key_pair = aws.ec2.KeyPair("test-key-pair",
16+
key_name=f"pulumi-v1-test-{env}",
17+
public_key=key.public_key_openssh,
18+
)
19+
20+
# IAM Role (no trust policy; just exists for diff testing)
21+
role = aws.iam.Role("test-role",
22+
name=f"pulumi-v1-test-{env}",
23+
assume_role_policy="""{
24+
"Version": "2012-10-17",
25+
"Statement": [{
26+
"Effect": "Deny",
27+
"Principal": {"Service": "none.amazonaws.com"},
28+
"Action": "sts:AssumeRole"
29+
}]
30+
}""",
31+
)
32+
33+
# CloudWatch Log Group
34+
log_group = aws.cloudwatch.LogGroup("test-log-group",
35+
name=f"/pulumi-v1/test/{env}",
36+
retention_in_days=1,
37+
)
38+
39+
pulumi.export("key_pair_name", key_pair.key_name)
40+
pulumi.export("role_arn", role.arn)
41+
pulumi.export("log_group_name", log_group.name)

test/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pulumi>=3.0.0
2+
pulumi-aws>=6.0.0
3+
pulumi-tls>=5.0.0

0 commit comments

Comments
 (0)