Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem matcher relative file path should be rooted in working-directory, not workspace #765

Open
bilderbuchi opened this issue Oct 24, 2020 · 1 comment
Labels
bug Something isn't working Runner Bug Bug fix scope to the runner

Comments

@bilderbuchi
Copy link

bilderbuchi commented Oct 24, 2020

tl;dr: To resolve relative paths in an Issuematch, the workspace location is used, even if the step's working-directory points elsewhere, making it impossible to correctly parse relative file paths in error logs.

I am using actions to check docstring code snippets ("doctests") in a Python codebase during documentation generation using Python's well-known documentation generator Sphinx. In typical Python codebases, the documentation resides in a subdirectory docs.

To run the doctest checker, you go to the docs subdirectory and run a sphinx-generated makefile with make doctest (which then uses sphinx-build).
I do this in a step by using working-directory:

      - name: Run doctests
        working-directory: ./docs
        run: |
          echo "::add-matcher::.github/sphinx.json"
          make doctest

I can tell that this works because the run step concludes correctly.
I have written a problem matcher (which you see added above) for this output. It has been simplified to account for the current lack of support for multi-line error messages. The problem matcher picks up the error messages correctly.

Now, crucially, doctest errors are reported by sphinx-build with relative paths relative to the docs directory where all the documentation and its configuration system reside. Using make -C docs doctest or similar things does not change that.

File "dev/adding_instruments.rst", line 321, in default

This file is in docs/dev/adding_instruments.rst related to the project root.

Another path referring to a file in the main python package looks like this - note the ... The line number being ? is a limitation of Sphinx.

File "../pymeasure/instruments/agilent/agilent34450A.py", line ?, in default

The annotation does not identify these paths correctly, despite the working-directory being used in the step definition:
Screenshot from 2020-10-24 21-31-10
Note that the line number and message are correctly picked up. The fact that this gets attributed to the .github "file" is actions/toolkit#473

I found no way to get the Annotations to be placed/recognized correctly. fromPath cannot be used because the error message does not know about the project root location. I think I have identified the relevant code section which suggests that the workspace root is used for rooting, not the working directory.

Expected behavior

Having an error message with a relative path in file, and using working-directory in the step definition, I expected the relative path to be resolved correctly by rooting in the working directory, and the annotation to be placed in the PR Files view.

I am assuming that if working-directory is unset, it defaults to GetGitHubContext("workspace"). If that is so, a change of IssueMatch rooting to working-directory should show no change for people not using working-directory, limiting the impact of a fix for this issue.

Related issues

actions/toolkit#224 by @xt0rted, apparently solved by @ericsciple but apparently not for a script step (non-container? I am not familiar with the lingo)
#659, which maybe could be solved at the same time if monorepos are restricted to using working-directory. This could limit scope so only use cases where the steps don't cd all over the place during execution would be supported.

Runner Version and Platform

2.273.5

OS of the machine running the runner? OSX/Windows/Linux/...
ubuntu-latest

Job Log Output

I can't offer debug logs as I don't have admin access to the repo in question, but the relevant run log starts [here].(https://github.com/ralph-group/pymeasure/runs/1302687942?check_suite_focus=true#step:6:1)

@dor-utila
Copy link

Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Runner Bug Bug fix scope to the runner
Projects
None yet
Development

No branches or pull requests

3 participants