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

feat: add tests to django example #42

Merged
merged 40 commits into from
Aug 17, 2022
Merged

feat: add tests to django example #42

merged 40 commits into from
Aug 17, 2022

Conversation

vinckr
Copy link
Member

@vinckr vinckr commented Jul 25, 2022

Add automated tests to the django example. The same template should then be usable for the other examples.

fyi @kevgo should we also add text-runner in this PR? it would check that all commands are correct right?

Related Issue or Design Document

Checklist

  • I have read the contributing guidelines and signed the CLA.
  • I have referenced an issue containing the design document if my change introduces a new feature.
  • I have read the security policy.
  • I confirm that this pull request does not address a security vulnerability. If this pull request addresses a security
    vulnerability, I confirm that I got green light (please contact security@ory.sh) from the
    maintainers to push the changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation within the code base (if appropriate).

Further comments

Copy link
Contributor

@kevgo kevgo left a comment

Choose a reason for hiding this comment

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

We spoke about adding Text-Runner to this repo a while ago and I still have a backlog item for it. Will do this after I'm done implementing the licensing tickets. It likely won't happen in this PR because this PR contains no Markdown files, and I prefer that each PR does only one thing.

playwright.config.ts Outdated Show resolved Hide resolved
playwright.config.ts Outdated Show resolved Hide resolved
@vinckr vinckr marked this pull request as ready for review July 27, 2022 10:57
@vinckr vinckr requested a review from kevgo July 27, 2022 10:57
@vinckr
Copy link
Member Author

vinckr commented Jul 27, 2022

Test is passing 🎉
Can you take a look maybe @kevgo ?

Copy link
Contributor

@kevgo kevgo left a comment

Choose a reason for hiding this comment

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

Sorry for the late review, this one slipped through my notification system. Very cool that you work on this! This is the first code review with me so naturally I have a lot of comments. Don't worry about that, this is totally normal. Just go through each comment and either apply it or come up with a good rationale for keeping your version. Both are equally okay with me, code reviews are intended to be helpful, not dominating.

Once you are through all comments, please move all the files that you have created in the root directory into the django-ory-cloud directory. You are writing an automated test for that app, and tests should live in the same folder as the app they test.

I suggest moving one file at a time, then updating the references to it, then checking that things still work, then committing this. That way, if you mess something up, you can easily go back to the latest working state.

When you have time, we can pair up and go through a few things and concepts together or even do some pair programming.

.github/workflows/playwright.yml Outdated Show resolved Hide resolved
.github/workflows/playwright.yml Outdated Show resolved Hide resolved
.github/workflows/playwright.yml Outdated Show resolved Hide resolved
.github/workflows/playwright.yml Outdated Show resolved Hide resolved
.github/workflows/playwright.yml Outdated Show resolved Hide resolved
playwright.config.ts Outdated Show resolved Hide resolved
tests/playwright/django-ory-cloud.spec.ts Outdated Show resolved Hide resolved
tests/playwright/django-ory-cloud.spec.ts Outdated Show resolved Hide resolved
tests/playwright/django-ory-cloud.spec.ts Outdated Show resolved Hide resolved
tests/playwright/helpers.ts Outdated Show resolved Hide resolved
@kevgo
Copy link
Contributor

kevgo commented Aug 3, 2022

And yes, I will focus on adding Text-Runner here and elsewhere very soon. I was tinkering all weekend on Text-Runner to update it!

@vinckr
Copy link
Member Author

vinckr commented Aug 9, 2022

Thanks for your review Kevin, really appreciate the detail!
I did not have time to look into it, but will do so now (and probably tomorrow 😁)

