Skip to content

chore: test pr linter#16

Open
pahud wants to merge 17 commits intomainfrom
test-pr-linter
Open

chore: test pr linter#16
pahud wants to merge 17 commits intomainfrom
test-pr-linter

Conversation

@pahud
Copy link
Owner

@pahud pahud commented Nov 14, 2025

Issue # (if applicable)

Closes #.

Reason for this change

Description of changes

Describe any new or updated permissions being added

Description of how you validated changes

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@amazon-q-developer
Copy link

Code review in progress. Analyzing for code quality issues and best practices. You can monitor the review status in the checks section at the bottom of this pull request. Detailed findings will be posted upon completion.

Using Amazon Q Developer for GitHub

Amazon Q Developer1 is an AI-powered assistant that integrates directly into your GitHub workflow, enhancing your development process with intelligent features for code development, review, and transformation.

Slash Commands

Command Description
/q <message> Chat with the agent to ask questions or request revisions
/q review Requests an Amazon Q powered code review
/q help Displays usage information

Features

Agentic Chat
Enables interactive conversation with Amazon Q to ask questions about the pull request or request specific revisions. Use /q <message> in comment threads or the review body to engage with the agent directly.

Code Review
Analyzes pull requests for code quality, potential issues, and security concerns. Provides feedback and suggested fixes. Automatically triggered on new or reopened PRs (can be disabled for AWS registered installations), or manually with /q review slash command in a comment.

Customization

You can create project-specific rules for Amazon Q Developer to follow:

  1. Create a .amazonq/rules folder in your project root.
  2. Add Markdown files in this folder to define rules (e.g., cdk-rules.md).
  3. Write detailed prompts in these files, such as coding standards or best practices.
  4. Amazon Q Developer will automatically use these rules when generating code or providing assistance.

Example rule:

All Amazon S3 buckets must have encryption enabled, enforce SSL, and block public access.
All Amazon DynamoDB Streams tables must have encryption enabled.
All Amazon SNS topics must have encryption enabled and enforce SSL.
All Amazon SNS queues must enforce SSL.

Feedback

To provide feedback on Amazon Q Developer, create an issue in the Amazon Q Developer public repository.

For more detailed information, visit the Amazon Q for GitHub documentation.

Footnotes

  1. Amazon Q Developer uses generative AI. You may need to verify generated code before using it in your environment. See the AWS Responsible AI Policy.

@github-actions github-actions bot added the p2 label Nov 14, 2025
Copy link

@amazon-q-developer amazon-q-developer bot left a comment

Choose a reason for hiding this comment

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

Review Summary

This pull request titled "Test pr linter" appears to contain no code changes (0 additions, 0 deletions, 0 changed files). The PR description template has not been filled out with specific details about:

  • The issue being addressed
  • Reason for the change
  • Description of changes
  • Validation approach

Recommendation: This PR cannot be merged in its current state as it contains no functional changes. If this is intended as a test PR for linter functionality, please add the actual code changes that need to be tested, or close this PR if it's no longer needed.

Next Steps:

  1. Add the intended code changes to the PR
  2. Fill out the PR description with relevant details
  3. Ensure all checklist items are completed before requesting review

You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

The pull request linter fails with the following errors:

❌ The title prefix of this pull request must be one of "feat|fix|build|chore|ci|docs|style|refactor|perf|test|revert"

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

The pull request linter fails with the following errors:

❌ The title prefix of this pull request must be one of "feat|fix|build|chore|ci|docs|style|refactor|perf|test|revert"

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

The pull request linter fails with the following errors:

❌ The title prefix of this pull request must be one of "feat|fix|build|chore|ci|docs|style|refactor|perf|test|revert"

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

The pull request linter fails with the following errors:

❌ The title prefix of this pull request must be one of "feat|fix|build|chore|ci|docs|style|refactor|perf|test|revert"

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

The pull request linter fails with the following errors:

❌ The title prefix of this pull request must be one of "feat|fix|build|chore|ci|docs|style|refactor|perf|test|revert"

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

