Skip to content

JQ fails when affected stacks is empty #9

Description

@brett-au

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 <top-level>, 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

image

Environment (please complete the following information):

Github actions runner ubuntu-latest

Additional Context

Add any other context about the problem here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug🐛 An issue with the system

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions