Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/actions/create-package-validation-issue/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
*.log
.DS_Store
152 changes: 152 additions & 0 deletions .github/actions/create-package-validation-issue/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# Create Package Validation Issue Action

This GitHub Action creates or updates issues when package validation failures are detected in the Pipedream repository.

## Features

- ✅ **Smart Issue Management**: Creates new issues or updates existing ones for the same day
- 📊 **Rich Reporting**: Includes detailed summaries, failure categories, and quick action commands
- 🔄 **Fallback Support**: Works with both JSON and text validation reports
- 🏷️ **Auto-labeling**: Automatically applies appropriate labels for organization
- 📈 **Failure Analysis**: Groups failures by category for easier debugging

## Inputs

| Input | Description | Required | Default |
|-------|-------------|----------|---------|
| `github-token` | GitHub token for API access | ✅ | - |
| `validation-report-json` | Path to JSON validation report | ✅ | `validation-report.json` |
| `validation-report-txt` | Path to text validation report | ❌ | `validation-report.txt` |
| `workflow-run-number` | GitHub workflow run number | ✅ | - |
| `workflow-run-id` | GitHub workflow run ID | ✅ | - |
| `server-url` | GitHub server URL | ✅ | - |
| `repository` | Repository name (owner/repo) | ✅ | - |

## Outputs

| Output | Description | Example |
|--------|-------------|---------|
| `issue-created` | Whether a new issue was created | `true`/`false` |
| `issue-updated` | Whether an existing issue was updated | `true`/`false` |
| `issue-url` | URL of the created/updated issue | `https://github.com/...` |
| `failed-count` | Number of failed packages | `42` |

**Note**: All outputs are properly set for both regular and composite actions, supporting `core.setOutput()` and `$GITHUB_OUTPUT` file methods.

## Usage

```yaml
- name: Create Issue on Failures
if: steps.check_failures.outputs.failed_count != '0'
uses: ./.github/actions/create-package-validation-issue
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
validation-report-json: 'validation-report.json'
validation-report-txt: 'validation-report.txt' # optional
workflow-run-number: ${{ github.run_number }}
workflow-run-id: ${{ github.run_id }}
server-url: ${{ github.server_url }}
repository: ${{ github.repository }}
```

## Issue Format

The action creates issues with:

### 📦 Title Format
```
📦 Package Validation Report - [Date] - [X] failures
```

### 📋 Content Sections
1. **Summary**: Overview statistics of validation results
2. **Links**: Direct links to workflow run and artifacts
3. **Failed Packages**: List of top failing packages with error types
4. **Failure Categories**: Grouped failures by validation type
5. **Next Steps**: Action items for developers
6. **Quick Commands**: Copy-paste commands for local testing

### 🏷️ Auto-applied Labels
- `package-validation`: Identifies validation-related issues
- `automated`: Marks as automatically created
- `bug`: Indicates packages needing fixes

## Behavior

### New Issues
- Creates a new issue if no open validation issue exists for the current date
- Applies appropriate labels automatically

### Existing Issues
- Updates existing issues with new validation results as comments
- Avoids creating duplicate issues for the same day
- Maintains issue history through comments

### No Failures
- Skips issue creation when no validation failures are detected
- Sets output flags appropriately for workflow logic

## Error Handling

- **JSON Parse Errors**: Falls back to text report parsing
- **Missing Files**: Gracefully handles missing report files
- **API Failures**: Provides detailed error messages for debugging
- **Network Issues**: Fails gracefully with actionable error messages

## Development

### Local Testing
```bash
# Install dependencies
cd .github/actions/create-package-validation-issue
npm install

# Test with sample data
node test/test-action.js
```

### Dependencies
- `@actions/core`: GitHub Actions toolkit for inputs/outputs
- `@actions/github`: GitHub API client and context

