mirror of
				https://github.com/threeal/cmake-action.git
				synced 2025-11-04 05:43:42 +00:00 
			
		
		
		
	feat: remove run-test and test-args action inputs
				
					
				
			This commit is contained in:
		
							parent
							
								
									b1c63dc900
								
							
						
					
					
						commit
						aa21b94da4
					
				
							
								
								
									
										24
									
								
								.github/workflows/test.yaml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										24
									
								
								.github/workflows/test.yaml
									
									
									
									
										vendored
									
									
								
							@ -141,26 +141,6 @@ jobs:
 | 
				
			|||||||
      - name: Test Project
 | 
					      - name: Test Project
 | 
				
			||||||
        run: ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R test
 | 
					        run: ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  test-action-with-run-test:
 | 
					 | 
				
			||||||
    name: Test Action With Run Test
 | 
					 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					 | 
				
			||||||
    steps:
 | 
					 | 
				
			||||||
      - name: Checkout
 | 
					 | 
				
			||||||
        uses: actions/checkout@v4.1.2
 | 
					 | 
				
			||||||
        with:
 | 
					 | 
				
			||||||
          sparse-checkout: |
 | 
					 | 
				
			||||||
            action.yml
 | 
					 | 
				
			||||||
            dist
 | 
					 | 
				
			||||||
            test
 | 
					 | 
				
			||||||
          sparse-checkout-cone-mode: false
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      - name: Configure, Build, and Test Project
 | 
					 | 
				
			||||||
        uses: ./
 | 
					 | 
				
			||||||
        with:
 | 
					 | 
				
			||||||
          source-dir: test
 | 
					 | 
				
			||||||
          run-test: true
 | 
					 | 
				
			||||||
          test-args: -R hello_world
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  test-action-with-additional-args:
 | 
					  test-action-with-additional-args:
 | 
				
			||||||
    name: Test Action With Additional Arguments
 | 
					    name: Test Action With Additional Arguments
 | 
				
			||||||
    runs-on: ${{ matrix.compiler == 'msvc' && 'windows' || 'ubuntu' }}-latest
 | 
					    runs-on: ${{ matrix.compiler == 'msvc' && 'windows' || 'ubuntu' }}-latest
 | 
				
			||||||
@ -187,8 +167,6 @@ jobs:
 | 
				
			|||||||
          options: CHECK_SURPASS_WARNING=ON
 | 
					          options: CHECK_SURPASS_WARNING=ON
 | 
				
			||||||
          run-build: true
 | 
					          run-build: true
 | 
				
			||||||
          build-args: --target test_c --target test_cpp
 | 
					          build-args: --target test_c --target test_cpp
 | 
				
			||||||
          run-test: true
 | 
					 | 
				
			||||||
          test-args: -R test ${{ matrix.compiler == 'msvc' && '-C Debug' || '' }}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  test-action-with-custom-tools:
 | 
					  test-action-with-custom-tools:
 | 
				
			||||||
    name: Test Action With Custom Tools
 | 
					    name: Test Action With Custom Tools
 | 
				
			||||||