Good point about moving the test into the directory. I went by how it is in the ory/docs repo (https://github.com/ory/docs/tree/master/tests) but in this repo it probably makes more sense to have it in the app dir (not sure why it is this way in /docs, maybe to make the CI easier).

Another thing I am not 100% sure of is if we should run all tests for all examples in one workflow or if we should make a dedicated workflow for each example.
If we have only one workflow, its quite a long test (like in ory/docs).
If we have one workflow for each example we have a lot of workflows over time.
Intuitively I am leaning towards the second option, wdyt?

@kevgo
Copy link
Contributor

kevgo commented Aug 9, 2022

The repo ory/docs contains a single codebase. It has a src folder containing the source code and a tests folder containing the tests. That makes sense.

The repo here (ory/examples) is a monorepo. It contains many different codebases (the various example apps). Each code base (example app) is pretty independent of each other. They are in different programming languages (Go, Python, TypeScript) and are run separately from each other. Each codebase (example app) in this repo should have its own src and tests folder.

So, long story short, please move the tests for the Django example into a django-ory-cloud/tests folder (after you apply my comments and suggestions).

Good question around how we set up testing. I think your second option makes more sense, especially given the fact that each codebase uses a different technology and therefore might need a different docker image to run.

We can also do your first option (test all codebases in one workflow), with the performance optimization that we only run the test of codebases that are being changed in that PR. I.e. don't run tests for codebases that don't get changed in a PR. This should keep that workflow short.

Copy link
Contributor

@kevgo kevgo left a comment

Choose a reason for hiding this comment

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

Good progress so far! Please let me know if you want me to help implementing some of the suggestions I made.

.github/workflows/playwright.yml Outdated Show resolved Hide resolved
@vinckr
Copy link
Member Author

vinckr commented Aug 11, 2022

Thanks - lots of other topics this week but will try to finish it by EOW.
If you have bandwidth, I also appreciate the help :-)

@vinckr vinckr force-pushed the tests branch 3 times, most recently from 1cff1a6 to 47dce3d Compare August 11, 2022 17:29
@vinckr
Copy link
Member Author

vinckr commented Aug 12, 2022

Makes sense! I wanna start with the next test next week.
I renamed this one to E2E Tests for django-ory-cloud and then we have a .yml for each.
If we can run everything as part of the official test suite that would be good, but we should make sure to prevent that a broken community example doesn't block updates in /docs.

I also added you as maintainer here, but we could also add you to the ory mod team, then you have access to moderate all discussions as well.

@vinckr
Copy link
Member Author

vinckr commented Aug 12, 2022

Everything but two points is resolved 🙏

kevgo
kevgo previously approved these changes Aug 12, 2022
Copy link
Contributor

@kevgo kevgo left a comment

Choose a reason for hiding this comment

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

Great work! This is coming along nicely! The last open item from my end are the commented out tests. Do you have plans to make them run?

django-ory-cloud/Makefile Outdated Show resolved Hide resolved
django-ory-cloud/playwright.config.ts Outdated Show resolved Hide resolved
django-ory-cloud/test.sh Outdated Show resolved Hide resolved
django-ory-cloud/tests/playwright/django-ory-cloud.spec.ts Outdated Show resolved Hide resolved
django-ory-cloud/tests/playwright/django-ory-cloud.spec.ts Outdated Show resolved Hide resolved
django-ory-cloud/tests/playwright/django-ory-cloud.spec.ts Outdated Show resolved Hide resolved
django-ory-cloud/tests/playwright/django-ory-cloud.spec.ts Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
vinckr and others added 4 commits August 17, 2022 21:19
@vinckr vinckr requested a review from kevgo August 17, 2022 20:04
kevgo
kevgo previously approved these changes Aug 17, 2022
Copy link
Contributor

@kevgo kevgo left a comment

Choose a reason for hiding this comment

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

The finish line is in sight! This is ready to go after the last few comments are addressed. Really good work Vincent!

.github/workflows/django-ory-cloud.yml Outdated Show resolved Hide resolved
.github/workflows/django-ory-cloud.yml Outdated Show resolved Hide resolved
django-ory-cloud/Makefile Outdated Show resolved Hide resolved
django-ory-cloud/Makefile Outdated Show resolved Hide resolved
django-ory-cloud/playwright.config.ts Outdated Show resolved Hide resolved
django-ory-cloud/test.sh Outdated Show resolved Hide resolved
playwright.config.ts Outdated Show resolved Hide resolved
@vinckr
Copy link
Member Author

vinckr commented Aug 17, 2022

Alright added the last changes, thanks for the patience and reviews 🙏
Maybe we can make this a template that you just get with a new example?
make example and it creates a bunch of template files for README/playwright (and possibly more?)

Copy link
Contributor

@kevgo kevgo left a comment

Choose a reason for hiding this comment

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

Very cool, ship it!

@vinckr vinckr merged commit d8bca0e into master Aug 17, 2022
@kevgo
Copy link
Contributor

kevgo commented Aug 17, 2022

Maybe we can make this a template that you just get with a new example?

I propose we do a few examples and then see how much overlap there is between them. If it's just a few files (readme, playwright config), it might be easier to just copy-and-paste an existing example when one creates a new one.

@kevgo kevgo deleted the tests branch August 17, 2022 23:18
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