Skip to content

Support auto-detecting Actions workflows #3009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 7, 2025
Merged

Support auto-detecting Actions workflows #3009

merged 3 commits into from
Aug 7, 2025

Conversation

mbg
Copy link
Member

@mbg mbg commented Aug 7, 2025

This modifies getRawLanguagesInRepo to automatically detect Actions workflows. Linguist does not class those as a language, and so we failed to automatically detect them before.

I chose to implement this by checking for a non-empty .github/workflows directory, relative to source-root.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.
  • Confirm the changelog has been updated if necessary.

@mbg mbg requested a review from a team as a code owner August 7, 2025 10:05
@mbg mbg requested review from Copilot and henrymercer August 7, 2025 10:05
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds automatic detection of GitHub Actions workflows to the CodeQL Action's language detection system. Since GitHub's Linguist API doesn't classify Actions workflows as a language, this enhancement enables the CodeQL Action to detect them by checking for a non-empty .github/workflows directory.

Key changes:

  • Added hasActionsWorkflows() function to detect workflows by checking for files in .github/workflows
  • Modified getRawLanguagesInRepo() to include "actions" when workflows are detected
  • Updated function signatures throughout the codebase to pass sourceRoot parameter

Reviewed Changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated no comments.

File Description
src/config-utils.ts Implements workflow detection logic and updates language detection functions
src/config-utils.test.ts Updates test calls to include new sourceRoot parameter
lib/config-utils.js Generated JavaScript equivalent of TypeScript changes
lib/config-utils.test.js Generated JavaScript equivalent of test changes
Comments suppressed due to low confidence (1)

src/config-utils.ts:340

  • The function will throw an exception if the .github/workflows directory doesn't exist, causing lstatSync to fail. This should be wrapped in a try-catch block or use fs.existsSync() first to check if the path exists before calling lstatSync.
  const stats = fs.lstatSync(workflowsPath);
  return stats.isDirectory() && fs.readdirSync(workflowsPath).length > 0;

henrymercer
henrymercer previously approved these changes Aug 7, 2025
Copy link
Contributor

@henrymercer henrymercer left a comment

Choose a reason for hiding this comment

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

We have an implementation of language autodetection in the CLI which I'd like to see us use in the Action too, but given the simplicity of this PR this looks good as a quick fix.

@mbg mbg force-pushed the mbg/auto-detect-actions branch from 2d62781 to f28436b Compare August 7, 2025 11:43
@mbg mbg requested a review from henrymercer August 7, 2025 11:43
@mbg mbg enabled auto-merge August 7, 2025 11:47
@mbg mbg merged commit bc90418 into main Aug 7, 2025
282 checks passed
@mbg mbg deleted the mbg/auto-detect-actions branch August 7, 2025 11:58
@github-actions github-actions bot mentioned this pull request Aug 7, 2025
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants