Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add wrapper to tflint to expose stdout, stderr, and exitcode #1

Merged
merged 15 commits into from
Jun 8, 2023
19 changes: 18 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,20 @@ 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
run: tflint -f compact --force
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,20 @@ Used to authenticate requests to the GitHub API to obtain release data from the

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

### `tflint_wrapper_enabled`

If true, installs a wrapper script to wrap susbsequent calls of the `tflint` binary and expose its STDOUT, STDERR, and exit code as outputs.

Default: `"false"`

## Outputs

The action does not have any output.
This action does not configure any outputs directly. However, when you set the `tflint_wrapper_enabled` input
to `true`, the following outputs are available for subsequent steps that call the `tflint` binary:

- `stdout` - The STDOUT stream of the call to the `tflint` binary.
- `stderr` - The STDERR stream of the call to the `tflint` binary.
- `exitcode` - The exit code of the call to the `tflint` binary.

## Usage

Expand Down Expand Up @@ -98,6 +109,20 @@ or specify it explicitly as
- run: tflint -f compact
```

### Enabling the TFlint Wrapper
```yaml
- uses: terraform-linters/setup-tflint@v3
with:
tflint_wrapper_enabled: 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
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ inputs:
description: GitHub token - used when getting the latest version of tflint
required: false
default: ${{ github.token }}
tflint_wrapper_enabled:
description: 'Whether or not to install a wrapper to wrap subsequent calls of the `tflint` binary and expose its STDOUT, STDERR, and exit code as outputs named `stdout`, `stderr`, and `exitcode` respectively. Defaults to `false`.'
default: 'false'
required: false
runs:
using: 'node16'
main: 'dist/index.js'
Expand Down
Loading