cloudposse / cloudposse/github-action-matrix-extended

JQ fails when affected stacks is empty

Open
#9 4 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
No language data
Stars
10
Forks
2
Avg merge
1h 57m
Merged PRs (30d)
2

Description

## Describe the Bug
When updating our atmos repo, if we do not touch any component, catalog or stack files JQ fails to correctly parse the output.

```
jq: error: syntax error, unexpected ';' (Unix shell quoting issues?) at , line 1:
def name: ;
jq: 1 compile error
Error: The process '/usr/bin/jq' failed with exit code 3
```

When I run atmos locally the output is `[]` as expected

```
➜ affected=$(jq -c '.' affected-stacks.json)

➜ echo $affected
[]
➜ echo $affected | jq
[]
```

we are running `cloudposse/github-action-atmos-affected-stacks@v3` which calls this action

## Expected Behavior
`cloudposse/github-action-atmos-affected-stacks@v3` runs successfully and returns an empty set so
`if: ${{ needs.context.outputs.has-affected-stacks == 'true' }}` returns false correct and doesn't run more jobs based on the matrix.

## Steps to Reproduce

```
name: "terraform plan matrix"

permissions:
id-token: write
contents: read
pull-requests: write

on:
pull_request:
types: [opened, synchronize, reopened]

env:
ATMOS_LOGS_LEVEL: Off

jobs:
context:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- id: affected
uses: cloudposse/github-action-atmos-affected-stacks@v3
with:
nested-matrices-count: 1

outputs:
affected: ${{ steps.affected.outputs.affected }}
has-affected-stacks: ${{ steps.affected.outputs.has-affected-stacks }}
matrix: ${{ steps.affected.outputs.matrix }}
```

## Screenshots
![image](https://github.com/cloudposse/github-action-matrix-extended/assets/86862761/37fc2563-caad-41a4-95d2-a20e1ae7c603)

![image](https://github.com/cloudposse/github-action-matrix-extended/assets/86862761/4d029996-1ae8-45e7-9968-e5152e33fa53)

## Environment (please complete the following information):

Github actions runner `ubuntu-latest`

## Additional Context
Add any other context about the problem here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.