Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
  • Loading branch information
yashi committed Jun 9, 2024
0 parents commit d6b2fad
Show file tree
Hide file tree
Showing 2 changed files with 211 additions and 0 deletions.
125 changes: 125 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#+title: Run cpptestcli from Parasoft C/C++test

This action runs =cpptestcli= from Parasoft C/C++test Professional.

Parasoft already provides an official GitHub Action,
[[https://github.com/parasoft/run-cpptest-action][run-cpptest-action]]. If you prefer the official one, please visit their
repository.

=action-cpptestcli= aims not to interfere with =cpptestcli=. It
behaves just as =cpptestcli= does. For example, if you specify a
=.bdf=, it creates projects from the =.bdf=. If you specify =config=,
it will generate a report.

One difference from =cpptestcli= is that it always passes =-data=. The
default value for =-data= is =workspace=. This is because, unlike
desktop usage, =action-cpptestcli= is used for CI, and users don't
want to interact with =~/parasoft/workspace/=. Instead, it should use
a temporary workspace for CI.

Another difference is that =-report= is also always passed. The
default value for =-report= is =report=. The report is generated under
the =report/= directory.

* Basic usage
#+begin_src yaml
- name: Run cpptestcli
uses: spacecubics/action-cpptestcli@v1
with:
settings: local.conf
bdf: cpptestscan.bdf
config: builtin://Recommended Rules
#+end_src

This will run =cpptestcli= in the current working directory, create
=workspace/=, apply =./local.conf=, loads and generates projects
from =./cpptestscan.bdf= in the workspace, then generate a report
using the build in "Recommended Rules" under =report/= directory.

* Scenarios

** cpptestcli is not in PATH
#+begin_src yaml
- name: Run cpptestcli
uses: spacecubics/action-cpptestcli@v1
with:
settings: local.conf
bdf: cpptestscan.bdf
config: builtin://Recommended Rules
install-dir: /opt/tools/cpptest-2023.2.0
#+end_src

If you don't have =cpptestcli=, you can specify ~install-dir~.

** Different workspace directory
#+begin_src yaml
- name: Run cpptestcli
uses: spacecubics/action-cpptestcli@v1
with:
settings: local.conf
bdf: cpptestscan.bdf
config: builtin://Recommended Rules
data: myworkspace
#+end_src

** Different report directory
#+begin_src yaml
- name: Run cpptestcli
uses: spacecubics/action-cpptestcli@v1
with:
settings: local.conf
bdf: cpptestscan.bdf
config: builtin://Recommended Rules
report: myreport
#+end_src

** Create projects from a .bdf file but not generate report
#+begin_src yaml
- name: Run cpptestcli
uses: spacecubics/action-cpptestcli@v1
with:
settings: local.conf
bdf: cpptestscan.bdf
#+end_src

** Resource to use within the workspace
#+begin_src yaml
- name: Run cpptestcli
uses: spacecubics/action-cpptestcli@v1
with:
settings: local.conf
bdf: cpptestscan.bdf
config: builtin://Recommended Rules
resource: myproject
#+end_src

** Generate report from already populated workspace
#+begin_src yaml
- name: Run cpptestcli
uses: spacecubics/action-cpptestcli@v1
with:
settings: local.conf
config: builtin://Recommended Rules
#+end_src

** Run cpptestcli in a different directory
#+begin_src yaml
- name: Run cpptestcli
uses: spacecubics/action-cpptestcli@v1
with:
settings: local.conf
bdf: cpptestscan.bdf
config: builtin://Recommended Rules
working-directory: builddir
#+end_src

** Specify multiple configuraion files
#+begin_src yaml
- name: Run cpptestcli
uses: spacecubics/action-cpptestcli@v1
with:
settings: local.conf:license.conf
bdf: cpptestscan.bdf
config: builtin://Recommended Rules
working-directory: builddir
#+end_src
86 changes: 86 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Copyright 2024 Space Cubics, LLC.
# SPDX-License-Identifier: Apache-2.0

name: Run cpptestcli
description: Run cpptestcli from Parasoft C/C++test Professional

inputs:
data:
description: workspace to use
required: false
default: workspace

config:
description: configuration URL
required: false

bdf:
description: build data file (.bdf)
required: false

resource:
description: resource path within workspace to add to the test scope
required: false

report:
description: report directory
required: false
default: report

settings:
description: Custom configuration files
required: false

install-dir:
description: Install directory when cpptestcli is not found in $PATH
required: false

working-directory:
description: Working directory to run on
required: false

runs:
using: "composite"
steps:

- name: Find cpptestcli
shell: bash
run: |
if [[ -n "${{ inputs.install-dir }}" ]]; then
if test -x "${{ inputs.install-dir }}/cpptestcli" ; then
echo "Executable found: ${{ inputs.install-dir }}/cpptestcli"
echo "CPPTESTCLI=${{ inputs.install-dir }}/cpptestcli" >> $GITHUB_ENV
else
echo "install-dir is set but ${{ inputs.install-dir }}/cpptestcli does not exist or isn't executable"
exit 1
fi
else
if command -v cpptestcli ; then
echo "Executable found in PATH: $(command -v cpptestcli)"
echo "CPPTESTCLI=$(command -v cpptestcli)" >> $GITHUB_ENV
else
echo "install-dir is not set and cpptestcli is not in $PATH"
exit 1
fi
fi
- name: Run cpptestcli
shell: bash
run: |
cmd=("$CPPTESTCLI")
cmd+=(-data "${{ inputs.data }}")
[[ -n "${{ inputs.config }}" ]] && cmd+=(-config "${{ inputs.config }}")
[[ -n "${{ inputs.report }}" ]] && cmd+=(-report "${{ inputs.report }}")
[[ -n "${{ inputs.bdf }}" ]] && cmd+=(-bdf "${{ inputs.bdf }}")
IFS=":"
SETTINGS="${{ inputs.settings }}"
for setting in $SETTINGS; do
cmd+=(-settings "$setting")
done
if [[ -n "${{ inputs.working-directory }}" ]]; then
cd "${{ inputs.working-directory }}"
fi
"${cmd[@]}"

0 comments on commit d6b2fad

Please sign in to comment.