@pahud pahud changed the title Test pr linter chore: test pr linter Nov 15, 2025
pahud and others added 17 commits November 17, 2025 11:13
- Extract pull request number and SHA into environment variables
- Use env variables instead of inline GitHub context expressions
- Improves workflow readability and maintainability
- Reduces duplication of GitHub context references in run script
Added a test comment to the EKS Add-On interface documentation.
Co-authored-by: amazon-q-developer[bot] <208079219+amazon-q-developer[bot]@users.noreply.github.com>
minor formatting improvement
Comment out Docker setup and caching steps in workflow.
mergify bot pushed a commit to aws/aws-cdk that referenced this pull request Nov 17, 2025
…6057)

Added steps to save and upload pull request information.

### Issue # (if applicable)

Closes #36055

### Reason for this change

THE PROBLEM:
------------
PR Linter can't determine which PR to validate because:
  1. No pr_info artifact exists
  2. pull_requests array is empty (GitHub limitation)


THE SOLUTION:
-------------
Add these steps to codebuild-pr-build.yml:

```yaml
  - name: Save PR info for PR Linter
    if: github.event_name == 'pull_request'
    run: |
      mkdir -p ./pr
      echo "${{ github.event.pull_request.number }}" > ./pr/pr_number
      echo "${{ github.event.pull_request.head.sha }}" > ./pr/pr_sha

  - name: Upload PR info artifact
    if: github.event_name == 'pull_request'
    uses: actions/upload-artifact@v5
    with:
      name: pr_info
      path: pr/
```

WHY IT WORKS:
-------------

```
BEFORE (BROKEN):
┌─────────────────────────────────────────────────────────┐
│ Codebuild PR Build                                      │
│   Context: github.event.pull_request.number = 36049 ✓   │
│   Context: github.event.pull_request.head.sha = fc4... ✓│
│                                                          │
│   ✗ Does NOT save this info                             │
│   ✗ Does NOT upload artifact                            │
└─────────────────────────────────────────────────────────┘
                    │
                    │ workflow_run event
                    ▼
┌─────────────────────────────────────────────────────────┐
│ PR Linter (workflow_run context)                        │
│   Context: github.event.workflow_run.pull_requests = [] │
│   Context: No PR info available ✗                       │
│                                                          │
│   Tries to download pr_info artifact ──► ✗ Not found   │
│   Tries pull_requests[0].number ──────► ✗ Empty array  │
│                                                          │
│   Result: ✗ CANNOT DETERMINE PR NUMBER                  │
└─────────────────────────────────────────────────────────┘


AFTER (FIXED):
┌─────────────────────────────────────────────────────────┐
│ Codebuild PR Build                                      │
│   Context: github.event.pull_request.number = 36049 ✓   │
│   Context: github.event.pull_request.head.sha = fc4... ✓│
│                                                          │
│   ✓ Saves PR number to file: pr/pr_number               │
│   ✓ Saves PR SHA to file: pr/pr_sha                     │
│   ✓ Uploads pr_info artifact                            │
│      └─ Contains: pr_number=36049, pr_sha=fc4...        │
└─────────────────────────────────────────────────────────┘
                    │
                    │ workflow_run event
                    │ (artifact travels with event)
                    ▼
┌─────────────────────────────────────────────────────────┐
│ PR Linter (workflow_run context)                        │
│   Context: github.event.workflow_run.pull_requests = [] │
│                                                          │
│   Downloads pr_info artifact ─────────► ✓ Found!       │
│     └─ Extracts pr/pr_number ────────► ✓ 36049         │
│     └─ Extracts pr/pr_sha ───────────► ✓ fc4...        │
│                                                          │
│   Result: ✓ PR NUMBER DETERMINED = 36049                │
│           ✓ Can now validate the correct PR             │
└─────────────────────────────────────────────────────────┘
```

KEY INSIGHT:
------------

```
┌──────────────────────────────────────────────────────────┐
│  The PR context EXISTS in Codebuild PR Build             │
│  (triggered by pull_request event)                       │
│                                                           │
│  But it DISAPPEARS in PR Linter                          │
│  (triggered by workflow_run event)                       │
│                                                           │
│  Solution: PERSIST the context via artifact              │
│            (artifacts survive the context switch)        │
└──────────────────────────────────────────────────────────┘
```