### Technical Notes
- **Composite Action**: Uses `composite` action type to handle dependency installation automatically
- **Auto-Install**: Dependencies are installed during action execution for reliability
- **Path Resolution**: File paths are resolved relative to the GitHub workspace
- **Fallback Support**: Gracefully handles missing files and parse errors

## Integration

This action is designed to work with:
- `scripts/generate-package-report.js`: Validation report generator
- `.github/workflows/scheduled-package-validation.yaml`: Scheduled validation workflow
- Pipedream component validation pipeline

## Example Issue Output

```markdown
# 📦 Scheduled Package Validation Report - Mon Jan 15 2024

📊 **Summary:**
- Total Components: 2932
- ✅ Validated: 2847
- ❌ Failed: 85
- ⏭️ Skipped: 1250
- 📈 Publishable: 2932
- 📉 Failure Rate: 2.90%

## 🔗 Links
- **Workflow Run**: [#123](https://github.com/org/repo/actions/runs/456)
- **Download Reports**: Check the workflow artifacts for detailed reports

## ❌ Failed Packages
- **@pipedream/netlify** (netlify): import, dependencies
- **@pipedream/google-slides** (google_slides): mainFile
- ... and 83 more packages

## Next Steps
1. Review the failed packages listed above
2. Check the full validation report artifact
3. Fix import/dependency issues in failing packages
...
```
69 changes: 69 additions & 0 deletions .github/actions/create-package-validation-issue/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: 'Create Package Validation Issue'
description: 'Creates or updates GitHub issues when package validation failures are detected'
inputs:
github-token:
description: 'GitHub token for creating issues'
required: true
validation-report-json:
description: 'Path to the JSON validation report file'
required: true
default: 'validation-report.json'
validation-report-txt:
description: 'Path to the text validation report file'
required: false
default: 'validation-report.txt'
workflow-run-number:
description: 'GitHub workflow run number'
required: true
workflow-run-id:
description: 'GitHub workflow run ID'
required: true
server-url:
description: 'GitHub server URL'
required: true
repository:
description: 'Repository name in owner/repo format'
required: true

outputs:
issue-created:
description: 'Whether a new issue was created'
value: ${{ steps.run_issue_creation.outputs.issue-created }}
issue-updated:
description: 'Whether an existing issue was updated'
value: ${{ steps.run_issue_creation.outputs.issue-updated }}
issue-url:
description: 'URL of the created/updated issue'
value: ${{ steps.run_issue_creation.outputs.issue-url }}
failed-count:
description: 'Number of failed packages'
value: ${{ steps.run_issue_creation.outputs.failed-count }}

runs:
using: 'composite'
steps:
- name: Setup Node.js for action
uses: actions/[email protected]
with:
node-version: '20'

- name: Install action dependencies
shell: bash
run: |
cd ${{ github.action_path }}
npm install

- name: Run issue creation
id: run_issue_creation
shell: bash
run: |
cd ${{ github.action_path }}
node src/index.js
env:
INPUT_GITHUB_TOKEN: ${{ inputs.github-token }}
INPUT_VALIDATION_REPORT_JSON: ${{ inputs.validation-report-json }}
INPUT_VALIDATION_REPORT_TXT: ${{ inputs.validation-report-txt }}
INPUT_WORKFLOW_RUN_NUMBER: ${{ inputs.workflow-run-number }}
INPUT_WORKFLOW_RUN_ID: ${{ inputs.workflow-run-id }}
INPUT_SERVER_URL: ${{ inputs.server-url }}
INPUT_REPOSITORY: ${{ inputs.repository }}
21 changes: 21 additions & 0 deletions .github/actions/create-package-validation-issue/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "create-package-validation-issue",
"version": "1.0.0",
"description": "GitHub Action to create or update issues for package validation failures",
"main": "src/index.js",
"scripts": {
"test": "echo \"No tests yet\" && exit 0"
},
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0"
},
"keywords": [
"github-action",
"pipedream",
"package-validation",
"issues"
],
"author": "Pipedream",
"license": "MIT"
}
Loading
Loading