medusa-project / book-tracker

Medusa Book Tracker
0 stars 0 forks source link

Get tests working in GitHub Actions #4

Closed adolski closed 1 year ago

adolski commented 1 year ago

GitHub Actions doesn't require the use of Docker, but I think it's more convenient to get the tests working in a container. That way we can run the container theoretically anywhere (locally or in GitHub Actions CI) and it will work the same way. Otherwise we would have to set up the GHA environment manually (installing all dependencies etc.).

I did a Mind Meld presentation on GitHub Actions in May: https://uofi.box.com/s/4td1oa43g5s9syxjplork9xw3lerk5kp

gaurijo commented 1 year ago

@adolski Is there anything in particular I should be aware of before looking into this? (First time using GitHub Actions)

For example, do I need to set up a specific workflow, or can I get started with the Ruby on Rails configuration that GitHub Actions has out the box?

Image

adolski commented 1 year ago

Before starting on this, I would start on #23 (which I just created and I will add some description to soon). Once the tests are working in Docker, it will be easy to set up GitHub Actions to run the tests that way.

adolski commented 1 year ago

The file(s) that "turn on" GitHub Actions are the YAML files in .github/workflows. The Book Tracker doesn't have one yet so you'll have to create it. Here is the one used by IDEALS, which should be almost the same for Book Tracker.

gaurijo commented 1 year ago

From my understanding, I can create the necessary YAML file(s) inside .github/workflows, commit it directly to develop branch, and GitHub Actions will automatically run that workflow. Is that correct? I'm not sure if I should start a new branch with a new PR for this, but certainly can do that if preferred.

adolski commented 1 year ago

GitHub Actions works per-branch, so it will work on any branch in which those files are present. Once it's set up (on any branch) you'll see stuff happening in the actions tab above.

I think it's fine to commit straight to develop.

gaurijo commented 1 year ago

Perfect, thanks. I've got the workflow running in there. However I'm realizing it will always fail because we've kept those two User model tests in there:

UserTest#test_medusa_admin?_returns_false_for_non-medusa_admins

and

UserTest#test_medusa_admin?_returns_true_for_medusa_admins

I can go ahead and skip or comment out those two tests and push up again if it's still fine to not include those.

adolski commented 1 year ago

Yes, please just go ahead and skip them.

gaurijo commented 1 year ago

Skipped those tests and Github Actions workflow now runs successfully