Skip to content

codeql-action/init workflow validation doesn't respect custom source-root #3142

@g-ulli

Description

@g-ulli

We get the warning

Warning: Unable to validate code scanning workflow: error: getWorkflow() failed: Error: Expected to find a code scanning workflow file at /home/runner/_work/ProDriver-Safety-Path/ProDriver-Safety-Path/.github/workflows/nightly_codeql.yml, but no such file existed. This can happen if the currently running workflow checks out a branch that doesn't contain the corresponding workflow file.

in our custom CodeQL workflow. We check out our repository in a custom location and specify this location using source-root:

  - name: Checkout
    uses: actions/checkout@v4
    if: always()
    with:
        path: "my-custom-path"

  - name: Initialize CodeQL
    uses: github/codeql-action/init@v3
    with:
        languages: ${{ matrix.language }}
        build-mode: ${{ matrix.build-mode }}
        source-root: "my-custom-path"

It looks like the bug is this code:

async function getWorkflowAbsolutePath(logger: Logger): Promise<string> {
const relativePath = await api.getWorkflowRelativePath();
const absolutePath = path.join(
getRequiredEnvParam("GITHUB_WORKSPACE"),
relativePath,
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions