๐ Profiling Workflow
The Profiling workflow is an automated GitHub Actions workflow that generates and compares performance profiles for Kepler when changes are made to the codebase. This workflow helps developers understand the performance impact of their changes by providing detailed CPU and memory profiling data.
๐ฏ Purpose
The profiling workflow serves several critical purposes:
- ๐ Performance Regression Detection: Automatically identifies potential performance degradations introduced by code changes
- ๐ Resource Usage Analysis: Provides detailed insights into CPU and memory consumption patterns
- โ๏ธ Comparative Analysis: Compares performance metrics between the development version and the latest stable version
- ๐ Continuous Performance Monitoring: Ensures performance considerations are part of the development process
๐ Workflow Overview
๐๏ธ Workflow Structure
The profiling workflow consists of three main jobs:
1. ๐ Check Changes Job
- ๐ฏ Purpose: Determines if profiling should run based on file changes
- โก Trigger: Runs on every pull request
2. ๐ Profiling Job
- ๐ฏ Purpose: Executes the actual profiling process
- โ ๏ธ Conditions: Only runs if relevant changes are detected
3. ๐ฌ Generate Comment Message Job
- ๐ฏ Purpose: Creates a formatted comment message with profiling results
- โ ๏ธ Conditions: Only runs if profiling job succeeds
- ๐ฆ Output: Generates artifacts containing:
- Formatted profiling comparison results
- Download instructions for profiling artifacts
- GitHub CLI commands for artifact retrieval
โจ Key Features
๐ค Automated Environment Setup
The workflow automatically provisions a complete testing environment including:
- ๐ณ Docker containerization for isolated testing
- ๐ Both development and production Kepler versions
๐ฌ Comprehensive Profiling
- โฑ๏ธ Duration: 60-second profiling sessions for statistically significant data
- ๐ Metrics: CPU and memory usage patterns
- ๐ Comparison: Side-by-side analysis of different versions
๐ฆ Artifact Management
- ๐๏ธ Retention: Profiling artifacts retained for 5 days
- ๐ท๏ธ Naming: Artifacts named with PR numbers for easy identification
- ๐ฅ Access: Multiple download methods provided (web interface, GitHub CLI)
๐ Security Considerations
๐ค Why Separate Comment Message Generation?
The workflow uploads comment messages as artifacts rather than directly posting comments to pull requests. This approach addresses critical security concerns outlined in issue #2287.
โ ๏ธ Security Challenge
Using the pull_request_target
event for PR comments creates security risks because:
- โก The workflow runs in the context of the target branch with full repository permissions
- ๐ก๏ธ Malicious code in PR branches could potentially access sensitive information
- ๐ Direct comment posting from PR contexts poses privilege escalation risks
โ Secure Solution
The current approach implements a two-stage security model:
- ๐ Source Workflow (this profiling workflow):
- ๐ Runs in the limited context of the PR branch
- ๐ก๏ธ Generates comment content safely
-
๐ค Uploads message as an artifact (no direct repository access)
-
๐ฌ Dedicated PR Comment Workflow:
- ๐ Runs separately using the safer
workflow_run
event trigger - ๐ฅ Downloads the pre-generated comment artifact
- ๐ Posts comments with proper base branch context
- ๐ก๏ธ Maintains security isolation
๐ฏ Benefits of This Approach
- ๐ Security Isolation: PR comment workflows run in base branch context, not PR context
- ๐ก๏ธ Reduced Attack Surface: Limited permissions for content generation workflows
- ๐ Audit Trail: Clear separation of content generation and posting actions
- โป๏ธ Reusability: Comment generation pattern can be reused across multiple workflows
๐ Usage
The profiling workflow automatically triggers on pull requests that modify relevant files. No manual intervention is required. Results are available through:
- ๐ GitHub Actions Summary: View workflow execution details and download artifacts
- ๐ฌ PR Comments: Automated comments with profiling summaries (posted by separate workflow)
- ๐ฆ Artifacts: Detailed profiling data available for download and local analysis