syntax-prosody-ot / main

A webapp for the syntax-prosody analyst working in Optimality Theory, with automated Gen, Con and Eval. Download build files from syntax-prosody-ot/build
https://spot.sites.ucsc.edu/
GNU General Public License v2.0
12 stars 2 forks source link

auto testing by Github #547

Closed jbellik closed 3 years ago

jbellik commented 3 years ago

Goal: To take advantage of Github's "Actions" to automatically run various tests whenever a pull request comes in.

To do this, we need all the (relevant) Mocha tests to be in .js files by themselves.

jbellik commented 3 years ago

Sub tasks:

jbellik commented 3 years ago

First step would be to try pulling the Mocha code/script out of one of the existing automated test files and adding a line to the workflow that runs it

sz245 commented 3 years ago

When pulling mocha tests out of existing html into .js files, do you mean find a command that does that or change the test files manually like with the interface test files or either or?

jbellik commented 3 years ago

As a first step, let's take the mocha tests out manually from one html file. That will give us a .js file, let's call it test1.js, that (I hope) can be used both in the html file and in the Github action (in the yml file). Then try adding a line to the .yml file that runs test1.js.

sz245 commented 3 years ago

start with stringTest.js

sz245 commented 3 years ago

branch github

jbellik commented 3 years ago

Since stringTest.js is using the interface, let's actually start with extracting the script from binarityTest.html into binarityTest.js.

jbellik commented 3 years ago

Possibly we also need to install chai in the yml script.

jbellik commented 3 years ago

mocha.setup("bdd"); //brings "describe", "it", etc. into global namespace //mocha.checkLeaks(); var assert = chai.assert;

Ultimately these lines also need to get into the yml or into the compiled test.js file, but for now, just grab them along with the rest of the binarity tests and put them at the top of binarityTest.js.

sz245 commented 3 years ago

It seems that I need to first merge my code with master branch to be able to test it in github actions. Is there another way to test it first without merging?

sz245 commented 3 years ago

https://gist.github.com/soheilhy/867f76feea7cab4f8a84 https://www.freecodecamp.org/news/what-are-github-actions-and-how-can-you-automate-tests-and-slack-notifications/ https://docs.github.com/en/actions https://github.com/actions/checkout/blob/main/.github/workflows/test.yml https://stackoverflow.com/questions/9722407/how-do-you-install-and-run-mocha-the-node-js-testing-module-getting-mocha-co https://itnext.io/getting-started-with-github-actions-fe94167dbc6d

jbellik commented 3 years ago

Some general info on using Mocha in the terminal:

jbellik commented 3 years ago

Largely addressed by #567 Running mocha in the console requires installing node. If you have node installed on your local machine, and have pulled package.json into your local repository, you can check whether all the tests in main/test/compiledTest/test.js are passing: Step 1: From main, run ./mochabuild.sh. (NB I have not written a .bat version of this build script!) This will create test.js in the directory main/test/compiledTest. Step 2: Also from main, run npm test, which will evaluate the 400+ tests in test.js and output results to the command line. But Github will also run all those tests for you when you set up a pull request to master, if you don't want to set node up locally. I did add node_modules to the .gitignore file so they don't end up in the repository.

Remaining tasks to finish setting up Github's auto testing:

jbellik commented 3 years ago

@M130 Could you work on this some more? Take a look at the post just above this and let me know if you have questions. Basically you can test it all locally if you install node; I set up the package.json file and changed the .gitignore to ignore the node files, so it won't mess up the repository even if you put it in your local repository folder.

I'm thinking it should be pretty easy to deal with the rest of the test files (listed in the post above) and you could probably manage that before Wednesday. But you'll need to update the .bat files to test it, if I'm remembering correctly that you're on a Windows machine.