Skip to content

Commit dfc4d18

Browse files
dreinhardt89bendrucker
authored andcommitted
add wrapper to expose stdout, stderr, and exitcode
Closes #173
1 parent 07d1d6c commit dfc4d18

File tree

13 files changed

+4565
-94
lines changed

13 files changed

+4565
-94
lines changed

.github/workflows/test.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545

4646
integration:
4747
name: Integration test
48-
48+
4949
strategy:
5050
matrix:
5151
os:
@@ -98,3 +98,29 @@ jobs:
9898
tflint_version: ${{ matrix.tflint_version }}
9999
- name: Run
100100
run: tflint -f compact --force
101+
102+
integration-wrapper:
103+
name: 'Integration test (tflint_version: ${{ matrix.tflint_version }})'
104+
runs-on: ubuntu-latest
105+
strategy:
106+
matrix:
107+
tflint_version: [ 'v0.26.0', latest ]
108+
109+
steps:
110+
- uses: actions/checkout@v3
111+
- name: Use Action
112+
uses: ./
113+
with:
114+
tflint_version: ${{ matrix.tflint_version }}
115+
tflint_wrapper: true
116+
- name: Run
117+
id: tflint
118+
run: tflint -f compact --force
119+
- name: Verify Exit Code Output
120+
run: |
121+
if [[ ${{ steps.tflint.outputs.exitcode }} -ne 0 ]]; then
122+
echo "TFLint Exit Code not captured."
123+
exit 1
124+
else
125+
echo "TFLint Exit Code captured."
126+
fi

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,6 @@ typings/
6666
# next.js build output
6767
.next
6868

69+
# ./wrapper/dist gets included in top-level ./dist
70+
wrapper/dist
71+

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,19 @@ Used to authenticate requests to the GitHub API to obtain release data from the
1919

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

22+
### `tflint_wrapper`
23+
24+
Installs a wrapper script to wrap subsequent calls to `tflint` and expose `stdout`, `stderr`, and `exitcode` outputs.
25+
26+
Default: `"false"`
27+
2228
## Outputs
2329

24-
The action does not have any output.
30+
The following outputs are available when the `tflint_wrapper` input is enabled:
31+
32+
- `stdout` - The output (stdout) produced by the tflint command.
33+
- `stderr` - The error output (stdout) produced by the tflint command.
34+
- `exitcode` - The exit code produced by the tflint command.
2535

2636
## Usage
2737

@@ -98,6 +108,21 @@ or specify it explicitly as
98108
- run: tflint -f compact
99109
```
100110
111+
### Wrapper
112+
113+
```yaml
114+
- uses: terraform-linters/setup-tflint@v3
115+
with:
116+
tflint_wrapper: true
117+
118+
- id: tflint
119+
run: tflint -f compact
120+
121+
- run: echo ${{ steps.tflint.outputs.stdout }}
122+
- run: echo ${{ steps.tflint.outputs.stderr }}
123+
- run: echo ${{ steps.tflint.outputs.exitcode }}
124+
```
125+
101126
### Checks
102127
103128
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.

action.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ inputs:
99
description: GitHub token - used when getting the latest version of tflint
1010
required: false
1111
default: ${{ github.token }}
12+
tflint_wrapper:
13+
description: Installs a wrapper script to wrap subsequent calls to `tflint` and expose `stdout`, `stderr`, and `exitcode` outputs
14+
default: 'false'
15+
required: false
16+
outputs:
17+
stdout:
18+
description: The output (stdout) produced by the tflint command. Only available if `tflint_wrapper` is set to `true`.
19+
stderr:
20+
description: The error output (stderr) produced by the tflint command. Only available if `tflint_wrapper` is set to `true`.
21+
exitcode:
22+
description: The exit code produced by the tflint command. Only available if `tflint_wrapper` is set to `true`.
1223
runs:
1324
using: 'node16'
1425
main: 'dist/index.js'

0 commit comments

Comments
 (0)