feat: Add support for push, pull_request, and workflow_dispatch events#124
Merged
feat: Add support for push, pull_request, and workflow_dispatch events#124
Conversation
…ent workflow monitoring; improve test coverage for job handling and update types for workflow status and conclusion
…incomplete jobs; improve filtering logic in getLatestCompletedAt function
- Fix type safety issues in getLatestCompletedAt with proper type guards - Fix incorrect attempt_number fallback logic (remove context.runNumber) - Add proper handling for in_progress status in span creation - Improve error messages with job ID/name context for better debugging - Add comprehensive test cases for edge scenarios: * Invalid timestamp handling * Mixed valid/invalid data processing * Job status variations (in_progress, queued, completed) * Null/undefined field handling * Steps processing with missing data * Runner information variations * Workflow status edge cases - Enhance error handling with graceful fallbacks - Improve logging with better context and warnings - Add robust null safety throughout the codebase - Fix ESLint violations and improve code quality Coverage improved to 96.12% with 75 comprehensive test cases 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
paper2
commented
Jun 21, 2025
README.md
Outdated
| ### GitHub Actions Examples | ||
|
|
||
| Here's an example of how to set up this action in a GitHub Actions workflow: | ||
| #### Option 1: Monitor Other Workflows (Original) |
paper2
commented
Jun 21, 2025
README.md
Outdated
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| ``` | ||
|
|
||
| #### Option 2: Monitor Current Workflow (New) |
paper2
commented
Jun 21, 2025
paper2
commented
Jun 21, 2025
src/github/github.test.ts
Outdated
| expect(result).toBe('2023-01-01T00:05:00.000Z') | ||
| }) | ||
|
|
||
| test('should handle empty jobs array', () => { |
Owner
Author
There was a problem hiding this comment.
[todo] What is this? I should check this
paper2
commented
Jun 21, 2025
src/github/github.test.ts
Outdated
| } | ||
|
|
||
| // Mix completed jobs with incomplete one (simulating real scenario) | ||
| const mixedJobs = [completedJob1, incompleteJob, completedJob2].filter( |
paper2
commented
Jun 21, 2025
paper2
commented
Jun 21, 2025
src/github/github.test.ts
Outdated
| expect(() => toWorkflowJob(incompleteJob as never)).toThrow( | ||
| 'This job is not completed. id: 1' | ||
| ) | ||
| const result = toWorkflowJob(incompleteJob as never) |
Owner
Author
There was a problem hiding this comment.
[todo] これnullで返すのどうだろうな〜。モデルの型を分けておいて、それで区別できるようにしておいた方が良くないかな。
paper2
commented
Jun 21, 2025
src/github/github.ts
Outdated
| const runId = settings.workflowRunId ?? workflowRunEvent?.workflow_run?.id | ||
| // Priority order: | ||
| // 1. Environment variable (for testing) | ||
| // 2. workflow_run event payload (existing functionality) |
paper2
commented
Jun 21, 2025
src/github/github.ts
Outdated
| const jobCompletedAtDates = jobs.map(job => new Date(job.completed_at)) | ||
| const maxDateNumber = Math.max(...jobCompletedAtDates.map(Number)) | ||
| return new Date(maxDateNumber).toISOString() | ||
| // Filter jobs that have completed_at with proper type guard |
Owner
Author
There was a problem hiding this comment.
ここで終わってないjobをfitlterするのは微妙だからやめたい。元の関数に戻したい。
paper2
commented
Jun 21, 2025
src/github/types.ts
Outdated
| readonly id: number | ||
| readonly name: string | ||
| readonly status: 'completed' | ||
| readonly status: 'completed' | 'in_progress' |
Owner
Author
There was a problem hiding this comment.
ステータス他を考慮しないで良いか確認。workflowは処理が変わるので、statusの違いなどは型を分けて表現するのもありかも。
paper2
commented
Jun 21, 2025
paper2
commented
Jun 21, 2025
paper2
commented
Jun 21, 2025
| if (!job.workflow_name) throw new Error('Job workflow_name is required') | ||
| if (!job.completed_at) | ||
| throw new Error( | ||
| `Job completed_at is required for job: ${job.name} (id: ${job.id})` |
paper2
commented
Jun 21, 2025
| ) | ||
| if (!job.workflow_name) | ||
| throw new Error( | ||
| `Job workflow_name is required for job: ${job.name} (id: ${job.id})` |
paper2
commented
Jun 21, 2025
src/github/types.ts
Outdated
| // while maintaining strict validation for workflow_run events | ||
| if ( | ||
| workflowRun.status !== 'completed' && | ||
| workflowRun.status !== 'in_progress' |
paper2
commented
Jun 21, 2025
src/github/types.ts
Outdated
| throw new Error('Workflow run conclusion is required') | ||
|
|
||
| // For in_progress workflows, conclusion might be null | ||
| if (workflowRun.status === 'completed' && !workflowRun.conclusion) { |
Owner
Author
There was a problem hiding this comment.
このif文入れるなら型をしっかり分けておいた方が良い気がするな
paper2
commented
Jun 21, 2025
src/github/github.test.ts
Outdated
|
|
||
| expect(() => toWorkflowJob(jobWithoutWorkflowName as never)).toThrow( | ||
| 'Job workflow_name is required' | ||
| 'Job workflow_name is required for job: test-job (id: 1)' |
…elemetry into feat/multi-event-support
…elemetry into feat/multi-event-support
- Add expected Workflow object in toWorkflowRun test for proper validation - Translate run_event.md specification and design documentation from Japanese to English - Improve test structure with expectedWorkflowBase for better maintainability 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…maintain backward compatibility
…github-actions-opentelemetry into feat/multi-event-support
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…ilters for normalization
…ics in validation workflow
…ta and improved formatting
…rics in the GitHub Actions workflow
…e checks and improve error reporting
…t for better error visibility
… workflow to reflect new expected file naming conventions
…ected traces and metrics files
… error handling for trace and metric validation
…e outdated run event documentation
… for improved testability
…dling for fetchWorkflowResults
…e unnecessary warnings for jobs without steps; update workflow conclusion handling to avoid using empty string.
308ea81 to
4236541
Compare
…metry configuration; bump version to v0.7.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR extends the GitHub Action to support monitoring the current workflow in addition to the existing workflow_run event functionality. This enables telemetry collection for push, pull_request, and workflow_dispatch events while maintaining full backward compatibility.
Key Benefits:
Changes Made
Core Functionality
getWorkflowContext()with intelligent fallback priority (environment variable → workflow_run event → current context)toWorkflowJob()to return null for incomplete jobs instead of throwing errorsData Processing Improvements
getLatestCompletedAt()to filter out incomplete jobs with null timestampstoWorkflowRun()to process both 'completed' and 'in_progress' workflow statusesTesting & Quality
Usage Patterns
Option 1: External Workflow Monitoring (Existing)
Monitor completed workflows from external events:
Option 2: Current Workflow Monitoring (New)
Monitor the current workflow execution:
Technical Implementation
Testing Strategy
Impact & Benefits
This enhancement enables teams to:
Closes #106
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com