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

Upload Simpletest Results as an Artifact in GHA #6458

Closed
quicksketch opened this issue Apr 19, 2024 · 12 comments · Fixed by backdrop/backdrop#4730
Closed

Upload Simpletest Results as an Artifact in GHA #6458

quicksketch opened this issue Apr 19, 2024 · 12 comments · Fixed by backdrop/backdrop#4730

Comments

@quicksketch
Copy link
Member

Description of the need

Debugging test failures in GitHub Actions is often difficult, because you can't see what is happening like you can when running tests locally through the UI. In particular, the contents of HTML pages that are loaded (and verbose messages) are helpful in that it shows you what the HTML browser sees while executing the test.

Proposed solution

We could make things more transparent as to what's happening in our GitHub Action test runs by uploading the verbose output as an artifact and attaching it to the test runs.

Alternatives that have been considered

I usually run tests locally when there is a failure, but occasionally there is an error that happens only on GitHub (like we've been experiencing with #2277).

Additional information

This can be achieved by adding this to the bottom of our test YML files:

      - name: Save Test Results
        uses: actions/upload-artifact@v4
        if: always()
        with:
          name: simpletest-output
          path: files/simpletest
@argiepiano
Copy link

I love this! +1

@argiepiano
Copy link

FWIW I added these lines to the GHA test for backup_migrate and they worked great. Thanks!

@quicksketch
Copy link
Member Author

PR filed at backdrop/backdrop#4730 that enables saving the SimpleTest output as artifacts in both the regular and database-config tests.

@quicksketch
Copy link
Member Author

To test:

  • Open the PR.
  • Click on any test run for simpletest.
  • Expand the test result section labeled "Save Test Results"
  • Click the link inside this section, as shown below:
    image
  • Open the downloaded archive and verify it contains test run contents. It will be the HTML output of every test that was run.

@argiepiano
Copy link

LGTM. I don't know much about GHA so I can't do a code review.

@klonos
Copy link
Member

klonos commented May 4, 2024

Code looks good to me 👍🏼 ...if I can make a suggestion, that would be to add the PR number as a prefix to the artifact files + a timestamp as a suffix. Otherwise, assuming that people will be downloading these locally to extract and investigate/troubleshoot, it would be annoying to have the operating system naming the downloaded files with (1) (2) or whatever suffix, and then having to figure out which one is for which PR and if it was before or after a specific commit.

Other than that, lets please get this in! 🙂

@quicksketch
Copy link
Member Author

Finding the pull request number is apparently difficult, because tests can run on things other than just pull requests. Big long thread on that here: actions/checkout#58

@klonos
Copy link
Member

klonos commented May 4, 2024

...from a quick research, I believe that ${{ github.event.number }} should work for the PR number.

@klonos
Copy link
Member

klonos commented May 4, 2024

...and https://stackoverflow.com/questions/60942067/get-current-date-and-time-in-github-workflows has an example on how to get the date from a GHA step.

But I don't want to derail this. I'm happy to get it in as is.

@quicksketch
Copy link
Member Author

Thanks, yeah I started looking into it and just realized it's messier than you'd think. The current approach works and (hopefully) downloading artifacts will be a rare need; usually only when we're dealing with GHA-specific issues.

I merged backdrop/backdrop#4730 into 1.x only, since the testing framework was reworked quite a bit in #2277, which is 1.28.0 and higher.

@klonos
Copy link
Member

klonos commented May 4, 2024

...realized it's messier than you'd think.

I don't know about that. Seems pretty simple to me, and it works: backdrop/backdrop#4731

Feel free to close the follow-up PR if you don't agree.

@klonos klonos reopened this May 4, 2024
@quicksketch
Copy link
Member Author

With how rare (hopefully) downloading simpletest results is; this only affecting developers; only certain browser situations; and the addition of event number potentially causing problems when running tests outside of PRs, I think I'd like to be able to just close this for 1.28.0. Thank you for filing it and we can revisit if we find it to be actually problematic.

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