invertase / melos

🌋 A tool for managing Dart projects with multiple packages. With IntelliJ and Vscode IDE support. Supports automated versioning, changelogs & publishing via Conventional Commits.
https://melos.invertase.dev/~melos-latest
Apache License 2.0
1.19k stars 206 forks source link

fix: Tests Failing in Windows Environment #757

Open jessicatarra opened 2 months ago

jessicatarra commented 2 months ago

Is there an existing issue for this?

Version

main

Description

Currently, there are two issues related to the Windows environment:

  1. The status codes when running some melos commands are not reliable. For example, the command melos test --no-select is expected to be the same as running melos exec --dir-exists=test --concurrency 1 -- "dart test". However, using the latter command directly provides the actual exit code of the process in windows environment pipeline, while the former does not.

  2. Due to the recent fix to maintain the working directory across script steps, as merged in PR #711, the log output will look like the following one:

'Microsoft Windows [Version 10.0.20348.2655]\n'
              '(c) Microsoft Corporation. All rights reserved.\n'
              '\n'
              'd:\\a\\melos\\melos\\packages\\melos\\.dart_tool\\a9ed4760>      echo "➡️ step: melos run list" && melos run list || VER>NUL && if %ERRORLEVEL% NEQ 0 (echo __FAILURE_COMMAND_END__) else (echo )\n'
              '"➡️ step: melos run list" \n'
              'melos run list\n'
              '  └> echo "list script"\n'
              '     └> RUNNING\n'
              '\n'
              '"list script"\n'
              '\n'
              'melos run list\n'
              '  └> echo "list script"\n'
              '     └> SUCCESS\n'
              '\n'
              'd:\\a\\melos\\melos\\packages\\melos\\.dart_tool\\a9ed4760>    \n'
              'd:\\a\\melos\\melos\\packages\\melos\\.dart_tool\\a9ed4760>      echo "➡️ step: echo "hello world"" && echo "hello world" || VER>NUL && if %ERRORLEVEL% NEQ 0 (echo __FAILURE_COMMAND_END__) else (echo )\n'
              '"➡️ step: echo "hello world"" \n'
              '"hello world" \n'
              '\n'
              'd:\\a\\melos\\melos\\packages\\melos\\.dart_tool\\a9ed4760>    \n'
              'd:\\a\\melos\\melos\\packages\\melos\\.dart_tool\\a9ed4760>SUCCESS\n'

Steps to reproduce

Run the test suite as a GitHub Actions Workflow: https://github.com/invertase/melos/actions/runs/10889115119

Expected behavior

Screenshots

No response

Additional context and comments

No response

bvoq commented 2 months ago

This also happens when you add steps as follows:

scripts:
  test:
    steps:
      - melos exec -f --dir-exists=test -- flutter test
      - echo "Continue the step like nothing happened"

If you run melos test you will hit exit code 0 on macOS. This is not platform specific. However, if you run melos exec -f --dir-exists=test -- flutter test directly, you will get exit code 1.

spydon commented 2 months ago

@bvoq this issue is about the internal Melos windows tests. There should be another issue open for the issue you're describing though.