Update CodeQL workflow with timeout, fail-fast error handling, and rosdep resilience
Changes
This PR improves the CodeQL CI workflow configuration to ensure more reliable and efficient execution:
1. Added Job Timeout
- Set
timeout-minutes: 60for the analyze job to prevent indefinite hangs - The job will now fail gracefully after 1 hour if it hasn't completed, though healthy runs should finish well before this limit
2. Added Fail-Fast Error Handling
- Added
set -eto all shell script steps (Prepare ROS, Install package dependencies, Build package) - This ensures each step fails immediately on any command error rather than continuing silently
- Prevents workflows from hanging or producing misleading success status when errors occur
3. Improved rosdep Initialization
- Added
|| echo "rosdep already initialized"to therosdep initstep - Prevents workflow failures in environments where rosdep is already initialized
- Makes the workflow more resilient to different execution contexts
Impact
These changes are workflow-only modifications with no impact on the codebase. The CodeQL job will now:
- Start and complete more reliably
- Fail early and clearly when errors occur
- Handle edge cases like pre-initialized rosdep gracefully
- Have a safety timeout to prevent resource waste
The runner version remains unchanged at ubuntu-20.04.
Original prompt
Update CI configuration to ensure CodeQL job starts and finishes efficiently. Set timeout-minutes to 60 for the analyze job. Add set -e to all shell script steps to fail fast on any error and prevent silent workflow hangs. Add || echo "rosdep already initialized" to the rosdep init step to avoid failures if rosdep is already initialized. Do not change the runner version. No codebase changes – only update the workflow file.
Refer to the workflow file: !.github/workflows/codeql-analysis.yml
The CodeQL job should now reliably start, fail early on errors, and have a timeout of 1 hour, but should typically finish well before that when the job is healthy.
This pull request was created as a result of the following prompt from Copilot chat.
Update CI configuration to ensure CodeQL job starts and finishes efficiently. Set timeout-minutes to 60 for the analyze job. Add set -e to all shell script steps to fail fast on any error and prevent silent workflow hangs. Add || echo "rosdep already initialized" to the rosdep init step to avoid failures if rosdep is already initialized. Do not change the runner version. No codebase changes – only update the workflow file.
Refer to the workflow file: !.github/workflows/codeql-analysis.yml
The CodeQL job should now reliably start, fail early on errors, and have a timeout of 1 hour, but should typically finish well before that when the job is healthy.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.