mirror of
https://github.com/threeal/cmake-action.git
synced 2025-12-21 07:45:12 +00:00
Compare commits
No commits in common. "main" and "v2.1.0" have entirely different histories.
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1,2 +1,2 @@
|
|||||||
dist/** -diff linguist-generated
|
dist/** -diff linguist-generated
|
||||||
pnpm-lock.yaml -diff linguist-generated
|
yarn.lock -diff linguist-generated
|
||||||
|
|||||||
4
.github/dependabot.yaml
vendored
4
.github/dependabot.yaml
vendored
@ -6,7 +6,7 @@ updates:
|
|||||||
interval: daily
|
interval: daily
|
||||||
commit-message:
|
commit-message:
|
||||||
prefix: chore
|
prefix: chore
|
||||||
labels: []
|
labels: [chore]
|
||||||
|
|
||||||
- package-ecosystem: npm
|
- package-ecosystem: npm
|
||||||
directory: /
|
directory: /
|
||||||
@ -14,5 +14,5 @@ updates:
|
|||||||
interval: daily
|
interval: daily
|
||||||
commit-message:
|
commit-message:
|
||||||
prefix: chore
|
prefix: chore
|
||||||
labels: []
|
labels: [chore]
|
||||||
versioning-strategy: increase
|
versioning-strategy: increase
|
||||||
|
|||||||
35
.github/workflows/build.yaml
vendored
35
.github/workflows/build.yaml
vendored
@ -5,30 +5,23 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
jobs:
|
jobs:
|
||||||
build-action:
|
build-package:
|
||||||
name: Build Action
|
name: Build Package
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Project
|
- name: Checkout Project
|
||||||
uses: actions/checkout@v5.0.0
|
uses: actions/checkout@v4.2.2
|
||||||
|
|
||||||
- name: Setup pnpm
|
- name: Setup Node.js
|
||||||
uses: threeal/setup-pnpm-action@v1.0.0
|
uses: actions/setup-node@v4.1.0
|
||||||
|
with:
|
||||||
|
node-version-file: .nvmrc
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Setup Yarn
|
||||||
run: pnpm install
|
uses: threeal/setup-yarn-action@v2.0.0
|
||||||
|
|
||||||
- name: Check Types
|
- name: Build Package
|
||||||
run: pnpm tsc
|
run: yarn build
|
||||||
|
|
||||||
- name: Test Action
|
- name: Check Diff
|
||||||
run: pnpm test
|
run: git diff && git diff-index --quiet --exit-code HEAD
|
||||||
|
|
||||||
- name: Check Formatting
|
|
||||||
run: pnpm prettier --check .
|
|
||||||
|
|
||||||
- name: Check Lint
|
|
||||||
run: pnpm eslint
|
|
||||||
|
|
||||||
- name: Build Action
|
|
||||||
run: pnpm rollup -c && git diff --exit-code dist
|
|
||||||
|
|||||||
30
.github/workflows/check.yaml
vendored
Normal file
30
.github/workflows/check.yaml
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
name: Check
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
jobs:
|
||||||
|
check-package:
|
||||||
|
name: Check Package
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- name: Checkout Project
|
||||||
|
uses: actions/checkout@v4.2.2
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4.1.0
|
||||||
|
with:
|
||||||
|
node-version-file: .nvmrc
|
||||||
|
|
||||||
|
- name: Setup Yarn
|
||||||
|
uses: threeal/setup-yarn-action@v2.0.0
|
||||||
|
|
||||||
|
- name: Check Formatting
|
||||||
|
run: yarn format
|
||||||
|
|
||||||
|
- name: Check Diff
|
||||||
|
run: git diff && git diff-index --quiet --exit-code HEAD
|
||||||
|
|
||||||
|
- name: Check Lint
|
||||||
|
run: yarn lint
|
||||||
51
.github/workflows/test.yaml
vendored
51
.github/workflows/test.yaml
vendored
@ -5,22 +5,40 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
jobs:
|
jobs:
|
||||||
|
test-package:
|
||||||
|
name: Test Package
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- name: Checkout Project
|
||||||
|
uses: actions/checkout@v4.2.2
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4.1.0
|
||||||
|
with:
|
||||||
|
node-version-file: .nvmrc
|
||||||
|
|
||||||
|
- name: Setup Yarn
|
||||||
|
uses: threeal/setup-yarn-action@v2.0.0
|
||||||
|
|
||||||
|
- name: Test Package
|
||||||
|
run: yarn test
|
||||||
|
|
||||||
test-action:
|
test-action:
|
||||||
name: Test Action
|
name: Test Action
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-24.04, macos-14, windows-2022]
|
os: [ubuntu-22.04, macos-14, windows-2022]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Sample Project
|
- name: Checkout Sample Project
|
||||||
uses: actions/checkout@v5.0.0
|
uses: actions/checkout@v4.2.2
|
||||||
with:
|
with:
|
||||||
repository: threeal/cpp-starter
|
repository: threeal/cpp-starter
|
||||||
ref: v1.0.0
|
ref: v1.0.0
|
||||||
|
|
||||||
- name: Checkout Action
|
- name: Checkout Action
|
||||||
uses: actions/checkout@v5.0.0
|
uses: actions/checkout@v4.2.2
|
||||||
with:
|
with:
|
||||||
path: cmake-action
|
path: cmake-action
|
||||||
sparse-checkout: |
|
sparse-checkout: |
|
||||||
@ -37,17 +55,17 @@ jobs:
|
|||||||
|
|
||||||
test-action-with-specified-dirs:
|
test-action-with-specified-dirs:
|
||||||
name: Test Action With Specified Directories
|
name: Test Action With Specified Directories
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Sample Project
|
- name: Checkout Sample Project
|
||||||
uses: actions/checkout@v5.0.0
|
uses: actions/checkout@v4.2.2
|
||||||
with:
|
with:
|
||||||
repository: threeal/cpp-starter
|
repository: threeal/cpp-starter
|
||||||
ref: v1.0.0
|
ref: v1.0.0
|
||||||
path: project
|
path: project
|
||||||
|
|
||||||
- name: Checkout Action
|
- name: Checkout Action
|
||||||
uses: actions/checkout@v5.0.0
|
uses: actions/checkout@v4.2.2
|
||||||
with:
|
with:
|
||||||
path: cmake-action
|
path: cmake-action
|
||||||
sparse-checkout: |
|
sparse-checkout: |
|
||||||
@ -67,16 +85,16 @@ jobs:
|
|||||||
|
|
||||||
test-action-without-run-build:
|
test-action-without-run-build:
|
||||||
name: Test Action Without Run Build
|
name: Test Action Without Run Build
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Sample Project
|
- name: Checkout Sample Project
|
||||||
uses: actions/checkout@v5.0.0
|
uses: actions/checkout@v4.2.2
|
||||||
with:
|
with:
|
||||||
repository: threeal/cpp-starter
|
repository: threeal/cpp-starter
|
||||||
ref: v1.0.0
|
ref: v1.0.0
|
||||||
|
|
||||||
- name: Checkout Action
|
- name: Checkout Action
|
||||||
uses: actions/checkout@v5.0.0
|
uses: actions/checkout@v4.2.2
|
||||||
with:
|
with:
|
||||||
path: cmake-action
|
path: cmake-action
|
||||||
sparse-checkout: |
|
sparse-checkout: |
|
||||||
@ -94,16 +112,16 @@ jobs:
|
|||||||
|
|
||||||
test-action-with-additional-options:
|
test-action-with-additional-options:
|
||||||
name: Test Action With Additional Options
|
name: Test Action With Additional Options
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Sample Project
|
- name: Checkout Sample Project
|
||||||
uses: actions/checkout@v5.0.0
|
uses: actions/checkout@v4.2.2
|
||||||
with:
|
with:
|
||||||
repository: threeal/cpp-starter
|
repository: threeal/cpp-starter
|
||||||
ref: v1.0.0
|
ref: v1.0.0
|
||||||
|
|
||||||
- name: Checkout Action
|
- name: Checkout Action
|
||||||
uses: actions/checkout@v5.0.0
|
uses: actions/checkout@v4.2.2
|
||||||
with:
|
with:
|
||||||
path: cmake-action
|
path: cmake-action
|
||||||
sparse-checkout: |
|
sparse-checkout: |
|
||||||
@ -121,16 +139,16 @@ jobs:
|
|||||||
|
|
||||||
test-action-with-custom-generator:
|
test-action-with-custom-generator:
|
||||||
name: Test Action With Custom Generator
|
name: Test Action With Custom Generator
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Sample Project
|
- name: Checkout Sample Project
|
||||||
uses: actions/checkout@v5.0.0
|
uses: actions/checkout@v4.2.2
|
||||||
with:
|
with:
|
||||||
repository: threeal/cpp-starter
|
repository: threeal/cpp-starter
|
||||||
ref: v1.0.0
|
ref: v1.0.0
|
||||||
|
|
||||||
- name: Checkout Action
|
- name: Checkout Action
|
||||||
uses: actions/checkout@v5.0.0
|
uses: actions/checkout@v4.2.2
|
||||||
with:
|
with:
|
||||||
path: cmake-action
|
path: cmake-action
|
||||||
sparse-checkout: |
|
sparse-checkout: |
|
||||||
@ -138,6 +156,9 @@ jobs:
|
|||||||
dist
|
dist
|
||||||
sparse-checkout-cone-mode: false
|
sparse-checkout-cone-mode: false
|
||||||
|
|
||||||
|
- name: Setup Ninja
|
||||||
|
uses: seanmiddleditch/gha-setup-ninja@v5
|
||||||
|
|
||||||
- name: Configure Sample Project
|
- name: Configure Sample Project
|
||||||
id: cmake-action
|
id: cmake-action
|
||||||
uses: ./cmake-action
|
uses: ./cmake-action
|
||||||
|
|||||||
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,6 +1,6 @@
|
|||||||
.*
|
.*
|
||||||
|
!.env.yarn
|
||||||
!.git*
|
!.git*
|
||||||
!.npmrc
|
!.nvmrc
|
||||||
!.prettier*
|
|
||||||
|
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
dist
|
|
||||||
pnpm-lock.yaml
|
|
||||||
README.md
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"plugins": ["prettier-plugin-organize-imports"]
|
|
||||||
}
|
|
||||||
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2023-2025 Alfi Maulana
|
Copyright (c) 2023-2024 Alfi Maulana
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
19
README.md
19
README.md
@ -37,13 +37,13 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build-project:
|
build-project:
|
||||||
name: Build Project
|
name: Build Project
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Project
|
- name: Checkout Project
|
||||||
uses: actions/checkout@v4.2.2
|
uses: actions/checkout@v4.2.1
|
||||||
|
|
||||||
- name: Build Project
|
- name: Build Project
|
||||||
uses: threeal/cmake-action@v2.1.0
|
uses: threeal/cmake-action@v2.0.0
|
||||||
```
|
```
|
||||||
|
|
||||||
### Specify the Source and Build Directories
|
### Specify the Source and Build Directories
|
||||||
@ -52,7 +52,7 @@ By default, this action uses the current working directory as the source directo
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Build Project
|
- name: Build Project
|
||||||
uses: threeal/cmake-action@v2.1.0
|
uses: threeal/cmake-action@v2.0.0
|
||||||
with:
|
with:
|
||||||
source-dir: source
|
source-dir: source
|
||||||
build-dir: output
|
build-dir: output
|
||||||
@ -63,8 +63,11 @@ By default, this action uses the current working directory as the source directo
|
|||||||
The following example demonstrates how to use this action to configure and build the project using [Ninja](https://ninja-build.org/) as the build system generator and [Clang](https://clang.llvm.org/) as the compiler:
|
The following example demonstrates how to use this action to configure and build the project using [Ninja](https://ninja-build.org/) as the build system generator and [Clang](https://clang.llvm.org/) as the compiler:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
- name: Setup Ninja
|
||||||
|
uses: seanmiddleditch/gha-setup-ninja@v5
|
||||||
|
|
||||||
- name: Build Project
|
- name: Build Project
|
||||||
uses: threeal/cmake-action@v2.1.0
|
uses: threeal/cmake-action@v2.0.0
|
||||||
with:
|
with:
|
||||||
generator: Ninja
|
generator: Ninja
|
||||||
cxx-compiler: clang++
|
cxx-compiler: clang++
|
||||||
@ -76,7 +79,7 @@ Use the `options` input to specify additional options for configuring a project:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Build Project
|
- name: Build Project
|
||||||
uses: threeal/cmake-action@v2.1.0
|
uses: threeal/cmake-action@v2.0.0
|
||||||
with:
|
with:
|
||||||
options: |
|
options: |
|
||||||
BUILD_TESTS=ON
|
BUILD_TESTS=ON
|
||||||
@ -91,7 +94,7 @@ By default, this action builds the project after configuration. To skip the buil
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Configure Project
|
- name: Configure Project
|
||||||
uses: threeal/cmake-action@v2.1.0
|
uses: threeal/cmake-action@v2.0.0
|
||||||
with:
|
with:
|
||||||
run-build: false
|
run-build: false
|
||||||
```
|
```
|
||||||
@ -100,4 +103,4 @@ By default, this action builds the project after configuration. To skip the buil
|
|||||||
|
|
||||||
This project is licensed under the terms of the [MIT License](./LICENSE).
|
This project is licensed under the terms of the [MIT License](./LICENSE).
|
||||||
|
|
||||||
Copyright © 2023-2025 [Alfi Maulana](https://github.com/threeal/)
|
Copyright © 2023-2024 [Alfi Maulana](https://github.com/threeal/)
|
||||||
|
|||||||
@ -33,5 +33,5 @@ outputs:
|
|||||||
description: The build directory of the CMake project
|
description: The build directory of the CMake project
|
||||||
value: ${{ steps.process-inputs.outputs.build-dir }}
|
value: ${{ steps.process-inputs.outputs.build-dir }}
|
||||||
runs:
|
runs:
|
||||||
using: node24
|
using: node20
|
||||||
main: dist/action.mjs
|
main: dist/action.mjs
|
||||||
|
|||||||
10
dist/action.mjs
generated
vendored
10
dist/action.mjs
generated
vendored
@ -82,7 +82,7 @@ async function exec(command, args) {
|
|||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
reject(new Error(`Command exited with status code ${code.toString()}`));
|
reject(new Error(`Command exited with status code ${code}`));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -136,7 +136,7 @@ function parse(str) {
|
|||||||
const args = [];
|
const args = [];
|
||||||
let match;
|
let match;
|
||||||
while ((match = regex.exec(str)) !== null) {
|
while ((match = regex.exec(str)) !== null) {
|
||||||
args.push(match[1] || match[2] || match[3] || match[4]);
|
args.push(match[1] ?? match[2] ?? match[3] ?? match[4]);
|
||||||
}
|
}
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ function getContext() {
|
|||||||
}
|
}
|
||||||
input = getInput("options");
|
input = getInput("options");
|
||||||
if (input) {
|
if (input) {
|
||||||
options.push(...parse(input).map((opt) => opt));
|
options.push(...parse(input).map((opt) => opt.toString()));
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
sourceDir,
|
sourceDir,
|
||||||
@ -170,11 +170,11 @@ function getContext() {
|
|||||||
configure: {
|
configure: {
|
||||||
generator: getInput("generator"),
|
generator: getInput("generator"),
|
||||||
options,
|
options,
|
||||||
args: parse(getInput("args")).map((arg) => arg),
|
args: parse(getInput("args")).map((arg) => arg.toString()),
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
enabled: getInput("run-build") == "true",
|
enabled: getInput("run-build") == "true",
|
||||||
args: parse(getInput("build-args")).map((arg) => arg),
|
args: parse(getInput("build-args")).map((arg) => arg.toString()),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
11
eslint.config.js
Normal file
11
eslint.config.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import eslint from "@eslint/js";
|
||||||
|
import tseslint from "typescript-eslint";
|
||||||
|
|
||||||
|
export default [
|
||||||
|
eslint.configs.recommended,
|
||||||
|
...tseslint.configs.recommended,
|
||||||
|
...tseslint.configs.stylistic,
|
||||||
|
{
|
||||||
|
ignores: [".*", "dist"],
|
||||||
|
},
|
||||||
|
];
|
||||||
@ -1,20 +0,0 @@
|
|||||||
import eslint from "@eslint/js";
|
|
||||||
import { defineConfig, globalIgnores } from "eslint/config";
|
|
||||||
import tseslint from "typescript-eslint";
|
|
||||||
|
|
||||||
export default defineConfig(
|
|
||||||
globalIgnores(["dist"]),
|
|
||||||
eslint.configs.recommended,
|
|
||||||
tseslint.configs.strictTypeChecked,
|
|
||||||
tseslint.configs.stylisticTypeChecked,
|
|
||||||
{
|
|
||||||
languageOptions: {
|
|
||||||
parserOptions: {
|
|
||||||
projectService: {
|
|
||||||
allowDefaultProject: ["rollup.config.js"],
|
|
||||||
},
|
|
||||||
tsconfigRootDir: import.meta.dirname,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
20
jest.config.json
Normal file
20
jest.config.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"collectCoverage": true,
|
||||||
|
"coverageReporters": ["text"],
|
||||||
|
"coverageThreshold": {
|
||||||
|
"global": {
|
||||||
|
"branches": 100,
|
||||||
|
"functions": 100,
|
||||||
|
"lines": 100,
|
||||||
|
"statements": 100
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"moduleNameMapper": {
|
||||||
|
"^(\\.{1,2}/.*)\\.js$": "$1"
|
||||||
|
},
|
||||||
|
"preset": "ts-jest/presets/default-esm",
|
||||||
|
"transform": {
|
||||||
|
"^.+\\.ts$": ["ts-jest", { "useESM": true }]
|
||||||
|
},
|
||||||
|
"verbose": true
|
||||||
|
}
|
||||||
@ -1,20 +0,0 @@
|
|||||||
pre-commit:
|
|
||||||
piped: true
|
|
||||||
jobs:
|
|
||||||
- name: install dependencies
|
|
||||||
run: pnpm install
|
|
||||||
|
|
||||||
- name: check types
|
|
||||||
run: pnpm tsc
|
|
||||||
|
|
||||||
- name: fix formatting
|
|
||||||
run: pnpm prettier --write .
|
|
||||||
|
|
||||||
- name: fix lint
|
|
||||||
run: pnpm eslint --fix
|
|
||||||
|
|
||||||
- name: build action
|
|
||||||
run: pnpm rollup -c
|
|
||||||
|
|
||||||
- name: check diff
|
|
||||||
run: git diff --exit-code dist pnpm-lock.yaml {staged_files}
|
|
||||||
37
package.json
37
package.json
@ -3,26 +3,29 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "vitest run"
|
"build": "rollup -c",
|
||||||
|
"format": "prettier --write --cache . !dist !README.md",
|
||||||
|
"lint": "eslint",
|
||||||
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"gha-utils": "^0.4.1"
|
"gha-utils": "^0.4.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.35.0",
|
"@eslint/js": "^9.16.0",
|
||||||
"@rollup/plugin-node-resolve": "^16.0.1",
|
"@jest/globals": "^29.7.0",
|
||||||
"@rollup/plugin-typescript": "^12.1.4",
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
||||||
"@tsconfig/node24": "^24.0.1",
|
"@rollup/plugin-typescript": "^12.1.1",
|
||||||
"@types/node": "^24.3.0",
|
"@types/jest": "^29.5.14",
|
||||||
"@vitest/coverage-v8": "^3.1.4",
|
"@types/node": "^22.10.1",
|
||||||
"eslint": "^9.34.0",
|
"eslint": "^9.16.0",
|
||||||
"jiti": "^2.5.1",
|
"jest": "^29.7.0",
|
||||||
"lefthook": "^1.12.3",
|
"prettier": "^3.4.2",
|
||||||
"prettier": "^3.6.2",
|
"rollup": "^4.28.0",
|
||||||
"prettier-plugin-organize-imports": "^4.2.0",
|
"ts-jest": "^29.2.5",
|
||||||
"rollup": "^4.46.2",
|
"tslib": "^2.8.1",
|
||||||
"typescript": "^5.9.2",
|
"typescript": "^5.7.2",
|
||||||
"typescript-eslint": "^8.42.0",
|
"typescript-eslint": "^8.17.0"
|
||||||
"vitest": "^3.1.4"
|
},
|
||||||
}
|
"packageManager": "yarn@4.5.3"
|
||||||
}
|
}
|
||||||
|
|||||||
2574
pnpm-lock.yaml
2574
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -1,6 +0,0 @@
|
|||||||
packages:
|
|
||||||
- .
|
|
||||||
|
|
||||||
onlyBuiltDependencies:
|
|
||||||
- esbuild
|
|
||||||
- lefthook
|
|
||||||
@ -1,7 +1,5 @@
|
|||||||
import { describe, expect, it, vi } from "vitest";
|
import { jest } from "@jest/globals";
|
||||||
import { buildProject, configureProject } from "./cmake.js";
|
|
||||||
import type { Context } from "./context.js";
|
import type { Context } from "./context.js";
|
||||||
import { exec } from "./exec.js";
|
|
||||||
|
|
||||||
interface TestCase {
|
interface TestCase {
|
||||||
name: string;
|
name: string;
|
||||||
@ -23,7 +21,9 @@ const defaultContext: Context = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
vi.mock("./exec.js", () => ({ exec: vi.fn() }));
|
jest.unstable_mockModule("./exec.js", () => ({
|
||||||
|
exec: jest.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
describe("configure a CMake project", () => {
|
describe("configure a CMake project", () => {
|
||||||
const testCases: TestCase[] = [
|
const testCases: TestCase[] = [
|
||||||
@ -100,7 +100,10 @@ describe("configure a CMake project", () => {
|
|||||||
|
|
||||||
for (const testCase of testCases) {
|
for (const testCase of testCases) {
|
||||||
it(`should execute the correct command ${testCase.name}`, async () => {
|
it(`should execute the correct command ${testCase.name}`, async () => {
|
||||||
vi.mocked(exec).mockReset();
|
const { configureProject } = await import("./cmake.js");
|
||||||
|
const { exec } = await import("./exec.js");
|
||||||
|
|
||||||
|
jest.mocked(exec).mockReset();
|
||||||
|
|
||||||
await configureProject({ ...defaultContext, ...testCase.context });
|
await configureProject({ ...defaultContext, ...testCase.context });
|
||||||
|
|
||||||
@ -141,7 +144,10 @@ describe("build a CMake project", () => {
|
|||||||
|
|
||||||
for (const testCase of testCases) {
|
for (const testCase of testCases) {
|
||||||
it(`should execute the correct command ${testCase.name}`, async () => {
|
it(`should execute the correct command ${testCase.name}`, async () => {
|
||||||
vi.mocked(exec).mockReset();
|
const { buildProject } = await import("./cmake.js");
|
||||||
|
const { exec } = await import("./exec.js");
|
||||||
|
|
||||||
|
jest.mocked(exec).mockReset();
|
||||||
|
|
||||||
await buildProject({ ...defaultContext, ...testCase.context });
|
await buildProject({ ...defaultContext, ...testCase.context });
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import type { Context } from "./context.js";
|
|
||||||
import { exec } from "./exec.js";
|
import { exec } from "./exec.js";
|
||||||
|
import type { Context } from "./context.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the build system for a CMake project.
|
* Configures the build system for a CMake project.
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
|
import { jest } from "@jest/globals";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
|
||||||
import type { Context } from "./context.js";
|
import type { Context } from "./context.js";
|
||||||
|
|
||||||
vi.mock("gha-utils", () => ({ getInput: vi.fn() }));
|
jest.unstable_mockModule("gha-utils", () => ({
|
||||||
|
getInput: jest.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
describe("get action context", () => {
|
describe("get action context", () => {
|
||||||
interface TestCase {
|
interface TestCase {
|
||||||
@ -183,8 +185,10 @@ describe("get action context", () => {
|
|||||||
const { getInput } = await import("gha-utils");
|
const { getInput } = await import("gha-utils");
|
||||||
const { getContext } = await import("./context.js");
|
const { getContext } = await import("./context.js");
|
||||||
|
|
||||||
const inputs = testCase.inputs ?? {};
|
const inputs = testCase.inputs || {};
|
||||||
vi.mocked(getInput).mockImplementation((name) => inputs[name] ?? "");
|
jest.mocked(getInput).mockImplementation((name) => {
|
||||||
|
return inputs[name] || "";
|
||||||
|
});
|
||||||
|
|
||||||
expect(getContext()).toStrictEqual({
|
expect(getContext()).toStrictEqual({
|
||||||
sourceDir: "",
|
sourceDir: "",
|
||||||
|
|||||||
@ -40,7 +40,7 @@ export function getContext(): Context {
|
|||||||
|
|
||||||
input = getInput("options");
|
input = getInput("options");
|
||||||
if (input) {
|
if (input) {
|
||||||
options.push(...parse(input).map((opt) => opt));
|
options.push(...parse(input).map((opt) => opt.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -49,11 +49,11 @@ export function getContext(): Context {
|
|||||||
configure: {
|
configure: {
|
||||||
generator: getInput("generator"),
|
generator: getInput("generator"),
|
||||||
options,
|
options,
|
||||||
args: parse(getInput("args")).map((arg) => arg),
|
args: parse(getInput("args")).map((arg) => arg.toString()),
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
enabled: getInput("run-build") == "true",
|
enabled: getInput("run-build") == "true",
|
||||||
args: parse(getInput("build-args")).map((arg) => arg),
|
args: parse(getInput("build-args")).map((arg) => arg.toString()),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,16 @@
|
|||||||
import { logCommand } from "gha-utils";
|
import { jest } from "@jest/globals";
|
||||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
||||||
import { exec } from "./exec.js";
|
|
||||||
|
|
||||||
describe("execute commands", () => {
|
describe("execute commands", () => {
|
||||||
vi.mock("gha-utils", () => ({
|
const logCommand = jest.fn<(command: string, ...args: string[]) => void>();
|
||||||
logCommand: vi.fn<(command: string, ...args: string[]) => void>(),
|
jest.unstable_mockModule("gha-utils", () => ({ logCommand }));
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.mocked(logCommand).mockClear();
|
logCommand.mockClear();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should successfully execute a command", async () => {
|
it("should successfully execute a command", async () => {
|
||||||
|
const { exec } = await import("./exec.js");
|
||||||
|
|
||||||
await exec("node", ["--version"]);
|
await exec("node", ["--version"]);
|
||||||
|
|
||||||
expect(logCommand).toHaveBeenCalledTimes(1);
|
expect(logCommand).toHaveBeenCalledTimes(1);
|
||||||
@ -19,6 +18,8 @@ describe("execute commands", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should fail to execute a command", async () => {
|
it("should fail to execute a command", async () => {
|
||||||
|
const { exec } = await import("./exec.js");
|
||||||
|
|
||||||
await expect(exec("node", ["--invalid"])).rejects.toThrow(
|
await expect(exec("node", ["--invalid"])).rejects.toThrow(
|
||||||
"Command exited with status code 9",
|
"Command exited with status code 9",
|
||||||
);
|
);
|
||||||
|
|||||||
@ -17,11 +17,11 @@ export async function exec(command: string, args: string[]): Promise<void> {
|
|||||||
});
|
});
|
||||||
logCommand(proc.spawnfile, ...proc.spawnargs.splice(1));
|
logCommand(proc.spawnfile, ...proc.spawnargs.splice(1));
|
||||||
proc.on("error", reject);
|
proc.on("error", reject);
|
||||||
proc.on("close", (code: number) => {
|
proc.on("close", (code) => {
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
resolve();
|
resolve();
|
||||||
} else {
|
} else {
|
||||||
reject(new Error(`Command exited with status code ${code.toString()}`));
|
reject(new Error(`Command exited with status code ${code}`));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -12,7 +12,7 @@ export function parse(str: string): string[] {
|
|||||||
const args: string[] = [];
|
const args: string[] = [];
|
||||||
let match: RegExpExecArray | null;
|
let match: RegExpExecArray | null;
|
||||||
while ((match = regex.exec(str)) !== null) {
|
while ((match = regex.exec(str)) !== null) {
|
||||||
args.push(match[1] || match[2] || match[3] || match[4]);
|
args.push(match[1] ?? match[2] ?? match[3] ?? match[4]);
|
||||||
}
|
}
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,13 @@
|
|||||||
{
|
{
|
||||||
"extends": "@tsconfig/node24",
|
"include": ["src"],
|
||||||
|
"exclude": ["**/*.test.ts"],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"exactOptionalPropertyTypes": true,
|
||||||
|
"strict": true,
|
||||||
"module": "node16",
|
"module": "node16",
|
||||||
"noEmit": true
|
"moduleResolution": "node16",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"target": "es2022",
|
||||||
|
"skipLibCheck": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +0,0 @@
|
|||||||
import { defineConfig } from "vitest/config";
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
test: {
|
|
||||||
coverage: {
|
|
||||||
all: false,
|
|
||||||
enabled: true,
|
|
||||||
reporter: ["text"],
|
|
||||||
thresholds: { 100: true },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
Loading…
Reference in New Issue
Block a user