Skip to content

Commit

Permalink
add wrapper to expose stdout, stderr, and exitcode
Browse files Browse the repository at this point in the history
Closes #173
  • Loading branch information
dreinhardt89 authored and bendrucker committed Jun 23, 2023
1 parent 07d1d6c commit dfc4d18
Show file tree
Hide file tree
Showing 13 changed files with 4,565 additions and 94 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

integration:
name: Integration test

strategy:
matrix:
os:
Expand Down Expand Up @@ -98,3 +98,29 @@ jobs:
tflint_version: ${{ matrix.tflint_version }}
- name: Run
run: tflint -f compact --force

integration-wrapper:
name: 'Integration test (tflint_version: ${{ matrix.tflint_version }})'
runs-on: ubuntu-latest
strategy:
matrix:
tflint_version: [ 'v0.26.0', latest ]

steps:
- uses: actions/checkout@v3
- name: Use Action
uses: ./
with:
tflint_version: ${{ matrix.tflint_version }}
tflint_wrapper: true
- name: Run
id: tflint
run: tflint -f compact --force
- name: Verify Exit Code Output
run: |
if [[ ${{ steps.tflint.outputs.exitcode }} -ne 0 ]]; then
echo "TFLint Exit Code not captured."
exit 1
else
echo "TFLint Exit Code captured."
fi
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,6 @@ typings/
# next.js build output
.next

# ./wrapper/dist gets included in top-level ./dist
wrapper/dist

27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,19 @@ Used to authenticate requests to the GitHub API to obtain release data from the

Default: `${{ github.token }}`

### `tflint_wrapper`

Installs a wrapper script to wrap subsequent calls to `tflint` and expose `stdout`, `stderr`, and `exitcode` outputs.

Default: `"false"`

## Outputs

The action does not have any output.
The following outputs are available when the `tflint_wrapper` input is enabled:

- `stdout` - The output (stdout) produced by the tflint command.
- `stderr` - The error output (stdout) produced by the tflint command.
- `exitcode` - The exit code produced by the tflint command.

## Usage

Expand Down Expand Up @@ -98,6 +108,21 @@ or specify it explicitly as
- run: tflint -f compact
```
### Wrapper
```yaml
- uses: terraform-linters/setup-tflint@v3
with:
tflint_wrapper: true

- id: tflint
run: tflint -f compact

- run: echo ${{ steps.tflint.outputs.stdout }}
- run: echo ${{ steps.tflint.outputs.stderr }}
- run: echo ${{ steps.tflint.outputs.exitcode }}
```
### Checks
This action supports [Problem Matchers](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md) for `--format compact`. You can see annotations in pull requests when TFLint prints issues with the `compact` format.
Expand Down
11 changes: 11 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ inputs:
description: GitHub token - used when getting the latest version of tflint
required: false
default: ${{ github.token }}
tflint_wrapper:
description: Installs a wrapper script to wrap subsequent calls to `tflint` and expose `stdout`, `stderr`, and `exitcode` outputs
default: 'false'
required: false
outputs:
stdout:
description: The output (stdout) produced by the tflint command. Only available if `tflint_wrapper` is set to `true`.
stderr:
description: The error output (stderr) produced by the tflint command. Only available if `tflint_wrapper` is set to `true`.
exitcode:
description: The exit code produced by the tflint command. Only available if `tflint_wrapper` is set to `true`.
runs:
using: 'node16'
main: 'dist/index.js'
Expand Down
Loading

0 comments on commit dfc4d18

Please sign in to comment.