Skip to content

Commit 0197c38

Browse files
mario-camposaofaof0907
authored andcommitted
Make 'source-root' init input relative to github.workspace
In the previous commit, the default value of the input is ${{ github.workspace }} which means that most uses of this input would probably prefix their paths with ${{ github.workspace }}, especially since actions/checkout's 'path' input must be under ${{ github.workspace }}. Therefore, it doesn't make much sense for this to be an absolute file path. Instead, it's more intuitive to make this relative to the repository.
1 parent b68e0b2 commit 0197c38

4 files changed

Lines changed: 13 additions & 9 deletions

File tree

init/action.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ inputs:
3939
required: true
4040
default: 'true'
4141
source-root:
42-
description: The root source-code directory.
43-
required: true
44-
default: ${{ github.workspace }}
42+
description: Path to the root source-code directory, relative to ${{ github.workspace }}.
43+
required: false
4544
outputs:
4645
codeql-path:
4746
description: The path of the CodeQL binary used for analysis

lib/init-action.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/init-action.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as path from "path";
2+
13
import * as core from "@actions/core";
24

35
import {
@@ -201,11 +203,12 @@ async function run() {
201203
const codeqlRam = process.env["CODEQL_RAM"] || "6500";
202204
core.exportVariable("CODEQL_RAM", codeqlRam);
203205

204-
const tracerConfig = await runInit(
205-
codeql,
206-
config,
207-
getRequiredInput("source-root")
206+
const sourceRoot = path.join(
207+
getRequiredEnvParam("GITHUB_WORKSPACE"),
208+
getOptionalInput("source-root") || ""
208209
);
210+
211+
const tracerConfig = await runInit(codeql, config, sourceRoot);
209212
if (tracerConfig !== undefined) {
210213
for (const [key, value] of Object.entries(tracerConfig.env)) {
211214
core.exportVariable(key, value);

0 commit comments

Comments
 (0)