-
Notifications
You must be signed in to change notification settings - Fork 77
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
Add tests for static_react_task example #795
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
b116336
✅ Added passing tests for static_react_task
Etesam913 a091438
🔥 Removed the starter test
Etesam913 379c9e9
🔧 Configured github actions for cypress
Etesam913 481433f
✏️ Added correct extension to workflow
Etesam913 8bcd15c
🔥 Removed extraneous code from cypress folder
Etesam913 ee4d978
📝 Added info on cypress testing to contributing.md
Etesam913 0aee860
🐛 Fixed request_agent test being inconsistent
Etesam913 7bc4f1b
✨ Added ability to link packages from command line
Etesam913 9ee7203
Merge branch 'main' of https://github.com/facebookresearch/Mephisto i…
Etesam913 ac59bbd
✨ Added command line arg to other examples
Etesam913 3c392a5
⛓ Updated github action to link to mephisto-task
Etesam913 113b8a8
✏️ Renamed the test
Etesam913 b944d78
🎨 Added spacing
Etesam913 a5cc65f
🔥 Delete commented out file
Etesam913 2e989e9
⏮ Reverting test back
Etesam913 f904089
🔥 Removed defineConfig from cypressConfig
Etesam913 721b4e6
🔀 Pulled from origin
Etesam913 0fc65a1
🐛 Fixed syntax bug
Etesam913 5702d9e
🔧 Updated hydra config to accept two new parameters
Etesam913 41cc544
📝 Added post_build_script to cypress start action
Etesam913 6b40eed
✏️ Updated contributing to two new sections
Etesam913 d5e846d
📦 Moved troubleshooting section
Etesam913 eb27dc9
✏️ Fixed typo in CONTRIBUTING.md
Etesam913 00e0023
✅ Simplified the tests for alerts
Etesam913 35b3f28
🔥 Removed extraneous code
Etesam913 d34a2ef
✏️ Added testing section to readme of task
Etesam913 e1393b9
✏️ Fixed typos in task_run fields
Etesam913 14beded
✏️ Renamed post_build_script field
Etesam913 db879d5
✏️ Replaced all occurrences of post_build_script
Etesam913 28c8431
🥅 Update build_bundle to work with no run_config
Etesam913 ff7ae27
🔥 Removed two properties from hydra_config
Etesam913 cd3a36c
🚨 Removed parameter warnings as they were too noisy
Etesam913 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: cypress-end-to-end-tests | ||
on: | ||
pull_request: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
static-react-task: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 🔀 Checking out repo | ||
uses: actions/checkout@v2 | ||
- name: 🐍 Installing python | ||
uses: actions/setup-python@v2 | ||
|
||
- name: 🪨 Setup Node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 16 | ||
|
||
- name: 🤖 Install Mephisto | ||
run: pip install -e . | ||
|
||
- name: 🖋 Create data directory | ||
run: | | ||
cd ~ | ||
mkdir mephisto | ||
cd mephisto | ||
mkdir data | ||
|
||
- name: 📂 Set the data directory | ||
run: | | ||
mephisto config core.main_data_directory ~/mephisto/data | ||
|
||
- name: 📦 Setting up mephisto-task package | ||
run: | | ||
cd packages/mephisto-task | ||
yarn install | ||
yarn build | ||
npm link | ||
|
||
- name: ⌛️ Running cypress tests | ||
uses: cypress-io/[email protected] | ||
with: | ||
install: false | ||
project: ./examples/static_react_task/webapp | ||
config-file: ./cypress.config.js | ||
start: python examples/static_react_task/run_task.py mephisto.task.post_install_script=link_mephisto_task.sh | ||
wait-on: "http://localhost:3000/?worker_id=x&assignment_id=1" | ||
command-prefix: yarn dlx | ||
headless: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,49 @@ We actively welcome your pull requests. | |
5. Make sure your code lints. | ||
6. If you haven't already, complete the Contributor License Agreement ("CLA"). | ||
|
||
### Task Contributions | ||
## Cypress Testing | ||
For cypress testing the base url is: http://localhost:3000/?worker_id=x&assignment_id=1 | ||
|
||
### Running end to end tests on a task: | ||
1. Run the task by running python run_task.py in the appropriate task folder | ||
2. In a separate terminal window go into the webapp directory and run `npm run test` | ||
3. This should open a cypress app | ||
4. It is advised to test in Chrome(Chrome, Electron, and Firefox are all the options) as this browser works well with Cypress. | ||
5. After clicking one of the spec files, the tests from that spec will automatically run | ||
|
||
### Troubleshooting: | ||
### There may be a case where there is a baseUrl mismatch. | ||
|
||
For example: | ||
Suppose you ran the toxicity detection task and then closed it. This would use assignmentId=1 and assignmentId=2. | ||
|
||
If you then ran the mnist task, for example, then assignmentId=3 and assignmentId=4 would be used. While this task is running you can choose to run cypress tests in a different terminal window by going into the webapp folder and running `npm run test`. | ||
|
||
These tests will fail because the base url of http://localhost:3000/?worker_id=x&assignment_id=1 is not associated with the mnist task, it is associated with the toxicity detection task. The correct react-elements will not show up. | ||
|
||
There is a way to fix this: | ||
* You can change the base url(found in the cypress.config.js file in the webapp folder) to the current url that you are on. | ||
* Make sure to reset the baseUrl back to default("/") if contributing to the repo as the GitHub action will fail otherwise. | ||
|
||
## Local Package Development | ||
If you are modifying either the `mephisto-task` or `mephisto-worker-experience` packages you probably want to see your changes propagate to the task that you are working on. | ||
|
||
The easiest way to do this is to run a task by doing: | ||
```bash | ||
python run_task.py mephisto.task.post_install_script=link_mephisto_task.sh mephisto.task.force_rebuild=true | ||
``` | ||
|
||
Setting `mephisto.task.force_rebuild=true` runs `npm build` before running your task. By default the task is only rebuilt if a file is changed in the webapp, not if a linked package is changed. | ||
|
||
Setting `mephisto.task.post_install_script=link_mephisto_task.sh` runs the `link_mephisto_task.sh` script after `npm install` is ran and before the task is started. This script should be located in the webapp folder of the task. While this script can do many things, for local package development the primary purpose of it is to link to a local package. | ||
Comment on lines
+49
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a note - we can probably get these to automatically trigger as part of the test suite when any file in |
||
|
||
Alternatively, these values can be set in the task's hydra_configs/conf yaml file if you want to forgo typing the above and just type | ||
```bash | ||
python run_task.py | ||
``` | ||
instead. | ||
|
||
## Task Contributions | ||
Generally we encourage people to provide their own blueprints as part of the repo in which they release their code, though if someone creates a strong case for an abstract `Blueprint` that is generally applicable we'd be happy to review it. | ||
|
||
## Contributor License Agreement ("CLA") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#795 (comment)
I think I am already doing that in this github action (the start field)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed - missed that on first pass!