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

Multiline support for Toolkit Annotations #193

Open
svartalf opened this issue Oct 28, 2019 · 14 comments
Open

Multiline support for Toolkit Annotations #193

svartalf opened this issue Oct 28, 2019 · 14 comments
Labels
enhancement New feature or request

Comments

@svartalf
Copy link

This is a follow-up issue started at #186 (comment).

It is unclear from the recently added Annotation docs if ::debug/::warning/::error messages support multiline text in the {message} placeholder.

Why it is important? These Annotations can be used by various code linters and other similar tools, but their output easily could be spanned to multiple lines, for example:

pylint output:

W:108: Operator not followed by a space
     print >>sys.stderr, 'Unable to match %r', line
            ^

Rust compiler output:

warning: comparison is useless due to type limits
  --> example/src/lib.rs:20:8
   |
20 |     if pid < 0 {
   |        ^^^^^^^
   |
   = note: `#[warn(unused_comparisons)]` on by default

It would be nice to clarify if it is possible to use multiline strings over there and it is expected to be working correctly in the future.

@svartalf svartalf added the enhancement New feature or request label Oct 28, 2019
@danechitoaie
Copy link
Contributor

+1 At least some kind of initial feedback. Is it possible or not? And then maybe follow up with updating the docs.

@EricWF
Copy link

EricWF commented Mar 28, 2020

+1. This is one of the last blocking issues blocking me from moving to Github Actions. The output of my test suites failures are much longer than a single line, and I have no way to display them nicely.

AaronWashington referenced this issue Mar 28, 2020
@BrianHenryIE
Copy link

It can be achieved by using urlencoded newline %0A in place of \n.

I learned it from a comment by @PoisonousJohn at actions/starter-workflows#68 (comment)

I've confirmed it working for PHPUnit output and have a PR: https://github.com/mheap/phpunit-github-actions-printer/pull/14/files

And here's a screenshot of the outcome: https://i.imgur.com/nnSCPTG.png

Zero documentation anywhere, thank you @PoisonousJohn !

@EricWF
Copy link

EricWF commented Mar 28, 2020

I just discovered this, Cheers!
I can confirm it works and have used it successfully in a workflow.

PS. @BrianHenryIE Have you discovered a way to make problem matchers work with multi-line messages?

anomiex added a commit to Automattic/jetpack that referenced this issue Jan 11, 2021
Apparently you can include newlines in GitHub Actions errors and
warnings by using "%0A".

actions/toolkit#193 (comment)
bilderbuchi added a commit to bilderbuchi/pymeasure that referenced this issue Dec 8, 2021
Apparently this is not possible although the regex has
been confirmed to work, both using \n\n and url-encoded
%0A%0A.
See also actions/toolkit#193

Split warning messages are better than none, one will look
into the logs anyway.

This reverts commit 58bdefe.
@Profpatsch
Copy link

Wow, such an important feature and the only way to solve it is via an undocumented hack.

Why not just use a json object printed on one line, which can be readily produced with e.g. jq? Is this the quality standard the Github Actions team wants to stay at?

neal-kepler added a commit to keplercompute/pymeasure that referenced this issue Jul 20, 2022
* Fix typo SCIP->SCPI

* Fix SCPI used for Keithley 2400 voltage NPLC

* Add pendulum CNT-91 frequency counter. (pymeasure#508)

Add pendulum CNT91 frequency counter.

Add functionality for frequency time series and some basic operations.

* Update release workflow

Reflect the fact that the feedstock nowadays pulls from PyPI, not Github
conda-forge/pymeasure-feedstock#31
conda-forge/pymeasure-feedstock#32

* Fix missing return statements.

* Apply black to fix missing blank lines.

* Remove unused import.

* Update __init__.py

* Add files via upload

* Update index.rst

* Create anritsuMS9740A.rst

* Delete AnritsuMS9740A.py

* Add files via upload

* Delete AnritsuMS9710C.py

* Add files via upload

* Update __init__.py

* Keithley 2400: Allow assigning "ONCE" to auto_zero

* Keithley 2400: Add line frequency controls (pymeasure#524)

Keithley 2400: Add line frequency controls

* Add Rohde&Schwarz FSL spectrum analyzer. (pymeasure#511)

* updated filenames and docs

* minor updates per comments.

* changed the instance attribute 'idn' to an Instrument.control property called address.

* removed async methods, added the busy property to query if the controller is moving a motor.

* changed the current position property to step_position and added the absolute_position property. Interaction with this property should be defined in subclasses.

* Added an IntFlag subclass to decode errors so that user does not need to refer to the manual to understand error codes.

* fixed syntax error in error_reg definition

* added check_errors() function to log errors returned by the error_reg property. Introduced the step_position and absolute_position properties

* added home() method

* changed self.write('G') in step() method to self.go() so that user only needs to override go() in the application layer to acheive concurrency.

* Fixes error in Keithley2600.error when error code is returned in scientific notation.

* removed **kwargs from ask() overridden method as the base class has no kwargs.

* fixed formatting in docstrings and added wait_for_completion() method. This method just blocks until the controller is not 'busy.'

* modified the step_position property to return an integer

* updated dpseriesstepmotorcontroller home() docstring and added anaheimautomation/index to the instruments index file

* Update docs/api/instruments/anaheimautomation/dpseriesstepmotorcontroller.rst

Co-authored-by: Christoph Buchner <bilderbuchi@users.noreply.github.com>

* Update pymeasure/instruments/anaheimautomation/dpseriesmotorcontroller.py

committing suggested change from @bilderbuchi

Co-authored-by: Christoph Buchner <bilderbuchi@users.noreply.github.com>

* implemented changes suggested by @bilderbuchi

* Update authors.rst

* Update AUTHORS.txt

* Changed all get_process int casts to cast=int and changed the step_position setter to use the strict_range validator.

* Update docs/api/instruments/anritsu/anritsuMS9740A.rst

Co-authored-by: Christoph Buchner <bilderbuchi@users.noreply.github.com>

* Update and rename AnritsuMS9740A.py to anritsuMS9740A.py

* Update anritsuMS9740A.py

* Update anritsuMS9740A.py

* Fix indentation error

* Update anritsuMS9710C.py

* Use sphinx-problem-matcher, too.

This way we should also catch sphinx errors outside of docstrings.

Note: The line number of docstring warnings is not contained in the
warning message, so it's not possible to annotate such a warning at
the correct location in the file.
See also sphinx-doc/sphinx#6036

* Add flake8 problem matcher.

* Add a pytest warning problem matcher.

* Try to match multiline pytest warnings.

* Revert "Try to match multiline pytest warnings."
Apparently this is not possible although the regex has
been confirmed to work, both using \n\n and url-encoded
%0A%0A.
See also actions/toolkit#193

Split warning messages are better than none, one will look
into the logs anyway.

This reverts commit 58bdefe.

* Fix small error caught by flake8.

* Remove Python 3.6 from CI.

It's EOL and current PyQtgraph does not support it.

* Bump CI versions of pyqtgraph and pyvisa.

* Remove broken methods in experiment.py.

* Fix invalid escape warning.

* Move flake8 config to setup.cfg.

This way, editors can use the same configuration as CI.

* Linter: Fix indentation problems (E1).

The commmand used was
autopep8 --in-place -r --max-line-length=100 --select E1 .

* Let's go with a line length of 100.

* Linter: Fix trailing whitespace, too few or many blank lines.

W29,W39,E3

* Linter: Fix whitespace problems (E2).

* fix Attocube ANC300 with new SCPI Instrument properties

in commit bbc0354 the not implemented SCPI properties were changed to emit an error. The properties of an instrument can therefore not be browsed anymore as before which made a code change in the Attocube code necessary.

* Linter: Fix some line-too-long problems (E501).

* Linter: Fix whitespace problems. (W29)

* Linter: Fix last issues with autopep8.

From now on it seems to be manual work.

Used autopep8 --in-place -r --max-line-length=100 --ignore E402 .
E402 fixes looked weird/wrong, so were ignored.

* Linter: Fix reports in examples/*.

* Linter: Fix reports in adapters/*.

* Linter: Fix reports in display/*.

* Linter: Fix reports in experiment/*.

* Linter: Fix reports in tests/*.

* Linter: Fix reports in instruments/*.

* Remove unneeded computation of inverse map in setting factory.

* Bump the max complexity setting.

It's now a little above the level of Instrument.control, which is
not _that_ complex.

This should mainly guard against wildly complex methods.

* Simplify Results.parse_header

* Refactor DSP7265.buffer_to_float() to bring its complexity down.

Before, it was the most complex function in the codebase, by far.

* Add docs on flake8 usage and update the pull request section.

* Remove references to Python 3.6.

* Address review comments.

* Remove safeKeywords from VISAAdapter (pymeasure#536)

Implemented by @msmttchr

* Removed unused code

By chance I stumbled upon this code that isn't used anywhere apparently, so I propose to remove it.

* Enable flexible configuration of connection settings.

Instrument implementations pass in dicts, processing happens
within VISAAdapter.
Make it possible to override instrument-specific defaults.
Add tests demonstrating usage.
Update pyvisa CI version to latest.

* Add docs and docstrings for connection setting best practices.

* Use best practice for instrument connection settings that I could find.

* Switch on Python 3.10 testing.

* Cast progressbar value explicitly to int.

Avoid implicit conversion from float to integer, see
https://bugs.python.org/issue36048

Fixes pymeasure#531.

* Bump CI requirements to Python 3.10 compatibility.

* Fix linter report.

* Clarify some code, add a test for interface typo.

* Clarify docstring of joined_validators and strict_range.

* Added management of progress bar

In the examples, add also management of progress bar to address misunderstanding similar to those reported in pymeasure#531 (comment)
Implement solution proposed by @CasperSchippers

* Fix docstring formulation.

* Move write delay to the instrument itself

* Implement new flexible default connection-settings

* Remove test for write-delay

* Fix linting issues

* Fix linter reports and tweak docstring indentation.

* Change default communication settings to single-interface format

* Added HP8116A instrument class

* Added a few basic setters

* Unit parsing & some basic controls

* Improved docstrings

* Added controls which are string properties

* Added boolean controls

* Added Option 001 controls

* Added GPIB status byte & corrected flake8 issues

* Added a few unit tests and a method to check for option 001

* Automatic decision about the response length based on the command

* Implemented check_errors()

* Added 8116A to docs

* Added a method to control the autovernier

* Prefixed private methods with underscore & restructuring

* Error message update

Co-authored-by: Christoph Buchner <bilderbuchi@users.noreply.github.com>

* Updated error message

Co-authored-by: Christoph Buchner <bilderbuchi@users.noreply.github.com>

* New Instrument: Toptica Smart Laser diode (pymeasure#352)

Toptica IBeam Smart Laser diode instrument implementation.

This instrument uses a weird communication protocol which sends a CR+LF reply after every set command. 
Additionally a query and set command are acknowledged always by a [OK] reply.
A custom adapter is implemented that deals with this.

Co-authored-by: Christoph Buchner <bilderbuchi@users.noreply.github.com>

* Keithley 2306 Dual Channel Battery/Charger Simulator (pymeasure#529)

Add Keithley 2306 Dual Channel Battery/Charger Simulator.

Also add a test suite to check implementation with a 
connected instrument.
See pymeasure#529.

* Removed staticmethod from _boolean_control for python<3.10 compatibility

* Remove errorbars

* Simplified code structure

Enhancement and bug fixing to doc strings
Removed obscure code for reading functions parameters list
Removed module global variables to make class DynamicProperty reusable
Reordered and renamed parameter list for DynamicProperty class
Removed special_keys class variables and replaced with two list for fget and fset
Extended command_process to set commands to be uniform.
Very important removed use of dynamic parameter, now all Instrument.control/measurement/setting are dynamic by default.
dynamic parameter documentation left in the code, if changes are accepted be removed after review.
Simplified definition of fget and fset functions

* new Instruments: Andeen Hagerling capacitance bridges (pymeasure#535)

Add new Instruments: Andeen Hagerling capacitance bridges.

* Added back usage of dynamic parameter

Also more structured testing (credit to @bilderbuchi)

* Updated copyright & fixed spelling

* Typo in docstring

Co-authored-by: Casper Schippers <Casperschippers@hotmail.com>

* Typo in docstring

Co-authored-by: Casper Schippers <Casperschippers@hotmail.com>

* Improved English in documentation

Thanks to @CaspersShippers!!!

Co-authored-by: Casper Schippers <Casperschippers@hotmail.com>

* English improvement

Co-authored-by: Casper Schippers <Casperschippers@hotmail.com>

* Documentation update and minor code changes

Default parameters value set to None instead of mutable object
Enhanced error messages clarity
Use of __mro__ instead of method mro.
docstring improvements

* Update pymeasure/instruments/instrument.py

Co-authored-by: Christoph Buchner <bilderbuchi@users.noreply.github.com>

* Further enhancements

Simplified exception messages
Internal method name change to highlight the side effects
Appended string "(dynamic)" to docstring.

* Fix linter report.

* Change copyright date to 2022 (pymeasure#572)

* Update adding_instruments.rst (#5)

* Update adding_instruments.rst

* Update adding_instruments.rst

* Updated documentation after review

* Updated documentation after review

* Editing pass on new documentation.

* Modernise the code base to use Python 3.7 features.

This mainly starts using f-strings and .format instead of the %
notation, and removes superfluous super() arguments.

Used the pyupgrade tool to do this:
"find . -name '*.py' -exec pyupgrade --py37-plus {} +"

* Modernise the code base to use Python 3.7 features. (pymeasure#577)

This mainly starts using f-strings and .format instead of the %
notation, and removes superfluous super() arguments.

Used the pyupgrade tool to do this:
"find . -name '*.py' -exec pyupgrade --py37-plus {} +"

* Added image data generation to Mock Instrument class (pymeasure#552)

Create methods to return single channel mock image data with specified width, height, and bit depth
Maintenance around Mocks/fakes:
Updated Mock to inherit from FakeInstrument, rename to SwissArmyFake, put new functionality there.
Removed SwissArmyFake and FakeInstrument from the Instrument namespace.
Remove __getitem__ from SwissArmyFake. This was originally introduced (in a suspected nonfunctional
manner) in 3c5c158, but its current purpose is unknown.

Co-authored-by: Christoph Buchner <bilderbuchi@users.noreply.github.com>

* Heidenhain ND287 Position Display Unit Driver (pymeasure#534)

* configured directory widget to launch at currently entered directory

* Added ManagedWindowBase kwarg to set default dir

* removed default_directory_path param from ManagedWindowBase, added directory setter

* string-ify input value in directory setter

* Updated directory section of docs

* Added myself to authors.rst and AUTHORS.txt

* Add autodoc warnings to the problem matcher.

This should enable us to at least flag autodoc
import errors in the diff view.
Catching error otherwise is not feasible, see pymeasure#583.

* CI: Make warnings fail the docs_lint job.

This is the only way to reliably surface sphinx-autodoc warnings.
Failing lint steps don't stop the job execution, and despite a
failing docs_lint job the test job still runs, to maximize
received feedback.

* Fix pylint report.

* Correctly include fake instruments in the docs.

* New instruments: Oxford IPS120-10 and PS120-10 (pymeasure#459)

Includes a number of useful properties.
Uses a custom retrying adapter with reply checking to account for 
device-specific communication protocol.
PS120_10 is derived from IPS120_10 and only implements the 
differences using the new dynamic property feature.

Co-authored-by: Benjamin Klebel <32774645+bklebel@users.noreply.github.com>

* Move to using OxfordInstrumentsAdapter and move init to front of class

* Linting

* Make use of dynamic property for temperature_range

* Make use of dynamic property for temperature_range

* fix mistake with using dynamic property

* Correct usage of dynamic properties
Apparently it is not possible to modify the values list of a dynamic property since that requires getting the value (which is forbidden)

* Fix typo

* Enable the OxfordInstrumentsAdapter to handle signed numbers

* Remove "$" from commands

* Fix issue where the status and version commands didn't match the regex for validation
(The "X" and "V" command both have a different response compared from the other commands)

* Implement preprocess reply

* Small update to docs of the IPS

* Removed error checking from wait_for_idle ifn IPS120_10 as this is an intrinsic part of the OxfordInstrumentsAdapter

* Breakout widgets into separate modules. Auto-import current modules at pymeasure/display/widgets/__init__.py for backwards compatibility

* fix linting errors in browser_widget.py and plot_frame.py

* fix linting errors in __init__.py

* changed self.address to self._address in the ask() write() and values() methods. In the previous case, collisions on the serial line are caused when multiple motor controllers are connected on the same serial line.

* ran a sphinx  and fixed all reported broken links.

* Add Keysight N7776C Swept Laser Source (pymeasure#499)


Co-authored-by: Christoph Buchner <bilderbuchi@users.noreply.github.com>

* Added copyright to file

* Added submodules to widgets.rst and updated docstrings in widget modules.

* fix linting in docstrings and spelling errors

* Fix spelling error

* Changed docstring for ResultsDialog

* Increase timeout from 4 or 5 seconds to 20 to account for slow github action containers worker.join(timeout=20.0)

* Increasing sleep time for listener prevented errors in \`test_zmq_topic_filtering_works()\` for 40 runs

* json format works"

* fix to reload for JSON outputfmt

* allow port to be None from ManagedWindow

* sequences work with json formatter

* sequences work with json formatter

* can now sequential json add

* gui loads

* basic functionality demonstrated

* gui loads

* added some analysis abort buttons

* fixed abort analysis behavior

* minor fixes

* fail loudly

* fail mildly

* fix case hierarchy

* fix jsonification in resluts

* add new safe function to sequencer widget

* import error fix

* remove analyses when done

* modification to allow routines to do analyze when not finished

* more hacks to make fatigue work

* minor fix to json formatting to deal with race conditions

* minor debug fixes

* fixes to keithley2600

* more robush json reload retry

* chunk defined

* minor optimiization to transfer and load

* fix to bn675 driver

* try except in minicircuits adapter

Co-authored-by: Mike Fikes <mike@fikesfarm.com>
Co-authored-by: Michele Sardo <37845722+msmttchr@users.noreply.github.com>
Co-authored-by: Bastian Leykauf <leykauf@physik.hu-berlin.de>
Co-authored-by: Casper Schippers <Casperschippers@hotmail.com>
Co-authored-by: Christoph Buchner <bilderbuchi@users.noreply.github.com>
Co-authored-by: md12g12 <47577588+md12g12@users.noreply.github.com>
Co-authored-by: mcdo0486 <mcdo0486@umn.edu>
Co-authored-by: samcondon4 <scondon@caltech.edu>
Co-authored-by: Brian Carlsen <carlsen.bri@gmail.com>
Co-authored-by: Christoph Buchner <bilderbuchi@phononoia.at>
Co-authored-by: Dominik Kriegner <dominik.kriegner@gmail.com>
Co-authored-by: Michele Sardo <msmttchr@gmail.com>
Co-authored-by: CodingMarco <codingmarco@gmail.com>
Co-authored-by: Robert <LongnoseRob@users.noreply.github.com>
Co-authored-by: jarvas24 <66141312+jarvas24@users.noreply.github.com>
Co-authored-by: Benjamin Klebel <32774645+bklebel@users.noreply.github.com>
Co-authored-by: spherex <spherex>
Co-authored-by: Andreas Maeder <68421682+maederan201@users.noreply.github.com>
Co-authored-by: neal-kepler <neal@keplercomputer.com>
@Fleshgrinder
Copy link

The same trick can be used in echo "::warning::multi%0Aline" commands within a workflow. This creates a multiline annotation, but only the first line in the build log is going to be highlighted, all that follows show up as normal.

prince-chrismc pushed a commit to prince-chrismc/conan-center-index that referenced this issue Sep 30, 2022
conan-center-bot pushed a commit to conan-io/conan-center-index that referenced this issue Oct 25, 2022
…tion for `config.yml` and `conandata.yml`

* first attempt at a yaml linter wit github actions output

* This is less strict but has more information

* fixup message

* run config linter in Action

* better ux feedback

* try to use newlines

actions/toolkit#193 (comment)

* clean up

* fixup file name

* trying custom class for quoted str

* underlying yaml parser does not keep quotes

* trying to catch ints as problems

* remove test code

* and to "linter testing"

* install deps

* run new linter unconditionally

* revert testing changes

* new script for conandata (this one is much harder to spec)

* debugging

* lets see all the errors

* yamale -s ../linter/config_yaml_schema.yml aaf/config.yml

from linters folder as a test

* adjust script to match meeting discussion

* make sure the docs and linters match

* fix link

* Update conandata.yml

* exit 1 is not needed with annotations

* add annotation matchers for yaml since those do do much

* fix search for type

* fix whitespace

* tryout a yamllint file with a better looking matcher

* copy syntax from readme

* test if it's running in the wrong dir 🤔

* try with debug output

* bump since i dont have permissions

* bump - dont glob star

* bump

* less star globs

* also add action to conandata way

* bump

* drop action for cli + matcher

* more docs around linters

* fix file and name

* cleanup
@rhaschke
Copy link

The same trick can be used in echo "::warning::multi%0Aline" commands within a workflow.

Unfortunately, this trick doesn't work anymore:
image

@rhaschke
Copy link

The Command class (still) uses this escaping:

function escapeData(s: any): string {
return toCommandValue(s)
.replace(/%/g, '%25')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A')
}

josegomezr added a commit to josegomezr/perl-design-patterns that referenced this issue Nov 24, 2023
According to [0] & [1] all is needed is to urlencode newlines!

[0]: actions/starter-workflows#68 (comment)
[1]: actions/toolkit#193
@muzimuzhi
Copy link
Contributor

@rhaschke It seems the %0A trick still works, see https://github.com/pgf-tikz/pgf/actions/runs/7294270657.

@rhaschke
Copy link

It seems the %0A trick still works, see https://github.com/pgf-tikz/pgf/actions/runs/7294270657.

For me, the multi-line output is only shown correctly when clicking "show more". Without that expansion, everything shows up in a single line, doesn't it?
In my example (with a shorter line) it doesn't work: https://github.com/rhaschke/test/actions/runs/5961263674
As the line(s) are too short, there is no "show more" button provided.

@muzimuzhi
Copy link
Contributor

@rhaschke Yes, you observation is right.

@justinmchase
Copy link

justinmchase commented Mar 5, 2024

The new lines (escaped with %0A) don't appear to be respected in the annotation view of the errors...

new lines are not displayed

Screenshot 2024-03-05 at 9 09 07 AM

raw logs show newlines correctly

Screenshot 2024-03-05 at 9 09 26 AM

Also, I definitely expected it to respect markdown but it does not, which is surprising.

@tsigouris007
Copy link

Is there any actual way that works here?
%0A does not work for me as well now.

@Ximaz
Copy link

Ximaz commented Apr 28, 2024

I search for something similar but unable to find. I'd like to display valgrind's logs for memory leaks as an Error annotation, but it's multiline. I tried to do so :

-   name: "Analyze valgrind report"
    run: |
        status=0
        block=""
        while IFS= read -r line; do
            if [[ "${block}" != "" ]]; then
                if [[ $(echo "${line}" | grep '^==.*== $') ]]; then
                    echo "::error title=\"Valgrind Error\"::${block}"
                    block=""
                    status=1
                else
                    block="${block}
        ${line}"
                fi
            fi
            if [[ $(echo "${line}" | grep '^==.*== .* bytes in .* blocks are definitely lost in loss record .* of .*$') ]]; then
                block="${line}"
            fi
        done < valgrind-reports.log
        rm -f valgrind-reports.log
        exit "${status}"

And you can see that I'm leaving a line, without having to specify %0A, but the result is quite similar to the one above.

image image

I think it would be cool to have a sort of ::group:: ::endgroup:: but making it working for error, warning and so on, so it also gets displayed on the workflow summary.

In fact, it appeared that %0A works, I mean, at least regarding the summary :
image

But when clicking on the details, other logs are still shown outside of the error scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests