Skip to content

[Bug]: Reduce of empty array with no initial value #11

@mmahut

Description

@mmahut

What happened?

Calling the main file works okay.

$ stepci run ./main.yml 
 PASS  blocks/487800d208d4cb43ef8d8a4ec162f479a76dbeee3b4c14295bd920d99d33e0c7

Tests: 0 failed, 1 passed, 1 total
Steps: 0 failed, 0 skipped, 1 passed, 1 total
Time:  0.149s, estimated 0s
CO2:   0.00024g

Workflow passed after 0.149s
Give us your feedback on https://step.ci/feedback

Calling a file that includes it does not:

$ cat workflow.yml
version: "1.1"
name: My tests
include:
 - main.yml
node_modules/@stepci/runner/dist/index.js:97
            co2: testResults.map(test => test.co2).reduce((a, b) => a + b)
                                                   ^

TypeError: Reduce of empty array with no initial value
    at Array.reduce (<anonymous>)
    at run (node_modules/@stepci/runner/dist/index.js:97:52)

What did you expect to happen?

To run my included workflow as does the main file.

Version

2.6.3

Environment

v16.16.0

How can we reproduce this bug?

See above.

Relevant log output

No response

Would you be interested in working on a bugfix for this issue?

  • Yes! Assign me

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions