Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Please add an option to skip "cd" to different directories, or convert relative to absolute paths #174

Open
@svenevs

Description

@svenevs

Noticed something interesting recently fixing another CI error: my AppVeyor results were no longer being uploaded anymore (for who knows how long). I am greatly suspicious of this code:

toc = str((try_to_run('cd %s && git ls-files' % root) or
try_to_run('git ls-files') or
try_to_run('cd %s && hg locate' % root) or
try_to_run('hg locate') or '').strip())

Failed build

Full build log here, specifically this part is curious because this used to work as expected with codecov on this repo:

==> Collecting reports
XX> Searching for reports disabled
    Targeting specific files
    - Ignored: [Errno 2] No such file or directory: '.\\coverage.xml'
Error: No coverage report found

Solution: must use absolute path now

--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -94,6 +94,6 @@ after_test:
         Invoke-Expression $codecov_cmd
       }
       else {
-        $codecov_cmd = '& codecov -X gcov -f .\coverage.xml --name ' + $env:TEST_NAME
+        $codecov_cmd = '& codecov -X gcov -f c:\projects\exhale\coverage.xml --name ' + $env:TEST_NAME
         Invoke-Expression $codecov_cmd
       }

My Guess

I don't think you can just do cd <somewhere> && other_stuff || different_stuff on windows in general. So what I believe happens is the cd is successful, but the rest fails and then codecov never goes back.

In general, it's worth mentioning that this repo has a lot of patterns like this that should probably be a little more careful. Another small example that could cause problems:

branch = try_to_run('git rev-parse --abbrev-ref HEAD || hg branch')

I think that the python script was probably just adapted from the bash script and maybe that's why all of these are in here? Unfortunately, there's a large number of them...but this is why there are generally so many problems on AppVeyor.

For the cd (suspected) problem, you may want to introduce a simple context manager so that you can do

with cd(some_path):
    execute_stuff()

where the context manager will go back to where it came from (lots of examples online, here's a good starting place).

Or an even easier solution that would be much faster is specifically when you get a -f <some_path> you can check

# suppose it was called this
file_path = args["-f"]  # just an example...
if not os.path.isabs(file_path):
    file_path = os.path.abspath(file_path)

or similar. Basically, make everything absolute before you start "cd'ing" around 🙃

Happy to help implement changes with more input on what you want here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions