Skip to content

Expand the regression test annotations.#2501

Merged
rwest merged 11 commits intoReactionMechanismGenerator:mainfrom
rwest:regressiontests
Jul 22, 2023
Merged

Expand the regression test annotations.#2501
rwest merged 11 commits intoReactionMechanismGenerator:mainfrom
rwest:regressiontests

Conversation

@rwest
Copy link
Copy Markdown
Member

@rwest rwest commented Jul 20, 2023

Motivation or Problem

The results of the regression tests were largely buried in the logs of the continuous integration action workflow, rather than being nicely summarized on the annotation to the pull request.

Description of Changes

The summaries and comparisons that are generated by the CI running the regression tests are captured, and used to make the annotation.
The summary is stored as a text file, with the pull request number stored on the first line. This is then uploaded as an artifact. A new workflow runs whenever the CI workflow completes, then downloads the artifact, extracts the summary, and posts a comment. This complicated runaround is needed because workflows run by pull requests from forks do not have permission to write comments directly.

Testing

For the markdown formatting, I have run it a bunch, and checked things render correctly. (See some of the run logs, where things are duplicated into the workflow summary).
For the artifact and annotation scripts, I debugged and tested it on my own fork. It'll only function properly once the annotation.yml workflow ends up on the main branch - but I tested it there :)

Copy link
Copy Markdown
Contributor

@JacksonBurns JacksonBurns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small note

@codecov
Copy link
Copy Markdown

codecov bot commented Jul 20, 2023

Codecov Report

Merging #2501 (bc9be93) into main (2be81c4) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #2501   +/-   ##
=======================================
  Coverage   48.54%   48.54%           
=======================================
  Files         110      110           
  Lines       30812    30812           
  Branches     8054     8054           
=======================================
  Hits        14959    14959           
  Misses      14330    14330           
  Partials     1523     1523           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@rwest rwest force-pushed the regressiontests branch 2 times, most recently from 31ffcfc to 8d04acb Compare July 21, 2023 14:06
@rwest
Copy link
Copy Markdown
Member Author

rwest commented Jul 21, 2023

I think this annotation idea is not going to work for pull requests from forked repositories. Only pull requests made from branches of the official repository.

Check the "Maximum access for pull requests from public forked repositories" column here
This is a safety thing, to stop people doing nefarious things by opening a pull request that modifies the github action recipes.

Options seem to be...

@rwest
Copy link
Copy Markdown
Member Author

rwest commented Jul 21, 2023

Here is a workaround https://github.com/nyurik/auto_pr_comments_from_forks. The pull_request target saves the comment markdown as an artifact, that another workflow (in their case running on a cron job) posts as a comment.

This summary also helpful https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/
The workflow_run event might be useful.

@JacksonBurns
Copy link
Copy Markdown
Contributor

I will start a separate PR to implement this workaround to keep this one in scope.

@rwest
Copy link
Copy Markdown
Member Author

rwest commented Jul 21, 2023

I have an idea I'm going to try

rwest added 10 commits July 22, 2023 00:10
The regression-comparison step now captures its STDOUT
(and STDERR) outputs and they are used to create the
annotation on the pull request.

I tried the mathiasvr/[email protected]
workflow,  but it doesn't let us use a bash
login shell, and maybe has other vulnerabilities.
So I reverted to bash and trying to just
redirect outputs to files.
To help debugging. The thing that should become the PR annotation
is now duplicated into the summary of the
job run. Might be a good idea anyway.
Looks bad, with new system of putting the full summary there.
Blank lines needed to make subsequent blocks render as markdown.
Just trying to get the first line of a damn file.
We put the pull request number at the start of the summary file,
so the other workflow knows which PR to put the comment on.
@rwest rwest force-pushed the regressiontests branch from 6591934 to b54db3a Compare July 22, 2023 04:12
@rwest rwest marked this pull request as ready for review July 22, 2023 04:15
@rwest
Copy link
Copy Markdown
Member Author

rwest commented Jul 22, 2023

Sorry for pushing a couple of commits to master. If we undo (reset the head to before I did that and force push) then those commits will become part of this pull request, which can then be merged.

Anyway, I got it working (with a bunch of testing done in relative privacy of my own fork).
This is a bit simpler than the workaround hack I linked to (and that you started in #2502).

@rwest rwest requested a review from JacksonBurns July 22, 2023 04:17
(When I was debugging, I had a special workflow to test it more quickly)
Copy link
Copy Markdown
Contributor

@JacksonBurns JacksonBurns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice and succinct, well done. LGTM

@rwest rwest merged commit 4ee1e71 into ReactionMechanismGenerator:main Jul 22, 2023
@rwest rwest deleted the regressiontests branch July 22, 2023 13:14
@rwest
Copy link
Copy Markdown
Member Author

rwest commented Jul 22, 2023

Dammit. Is $PR_NUMBER defined in the CI workflow?

@rwest
Copy link
Copy Markdown
Member Author

rwest commented Jul 23, 2023

The "Continuous Integration" workflow runs on a push to master (eg merging a PR) and on a cron job, both of which will trigger the Annotation workflow, but neither of which will have uploaded a regression test summary file, so the Annotation workflow will fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants