It does not work when using jobs with matrix #394
-
Describe the bugI have some jobs with matrix strategy, and when I try to do a plan this fails with the following error: I was debugging and I think the error happens due to this line is not getting a result, making job_id is empty: Line 107 in 1e60ee1 So then the actual error happens in this line because job_id is empty: Line 112 in 1e60ee1 My matrix definitions is something like for example: I see this line creates something like "value1, value2, value" in the matrix variable Line 106 in 1e60ee1 but I think the problem is then it tries to filter the workflow json with that string "value1, value2, value3", but looking at the workflow json generated with gh api, that job does not have that information in the json, so it does not find anything, retuning an empty result. To ReproduceDefine a job with matrix strategy with more than 1 value, and then run a plan and it will fail. Expected behaviorBe able to run terraform plan with matrix. ScreenshotsAdditional context |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 1 reply
-
Hey @csaavedravanta, thanks for taking the time to dig through the code and raising such a detailed issue: the gold standard for feedback (especially since you recently joined GitHub)! I was under the impression that handling of matrix-strategy was nipped in the bud a long while back, including multiple matrix arrays. In fact, I checked with the CI tests of this very project/repository to confirm as much: notice the With that said, to the best of you ability, could I request you to share obfuscated snippets of your GH Action workflow? Specifically, the |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Fantastic, thanks for sharing @csaavedravanta, that gives me a solid lead! Just to humour me, would you mind deleting the following name: terraform (${{ matrix.aws_region }} ${{ matrix.environment }}) |
Beta Was this translation helpful? Give feedback.
-
Oh yeah, removing the custom name the job name is the same as the script intent to find it and now it can find it and works ok.
"value1, , value3" So a question, if I want to use TF-via-PR for matrix, the job cannot have a custom name? or is there a workaround or fix coming? |
Beta Was this translation helpful? Give feedback.
-
Great Q, so there's a few takeaways here:
TF-via-PR's current behaviour is a workaround in order to make it work with most scenarios. At best, a new "job-name" input could be introduced to allow users to specify their unconventional job-naming… which is far from ideal. Edit: For your particular use-case, the following custom name: terraform (${{ matrix.aws_region }}, ${{ matrix.aws_account_id }}, ${{ matrix.environment }}) Where:
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the response,
as you can see here, the second item of the matrix has another field somefield1d which is not in the first item and also does not have the somefield1b.
Thank you for the support. |
Beta Was this translation helpful? Give feedback.
-
Ah shoot, that's a tough nut to crack.
Smart thinking! I know some workarounds can be frustrating, but you've done well to manage it smoothly.
Thank you for sharing your feedback—super valuable to hear how others use this Action. On that note, I had a few questions:
|
Beta Was this translation helpful? Give feedback.
Great Q, so there's a few takeaways here:
🟢 Great to hear the default configuration worked for most cases!
🟢 The handling of empty matrix value(s) can be addressed by the workaround "Edit" below.
🔴 Unfortunately, the source of the problem is upstream: specifically with GitHub API discussed here and there.
name:
attribute and matrix strategy.TF-via-PR's current behaviour is a workaround in order to make it work with most scenarios. At best, a new "job-name" input could be in…