mirror of
https://github.com/threeal/cmake-action.git
synced 2025-04-21 11:01:20 +00:00
fix: fix default build dir not relative to source dir (#269)
* test: fix get action inputs test when source dir specified * fix: default build dir should relative to source dir * ci: fix test directory location
This commit is contained in:
parent
5c7d8af23f
commit
21ddda7def
6
.github/workflows/test.yaml
vendored
6
.github/workflows/test.yaml
vendored
@ -71,7 +71,6 @@ jobs:
|
|||||||
run: mv test/* .
|
run: mv test/* .
|
||||||
|
|
||||||
- name: Configure and Build Project
|
- name: Configure and Build Project
|
||||||
id: cmake-action
|
|
||||||
uses: ./
|
uses: ./
|
||||||
|
|
||||||
- name: Test Project
|
- name: Test Project
|
||||||
@ -135,6 +134,7 @@ jobs:
|
|||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: threeal/ctest-action@v1.0.0
|
uses: threeal/ctest-action@v1.0.0
|
||||||
with:
|
with:
|
||||||
|
test-dir: ${{ steps.cmake-action.outputs.build-dir }}
|
||||||
tests-regex: hello_world
|
tests-regex: hello_world
|
||||||
|
|
||||||
- name: Previous Step Should Failed
|
- name: Previous Step Should Failed
|
||||||
@ -159,6 +159,7 @@ jobs:
|
|||||||
sparse-checkout-cone-mode: false
|
sparse-checkout-cone-mode: false
|
||||||
|
|
||||||
- name: Configure and Build Project
|
- name: Configure and Build Project
|
||||||
|
id: cmake-action
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
source-dir: test
|
source-dir: test
|
||||||
@ -170,6 +171,7 @@ jobs:
|
|||||||
- name: Test Project
|
- name: Test Project
|
||||||
uses: threeal/ctest-action@v1.0.0
|
uses: threeal/ctest-action@v1.0.0
|
||||||
with:
|
with:
|
||||||
|
test-dir: ${{ steps.cmake-action.outputs.build-dir }}
|
||||||
build-config: Debug
|
build-config: Debug
|
||||||
tests-regex: test
|
tests-regex: test
|
||||||
|
|
||||||
@ -194,6 +196,7 @@ jobs:
|
|||||||
uses: seanmiddleditch/gha-setup-ninja@v4
|
uses: seanmiddleditch/gha-setup-ninja@v4
|
||||||
|
|
||||||
- name: Configure and Build Project
|
- name: Configure and Build Project
|
||||||
|
id: cmake-action
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
source-dir: test
|
source-dir: test
|
||||||
@ -206,4 +209,5 @@ jobs:
|
|||||||
- name: Test Project
|
- name: Test Project
|
||||||
uses: threeal/ctest-action@v1.0.0
|
uses: threeal/ctest-action@v1.0.0
|
||||||
with:
|
with:
|
||||||
|
test-dir: ${{ steps.cmake-action.outputs.build-dir }}
|
||||||
tests-regex: test
|
tests-regex: test
|
||||||
|
38
dist/index.js
generated
vendored
38
dist/index.js
generated
vendored
@ -27685,6 +27685,35 @@ module.exports = parseParams
|
|||||||
/******/ }
|
/******/ }
|
||||||
/******/
|
/******/
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
/******/ /* webpack/runtime/compat get default export */
|
||||||
|
/******/ (() => {
|
||||||
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||||
|
/******/ __nccwpck_require__.n = (module) => {
|
||||||
|
/******/ var getter = module && module.__esModule ?
|
||||||
|
/******/ () => (module['default']) :
|
||||||
|
/******/ () => (module);
|
||||||
|
/******/ __nccwpck_require__.d(getter, { a: getter });
|
||||||
|
/******/ return getter;
|
||||||
|
/******/ };
|
||||||
|
/******/ })();
|
||||||
|
/******/
|
||||||
|
/******/ /* webpack/runtime/define property getters */
|
||||||
|
/******/ (() => {
|
||||||
|
/******/ // define getter functions for harmony exports
|
||||||
|
/******/ __nccwpck_require__.d = (exports, definition) => {
|
||||||
|
/******/ for(var key in definition) {
|
||||||
|
/******/ if(__nccwpck_require__.o(definition, key) && !__nccwpck_require__.o(exports, key)) {
|
||||||
|
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
||||||
|
/******/ }
|
||||||
|
/******/ }
|
||||||
|
/******/ };
|
||||||
|
/******/ })();
|
||||||
|
/******/
|
||||||
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
||||||
|
/******/ (() => {
|
||||||
|
/******/ __nccwpck_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||||
|
/******/ })();
|
||||||
|
/******/
|
||||||
/******/ /* webpack/runtime/compat */
|
/******/ /* webpack/runtime/compat */
|
||||||
/******/
|
/******/
|
||||||
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = new URL('.', import.meta.url).pathname.slice(import.meta.url.match(/^file:\/\/\/\w:/) ? 1 : 0, -1) + "/";
|
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = new URL('.', import.meta.url).pathname.slice(import.meta.url.match(/^file:\/\/\/\w:/) ? 1 : 0, -1) + "/";
|
||||||
@ -27735,12 +27764,17 @@ async function buildProject(inputs) {
|
|||||||
await (0,exec.exec)("cmake", ["--build", inputs.buildDir, ...inputs.buildArgs]);
|
await (0,exec.exec)("cmake", ["--build", inputs.buildDir, ...inputs.buildArgs]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
;// CONCATENATED MODULE: external "node:path"
|
||||||
|
const external_node_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:path");
|
||||||
|
var external_node_path_default = /*#__PURE__*/__nccwpck_require__.n(external_node_path_namespaceObject);
|
||||||
;// CONCATENATED MODULE: ./src/inputs.ts
|
;// CONCATENATED MODULE: ./src/inputs.ts
|
||||||
|
|
||||||
|
|
||||||
function getInputs() {
|
function getInputs() {
|
||||||
|
const sourceDir = (0,core.getInput)("source-dir") || ".";
|
||||||
return {
|
return {
|
||||||
sourceDir: (0,core.getInput)("source-dir") || ".",
|
sourceDir,
|
||||||
buildDir: (0,core.getInput)("build-dir") || "build",
|
buildDir: (0,core.getInput)("build-dir") || external_node_path_default().join(sourceDir, "build"),
|
||||||
generator: (0,core.getInput)("generator"),
|
generator: (0,core.getInput)("generator"),
|
||||||
cCompiler: (0,core.getInput)("c-compiler"),
|
cCompiler: (0,core.getInput)("c-compiler"),
|
||||||
cxxCompiler: (0,core.getInput)("cxx-compiler"),
|
cxxCompiler: (0,core.getInput)("cxx-compiler"),
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { jest } from "@jest/globals";
|
import { jest } from "@jest/globals";
|
||||||
|
import path from "node:path";
|
||||||
import type { Inputs } from "./inputs.js";
|
import type { Inputs } from "./inputs.js";
|
||||||
|
|
||||||
jest.unstable_mockModule("@actions/core", () => ({
|
jest.unstable_mockModule("@actions/core", () => ({
|
||||||
@ -23,13 +24,27 @@ describe("get action inputs", () => {
|
|||||||
{
|
{
|
||||||
name: "with source directory specified",
|
name: "with source directory specified",
|
||||||
stringInputs: { "source-dir": "project" },
|
stringInputs: { "source-dir": "project" },
|
||||||
expectedInputs: { sourceDir: "project" },
|
expectedInputs: {
|
||||||
|
sourceDir: "project",
|
||||||
|
buildDir: path.join("project", "build"),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "with build directory specified",
|
name: "with build directory specified",
|
||||||
stringInputs: { "build-dir": "output" },
|
stringInputs: { "build-dir": "output" },
|
||||||
expectedInputs: { buildDir: "output" },
|
expectedInputs: { buildDir: "output" },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "with source and build directories specified",
|
||||||
|
stringInputs: {
|
||||||
|
"source-dir": "project",
|
||||||
|
"build-dir": "output",
|
||||||
|
},
|
||||||
|
expectedInputs: {
|
||||||
|
sourceDir: "project",
|
||||||
|
buildDir: "output",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "with generator specified",
|
name: "with generator specified",
|
||||||
stringInputs: { generator: "Ninja" },
|
stringInputs: { generator: "Ninja" },
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { getBooleanInput, getInput, getMultilineInput } from "@actions/core";
|
import { getBooleanInput, getInput, getMultilineInput } from "@actions/core";
|
||||||
|
import path from "node:path";
|
||||||
|
|
||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
sourceDir: string;
|
sourceDir: string;
|
||||||
@ -15,9 +16,10 @@ export interface Inputs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getInputs(): Inputs {
|
export function getInputs(): Inputs {
|
||||||
|
const sourceDir = getInput("source-dir") || ".";
|
||||||
return {
|
return {
|
||||||
sourceDir: getInput("source-dir") || ".",
|
sourceDir,
|
||||||
buildDir: getInput("build-dir") || "build",
|
buildDir: getInput("build-dir") || path.join(sourceDir, "build"),
|
||||||
generator: getInput("generator"),
|
generator: getInput("generator"),
|
||||||
cCompiler: getInput("c-compiler"),
|
cCompiler: getInput("c-compiler"),
|
||||||
cxxCompiler: getInput("cxx-compiler"),
|
cxxCompiler: getInput("cxx-compiler"),
|
||||||
|
Loading…
Reference in New Issue
Block a user