kiegroup / act-js

A node.js wrapper for nektos/act to programmatically run your github actions locally
Apache License 2.0
56 stars 10 forks source link

Flaky tests caused by parallel jobs log parsing #60

Closed TWiStErRob closed 11 months ago

TWiStErRob commented 11 months ago

Describe the bug If one job starts a group, and another logs while that group is open, then the parser crashes with:

Cannot read properties of undefined (reading 'output')
TypeError: Cannot read properties of undefined (reading 'output')
    at OutputParser.parseStepOutput (node_modules/@kie/act-js/build/src/output-parser/output-parser.js:119:61)
    at OutputParser.parseOutput (node_modules/@kie/act-js/build/src/output-parser/output-parser.js:26:18)
this.groupMatrix[stepOutputMatcherResult[1]][length - 1].output += ...
                                                        ^ LHS undefined

this.groupMatrix[stepOutputMatcherResult[1]] === [], therefore length is 0, and ...[-1] === undefined.

To Reproduce

test("original", async () => {
    const contents = await fs.readFile("act.log");
    console.log(new OutputParser(contents.toString()).parseOutput());
});

act.log:

[Build/Tests            ] ⭐ Run Main Testing
[Build/Tests            ]   ❓  ::group::Unit Tests
[Build/Static Analysis  ] ⭐ Run Main Lint
[Build/Static Analysis  ]   | No problems found.
[Build/Tests            ]   | 1231 tests executed.
[Build/Tests            ]   ❓  ::endgroup::
[Build/Tests            ]   ❓  ::group::Integration Tests
[Build/Tests            ]   | 32 tests executed.
[Build/Tests            ]   ❓  ::endgroup::
[Build/Static Analysis  ]   ✅  Success - Main Linting
[Build/Tests            ]   ✅  Success - Main Testing

Expected behavior "Just works".

Logs

Distilled real log focused on the issue ``` [Android Build/Unit Tests ] 🚀 Start image=ghcr.io/catthehacker/ubuntu:act-latest [Android Build/Android Lint ] 🚀 Start image=ghcr.io/catthehacker/ubuntu:act-latest [Android Build/Unit Tests ] ⭐ Run Main Set up Android SDK. [Android Build/Unit Tests ] 🐳 docker cp src=/home/runner/.cache/act/android-actions-setup-android@v3/ dst=/var/run/act/actions/android-actions-setup-android@v3/ [Android Build/Android Lint ] ⭐ Run Main Set up Android SDK. [Android Build/Android Lint ] 🐳 docker cp src=/home/runner/.cache/act/android-actions-setup-android@v3/ dst=/var/run/act/actions/android-actions-setup-android@v3/ [Android Build/Android Lint ] | [command]/root/.android/sdk/cmdline-tools/11.0/bin/sdkmanager tools [Android Build/Unit Tests ] | [command]/root/.android/sdk/cmdline-tools/11.0/bin/sdkmanager tools [Android Build/Android Lint ] | [command]/root/.android/sdk/cmdline-tools/11.0/bin/sdkmanager platform-tools [Android Build/Android Lint ] ❓ add-matcher /run/act/actions/android-actions-setup-android@v3/matchers.json [Android Build/Android Lint ] ✅ Success - Main Set up Android SDK. [Android Build/Android Lint ] ⭐ Run Main Set up Java for Project. [Android Build/Android Lint ] 🐳 docker cp src=/home/runner/.cache/act/actions-setup-java@v3/ dst=/var/run/act/actions/actions-setup-java@v3/ [Android Build/Android Lint ] ❓ ::group::Installed distributions [Android Build/Android Lint ] | Resolved Java 17.0.9+9 from tool-cache [Android Build/Unit Tests ] | [command]/root/.android/sdk/cmdline-tools/11.0/bin/sdkmanager platform-tools [Android Build/Android Lint ] | Path: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.9-9/x64 [Android Build/Android Lint ] ❓ ::endgroup:: [Android Build/Android Lint ] ✅ Success - Main Set up Java for Project. [Android Build/Unit Tests ] ❓ add-matcher /run/act/actions/android-actions-setup-android@v3/matchers.json [Android Build/Unit Tests ] ✅ Success - Main Set up Android SDK. ```

Additional context Looking at output-parser.js, as far as I see .isPartOfGroup is handled on the parser level, but it should per-job.

TWiStErRob commented 11 months ago

Can you please release this?

shubhbapna commented 11 months ago

Done!