Skip to content

intuitive action exit code #7

Closed
@2bndy5

Description

@2bndy5

As it is currently, the action current exits with a successful code (0) even when the run_check.sh finds problems given by clang-tidy or clang-format.

Solution

toward the end of the script, add

EXIT_CODE=0
if [ "$PAYLOAD_FORMAT" != "" && "$PAYLOAD_TIDY" != "" ]
then
  EXIT_CODE=1
fi
exit($EXIT_CODE)

Counter-argument

If the intention is to allow PRs to merge errors (ignore the warning from clang-*), then the user's workflow could handle the exit code instead of hard-coding it in the run_checks.sh. This option would require a output from this action:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: shenxianpeng/cpp-linter-action@master
        id: linter
        with:
          style: file
          extensions: 'cpp'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      # If there are any comments, fail the check
      - if: steps.linter.outputs.checks-failed > 0
        run: exit 1

This would simply require a change to the above bash script suggestion

EXIT_CODE=0
if [ "$PAYLOAD_FORMAT" != "" && "$PAYLOAD_TIDY" != "" ]
then
  EXIT_CODE=1
fi
# exit($EXIT_CODE) # let action exit successfully

# set the action's `checks-failed` output
echo "::set-output name=checks-failed::$(echo $EXIT_CODE)"

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions