question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Excluding struct from matrix doesn't work

See original GitHub issue

Describe the bug I have a workflow like this:

jobs:
  deploy:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        attr1:
          - key1: val1
            key2: val2
          - key1: val3
            key2: val4
        attr2:
          - key1: val5
            key2: val6
            key3: val7
          - key1: val8
            key2: val9
            key3: val10
    steps:
      - run: |
          echo ${{ matrix.attr1.key1 }}
          echo ${{ matrix.attr1.key2 }}
          echo ${{ matrix.attr2.key1 }}
          echo ${{ matrix.attr2.key2 }}
          echo ${{ matrix.attr2.key3 }}

That is to say, there are two attributes attr1 and attr2 (can be more in practice) in the matrix, with each one using “structs” as alternatives rather than string literals. This allows me to tie additional information with the key. The syntax is legal according to https://github.com/actions/runner/issues/343#issuecomment-590634907 and works well in practice. Note that the jobs (attr1.key1, attr1.key2, attr2.key1, attr2.key2, attr2.key3) triggered are:

  • (val1, val2, val5, val6, val7)
  • (val1, val2, val8, val9, val10)
  • (val3, val4, val5, val6, val7)
  • (val3, val4, val8, val9, val10)

However, I’m unable to exclude configurations from the matrix. For example, the following doesn’t work:

exclude:
  - attr1:
    - key1: val1
      key2: val2

To Reproduce Run the above workflow with the excluding rule added.

Expected behavior Only

  • (val3, val4, val5, val6, val7)
  • (val3, val4, val8, val9, val10)

get triggered.

Runner Version and Platform

2.284.0 (Github hosted runner)

OS of the machine running the runner? ubuntu-20.04 20211122.1

What’s not working?

All four jobs got triggered.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
MoetaYukocommented, Mar 2, 2022

Thanks for the response, feel free to close this issue.

0reactions
exsesxcommented, Aug 18, 2022

Hey! Excuse me for writing here. I have a similar issue (well, at least it’s the closest I could find).

strategy:
      fail-fast: false
      matrix:
        include:
          - service: my-service-1
            repository: string
            executor: string
            # build: false

          - service: my-service-2
            repository: string
            executor: string
            # build: true

          - ...
            
        exclude:
          # - build: false # doesn't work

I’m using the “include” syntax to build multiple services (in this case, two). Is there any way to exclude some of them? I was thinking about adding the shouldBuild boolean flag and then checking it. I could’ve just added if to my job, but I don’t think it’s clean.

Should I create a new issue for this?..

Read more comments on GitHub >

github_iconTop Results From Across the Web

Initializing an array of structs, why does using ...
I am extremely new to C. Would appreciate if someone can help understand why code in lines 13,14 and 16 does not work,...
Read more >
Saving to .mat without additional struct. - MATLAB Answers
When you save the struct array, specify the '-struct' option. This will save each of the struct fields separately in the MAT-file.
Read more >
How to Exclude Some Fields While Using the Function ...
First, I'd like to point out that it doesn't look like a structure is the right container for your data. Since you want...
Read more >
Set Array Elem for structs doesn't work
In my case, I have struct that contains an array of structs, which contains another array of structs, which, regardless of what I...
Read more >
Cannot add struct to array without adding element ...
I ran into this problem with structs and arrays today while working in my procedural world. I got an array of stucts.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found