@ -217,5 +195,3 @@ jobs:
 | 
				
			|||||||
          options: CHECK_USING_CLANG=ON
 | 
					          options: CHECK_USING_CLANG=ON
 | 
				
			||||||
          run-build: true
 | 
					          run-build: true
 | 
				
			||||||
          build-args: --target test_c --target test_cpp
 | 
					          build-args: --target test_c --target test_cpp
 | 
				
			||||||
          run-test: true
 | 
					 | 
				
			||||||
          test-args: -R test
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -29,8 +29,6 @@ For more information, refer to [action.yml](./action.yml) and the [GitHub Action
 | 
				
			|||||||
| `args` | Multiple strings | Additional arguments to pass during the CMake configuration. |
 | 
					| `args` | Multiple strings | Additional arguments to pass during the CMake configuration. |
 | 
				
			||||||
| `run-build` | `true` or `false` | If enabled, it builds the project using CMake. It defaults to `false`. |
 | 
					| `run-build` | `true` or `false` | If enabled, it builds the project using CMake. It defaults to `false`. |
 | 
				
			||||||
| `build-args` | Multiple strings | Additional arguments to pass during the CMake build. |
 | 
					| `build-args` | Multiple strings | Additional arguments to pass during the CMake build. |
 | 
				
			||||||
| `run-test` | `true` or `false` | If enabled, it runs testing using [CTest](https://cmake.org/cmake/help/latest/manual/ctest.1.html). It defaults to `false`. |
 | 
					 | 
				
			||||||
| `test-args` | Multiple strings | Additional arguments to pass during the CTest run. |
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
> **Note**: Multiple strings mean that the input can be specified with more than one value. Separate each value with a space or a new line.
 | 
					> **Note**: Multiple strings mean that the input can be specified with more than one value. Separate each value with a space or a new line.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -61,21 +59,17 @@ jobs:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      - name: Build Project
 | 
					      - name: Build Project
 | 
				
			||||||
        runs: cmake --build build
 | 
					        runs: cmake --build build
 | 
				
			||||||
 | 
					 | 
				
			||||||
      - name: Test Project
 | 
					 | 
				
			||||||
        runs: ctest --test-dir build
 | 
					 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
> **Note**: You can replace [`v1.3.0`](https://github.com/threeal/cmake-action/releases/tag/v1.3.0) with any version you prefer. See [this](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsuses).
 | 
					> **Note**: You can replace [`v1.3.0`](https://github.com/threeal/cmake-action/releases/tag/v1.3.0) with any version you prefer. See [this](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsuses).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#### Configure, Build, and Test in the Same Step
 | 
					#### Configure and Build in the Same Step
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```yaml
 | 
					```yaml
 | 
				
			||||||
- name: Configure, Build, and Test Project
 | 
					- name: Configure, Build, and Test Project
 | 
				
			||||||
  uses: threeal/cmake-action@v1.3.0
 | 
					  uses: threeal/cmake-action@v1.3.0
 | 
				
			||||||
  with:
 | 
					  with:
 | 
				
			||||||
    run-build: true
 | 
					    run-build: true
 | 
				
			||||||
    run-test: true
 | 
					 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#### Specify the Source and Build Directories
 | 
					#### Specify the Source and Build Directories
 | 
				
			||||||
 | 
				
			|||||||
@ -28,11 +28,6 @@ inputs:
 | 
				
			|||||||
    default: false
 | 
					    default: false
 | 
				
			||||||
  build-args:
 | 
					  build-args:
 | 
				
			||||||
    description: Additional arguments to pass during the CMake build
 | 
					    description: Additional arguments to pass during the CMake build
 | 
				
			||||||
  run-test:
 | 
					 | 
				
			||||||
    description: If enabled, it runs testing using CTest (true/false)
 | 
					 | 
				
			||||||
    default: false
 | 
					 | 
				
			||||||
  test-args:
 | 
					 | 
				
			||||||
    description: Additional arguments to pass during the CTest run
 | 
					 | 
				
			||||||
outputs:
 | 
					outputs:
 | 
				
			||||||
  build-dir:
 | 
					  build-dir:
 | 
				
			||||||
    description: The build directory of the CMake project
 | 
					    description: The build directory of the CMake project
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										13
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										13
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							@ -27715,8 +27715,6 @@ function getInputs() {
 | 
				
			|||||||
        args: (0,core.getMultilineInput)("args").flatMap((args) => args.split(" ")),
 | 
					        args: (0,core.getMultilineInput)("args").flatMap((args) => args.split(" ")),
 | 
				
			||||||
        runBuild: (0,core.getBooleanInput)("run-build"),
 | 
					        runBuild: (0,core.getBooleanInput)("run-build"),
 | 
				
			||||||
        buildArgs: (0,core.getMultilineInput)("build-args").flatMap((args) => args.split(" ")),
 | 
					        buildArgs: (0,core.getMultilineInput)("build-args").flatMap((args) => args.split(" ")),
 | 
				
			||||||
        testArgs: (0,core.getMultilineInput)("test-args").flatMap((args) => args.split(" ")),
 | 
					 | 
				
			||||||
        runTest: (0,core.getBooleanInput)("run-test"),
 | 
					 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -27760,18 +27758,9 @@ async function main() {
 | 
				
			|||||||
    configureArgs.push(...inputs.args);
 | 
					    configureArgs.push(...inputs.args);
 | 
				
			||||||
    await (0,exec.exec)("cmake", configureArgs);
 | 
					    await (0,exec.exec)("cmake", configureArgs);
 | 
				
			||||||
    core.setOutput("build-dir", inputs.buildDir);
 | 
					    core.setOutput("build-dir", inputs.buildDir);
 | 
				
			||||||
    if (inputs.runBuild || inputs.runTest) {
 | 
					    if (inputs.runBuild) {
 | 
				
			||||||
        await (0,exec.exec)("cmake", ["--build", inputs.buildDir, ...inputs.buildArgs]);
 | 
					        await (0,exec.exec)("cmake", ["--build", inputs.buildDir, ...inputs.buildArgs]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (inputs.runTest) {
 | 
					 | 
				
			||||||
        await (0,exec.exec)("ctest", [
 | 
					 | 
				
			||||||
            "--test-dir",
 | 
					 | 
				
			||||||
            inputs.buildDir,
 | 
					 | 
				
			||||||
            "--output-on-failure",
 | 
					 | 
				
			||||||
            "--no-tests=error",
 | 
					 | 
				
			||||||
            ...inputs.testArgs,
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
main().catch((err) => core.setFailed(err));
 | 
					main().catch((err) => core.setFailed(err));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										12
									
								
								src/index.ts
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/index.ts
									
									
									
									
									
								
							@ -48,19 +48,9 @@ async function main() {
 | 
				
			|||||||
  await exec("cmake", configureArgs);
 | 
					  await exec("cmake", configureArgs);
 | 
				
			||||||
  core.setOutput("build-dir", inputs.buildDir);
 | 
					  core.setOutput("build-dir", inputs.buildDir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (inputs.runBuild || inputs.runTest) {
 | 
					  if (inputs.runBuild) {
 | 
				
			||||||
    await exec("cmake", ["--build", inputs.buildDir, ...inputs.buildArgs]);
 | 
					    await exec("cmake", ["--build", inputs.buildDir, ...inputs.buildArgs]);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (inputs.runTest) {
 | 
					 | 
				
			||||||
    await exec("ctest", [
 | 
					 | 
				
			||||||
      "--test-dir",
 | 
					 | 
				
			||||||
      inputs.buildDir,
 | 
					 | 
				
			||||||
      "--output-on-failure",
 | 
					 | 
				
			||||||
      "--no-tests=error",
 | 
					 | 
				
			||||||
      ...inputs.testArgs,
 | 
					 | 
				
			||||||
    ]);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
main().catch((err) => core.setFailed(err));
 | 
					main().catch((err) => core.setFailed(err));
 | 
				
			||||||
 | 
				
			|||||||
@ -35,8 +35,6 @@ describe("get action inputs", () => {
 | 
				
			|||||||
        args: [],
 | 
					        args: [],
 | 
				
			||||||
        runBuild: false,
 | 
					        runBuild: false,
 | 
				
			||||||
        buildArgs: [],
 | 
					        buildArgs: [],
 | 
				
			||||||
        runTest: false,
 | 
					 | 
				
			||||||
        testArgs: [],
 | 
					 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
@ -51,8 +49,6 @@ describe("get action inputs", () => {
 | 
				
			|||||||
        switch (name) {
 | 
					        switch (name) {
 | 
				
			||||||
          case "run-build":
 | 
					          case "run-build":
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
          case "run-test":
 | 
					 | 
				
			||||||
            return true;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        throw new Error(`invalid input name: ${name}`);
 | 
					        throw new Error(`invalid input name: ${name}`);
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
@ -88,8 +84,6 @@ describe("get action inputs", () => {
 | 
				
			|||||||
              "some-build-args another-build-args",
 | 
					              "some-build-args another-build-args",
 | 
				
			||||||
              "some-other-build-args",
 | 
					              "some-other-build-args",
 | 
				
			||||||
            ];
 | 
					            ];
 | 
				
			||||||
          case "test-args":
 | 
					 | 
				
			||||||
            return ["some-test-args another-test-args", "some-other-test-args"];
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        throw new Error(`invalid input name: ${name}`);
 | 
					        throw new Error(`invalid input name: ${name}`);
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
@ -116,12 +110,6 @@ describe("get action inputs", () => {
 | 
				
			|||||||
          "another-build-args",
 | 
					          "another-build-args",
 | 
				
			||||||
          "some-other-build-args",
 | 
					          "some-other-build-args",
 | 
				
			||||||
        ],
 | 
					        ],
 | 
				
			||||||
        runTest: true,
 | 
					 | 
				
			||||||
        testArgs: [
 | 
					 | 
				
			||||||
          "some-test-args",
 | 
					 | 
				
			||||||
          "another-test-args",
 | 
					 | 
				
			||||||
          "some-other-test-args",
 | 
					 | 
				
			||||||
        ],
 | 
					 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
				
			|||||||
@ -12,8 +12,6 @@ export interface Inputs {
 | 
				
			|||||||
  args: string[];
 | 
					  args: string[];
 | 
				
			||||||
  runBuild: boolean;
 | 
					  runBuild: boolean;
 | 
				
			||||||
  buildArgs: string[];
 | 
					  buildArgs: string[];
 | 
				
			||||||
  runTest: boolean;
 | 
					 | 
				
			||||||
  testArgs: string[];
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function getInputs(): Inputs {
 | 
					export function getInputs(): Inputs {
 | 
				
			||||||
@ -31,7 +29,5 @@ export function getInputs(): Inputs {
 | 
				
			|||||||
    buildArgs: getMultilineInput("build-args").flatMap((args) =>
 | 
					    buildArgs: getMultilineInput("build-args").flatMap((args) =>
 | 
				
			||||||
      args.split(" "),
 | 
					      args.split(" "),
 | 
				
			||||||
    ),
 | 
					    ),
 | 
				
			||||||
    testArgs: getMultilineInput("test-args").flatMap((args) => args.split(" ")),
 | 
					 | 
				
			||||||
    runTest: getBooleanInput("run-test"),
 | 
					 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user