CONTEXT AVAILABILITY:
---------------------

Codebuild PR Build (pull_request trigger):
  ✓ github.event.pull_request.number
  ✓ github.event.pull_request.head.sha
  ✓ github.event.pull_request.* (all PR data)

PR Linter (workflow_run trigger):
  ✗ github.event.pull_request (doesn't exist)
  ✗ github.event.workflow_run.pull_requests (empty array)
  ✓ github.event.workflow_run.id (can download artifacts)


ARTIFACT AS BRIDGE:
-------------------

```
  Codebuild Context          Artifact           PR Linter Context
  ─────────────────          ────────           ─────────────────

  PR #36049                                     workflow_run event
  pull_request event                            (no PR context)
       │                                              │
       │ Has PR data                                  │ No PR data
       │                                              │
       ▼                                              ▼
  Save to files          ──────────►            Download files
  - pr_number: 36049        Upload               - pr_number: 36049
  - pr_sha: fc4...          artifact             - pr_sha: fc4...
                            pr_info
                                                 ✓ PR context restored!
```

EXECUTION FLOW WITH FIX:
-------------------------

```
1. PR opened ──► Codebuild PR Build starts
                 │
                 ├─ github.event.pull_request.number = 36049 ✓
                 ├─ github.event.pull_request.head.sha = fc4... ✓
                 │
                 ├─ echo 36049 > pr/pr_number
                 ├─ echo fc4... > pr/pr_sha
                 └─ upload-artifact: pr_info
                    └─ Artifact ID: 12345

2. Codebuild completes ──► workflow_run event fires
                            │
                            └─ github.event.workflow_run.id = 19342493369

3. PR Linter triggered ──► download-if-workflow-run job
                            │
                            ├─ Download artifact from run 19342493369
                            │  └─ Finds pr_info artifact (ID: 12345) ✓
                            │
                            ├─ Extract files:
                            │  ├─ pr/pr_number = 36049 ✓
                            │  └─ pr/pr_sha = fc4... ✓
                            │
                            └─ Pass to validate-pr job:
                               └─ PR_NUMBER=36049 ✓
                               └─ PR_SHA=fc4... ✓

4. validate-pr job ──► Validates PR #36049 ✓
```

SUMMARY:
--------
The solution works because it:
  1. Captures PR context when it's available (Codebuild)
  2. Persists it in an artifact (survives context switch)
  3. Restores it when needed (PR Linter)
  4. Bypasses GitHub's pull_requests array limitation

See #36055 for details


## How do I validate 

### Test Environment
Validated on fork repository: pahud#16

### Validation Steps

1. **Applied the fix** to fork's `codebuild-pr-build.yml` (artifact upload steps)
2. **Created test PR** to trigger workflows
3. **Verified Codebuild workflow** uploaded `pr_info` artifact successfully
4. **Verified PR Linter workflow** downloaded artifact and applied label

### Results

✅ **Codebuild PR Build**: Successfully uploaded `pr_info` artifact containing:
- `pr_number`: 16
- `pr_sha`: ebeaa4c...

✅ **PR Linter**: Successfully validated PR and applied label
- Workflow run: https://github.com/pahud/aws-cdk/actions/runs/19380492593
- Label applied: `pr/needs-community-review`
- Status: ✅ Success

### Evidence

**Before fix:**
- PR Linter failed with "Cannot determine PR number"
- No `pr_info` artifact available
- workflow_run.pull_requests array was empty

**After fix:**
- PR Linter successfully downloaded `pr_info` artifact
- Correctly identified PR number and SHA
- Applied appropriate review label

### Note on Fork Testing

For fork testing only, I added a `pull_request_target` fallback to `pr-linter.yml` since `workflow_run` events don't trigger from fork workflows. This fallback is **not needed** for aws/aws-cdk as workflows run in the base repository context where `workflow_run` works correctly.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant