From 8c78dd14deb4d68343b113ec33028670ffd3c74b Mon Sep 17 00:00:00 2001 From: roye2 <07eeroy@gmail.com> Date: Wed, 29 Jul 2026 12:16:26 -0400 Subject: [PATCH 1/4] update with usage instructions for submitty_test now that it uses docker --- .../testing/linting_static_analysis.md | 95 +++++++++++++++---- 1 file changed, 79 insertions(+), 16 deletions(-) diff --git a/_docs/developer/testing/linting_static_analysis.md b/_docs/developer/testing/linting_static_analysis.md index 47fa50e9..a21c08ba 100644 --- a/_docs/developer/testing/linting_static_analysis.md +++ b/_docs/developer/testing/linting_static_analysis.md @@ -97,40 +97,79 @@ If you fix one of these errors, you would need to regenerate this file which can php vendor/bin/phpstan analyze app public/index.php socket/index.php --generate-baseline --memory-limit 2G ``` The argument `--memory_limit 2G` is necessary when phpstan will otherwise not have enough memory -to generate a new baseline. You can see how much memory phpstan has been using with the `-v` flag +to generate a new baseline. You can see how much memory phpstan has been using with the `-v` flag. -# Submitty Test Script for PHP Linting +--- + +# Submitty Test Script The `submitty_test` script is an alias for the `SUBMITTY_TEST.sh` script, similar to `submitty_install_site`. -This script streamlines the process of PHP linting by performing the following steps: +This script streamlines the process of linting and testing by performing the following steps: -1. Changes the directory to `GIT_CHECKOUT/Submitty/site`. -2. Installs Composer if not already installed (skips if Composer is already installed). -3. Executes the specified PHP linting command. -4. Returns to the original directory. +1. Builds a Docker image containing all the necessary linting/testing tools. +2. Runs the specified command inside a container, with the root of the Submitty repository mounted. -## Commands: +***Note:** The first time you run the script, the Docker container will take anywhere from 5 to 10 minutes to build. +Subsequent runs of the script (and therefore builds), using Docker's cached build layers, should only take seconds.* + +## Running Locally (Outside the VM) + +The script can also be run directly on your host machine instead of inside the Vagrant VM, provided you have Docker installed. +This is useful if you're frequently running `vagrant destroy` and `vagrant up`, since the Docker image and its cached build state +will then live on your host rather than inside the VM, and you won't need to wait for a long Docker build as often. + +Run the script locally from the root of your cloned Submitty repository: +```bash +./.setup/SUBMITTY_TEST.sh [options] +``` -- `phpcs`: Runs PHP CodeSniffer. -- `phpstan`: Runs PHP static analysis. -- `php-lint`: Runs both PHP CodeSniffer and PHPStan. +On Windows, you may need to install Bash, then run the script like this: +```bash +bash .setup/SUBMITTY_TEST.sh [options] +``` + +## Commands: +- `phpcs`: Runs PHP CodeSniffer. [option: `--fix`] +- `phpstan`: Runs PHP static analysis. [option: `--memory-limit <#>G`, `--generate-baseline`] +- `php-lint`: Runs both PHP CodeSniffer and PHPStan (default options only). +- `php-unit`: Runs PHP unit tests. [option: `--filter testFunctionName`, `--debug`] +- `js-lint`: Runs eslint. [option: `--fix`] +- `css-lint`: Runs stylelint. [option: `--fix`] +- `py-flake8`: Runs flake8. [option: `/path/to/specific_file.py`] +- `py-pylint`: Runs pylint. [option: `/path/to/specific_file.py`] +- `py-lint`: Runs pylint & flake8. [option: `/path/to/specific_file.py`] +- `py-unit`: Runs all Python unit tests except `migration`. +- `py-unit-utils` / `py-unit-migration` / `py-unit-autograder` / `py-unit-daemon`: Runs the respective Python unit test suite. [option: module, class, function ...] ## Additional Arguments: -The `submitty_test` script accepts additional arguments, such as `--memory_limit 2G`. +The `submitty_test` script accepts additional arguments, such as `--memory-limit 2G` or `--fix`. Seen above are the additional arguments usable for each command. -## Example Usage: +## PHP Linting: -``` +```bash submitty_test php-lint --memory-limit 2G +submitty_test phpcs --fix +submitty_test phpstan ``` +## PHP Unit Testing: + +```bash +submitty_test php-unit +submitty_test php-unit --filter testFunctionName +submitty_test php-unit --debug +``` + +See also: [PHP Unit Tests](/developer/testing/php_unit_tests) + ## JavaScript Linting -The frontend JavaScript code Submitty uses is linted using [eslint](https://eslint.org/). As with the PHP linter, `submitty_test` can be used as an alias for the `SUBMITTY_TEST.sh` script. +The frontend JavaScript code Submitty uses is linted using [eslint](https://eslint.org/). As with other languages, `submitty_test` can be used as an alias for the `SUBMITTY_TEST.sh` script. ```bash submitty_test js-lint +submitty_test js-lint --fix ``` Alternatively, you can run eslint on your host system or on vagrant by navigating into the `site/` @@ -157,10 +196,11 @@ See also: [JavaScript Style Guide](/developer/coding_style_guide/javascript) ## CSS Linting -CSS is linted using [stylelint](https://stylelint.io/) in Submitty to enforce a consistent code style. As with the PHP linter, `submitty_test` can be used as an alias for the `SUBMITTY_TEST.sh` script. +CSS is linted using [stylelint](https://stylelint.io/) in Submitty to enforce a consistent code style. As with other languages, `submitty_test` can be used as an alias for the `SUBMITTY_TEST.sh` script. ```bash submitty_test css-lint +submitty_test css-lint --fix ``` Alternatively, you can run stylelint on your host system or on vagrant by navigating into the `site/` @@ -177,3 +217,26 @@ npm run css-stylelint:fix ``` See also: [CSS Style Guide](/developer/coding_style_guide/css) + +## Python Linting + +Python is linted using [flake8](https://flake8.pycqa.org/en/latest/) and [pylint](https://pylint.readthedocs.io/en/stable/) in Submitty. As with other languages, `submitty_test` can be used as an alias for the `SUBMITTY_TEST.sh` script. + +```bash +submitty_test py-lint # option: /path/to/specific_file.py +submitty_test py-flake8 # option: /path/to/specific_file.py +submitty_test py-pylint # option: /path/to/specific_file.py +``` + +See also: [Python Style Guide](/developer/coding_style_guide/python) + +## Python Unit Testing + +```bash +submitty_test py-unit # runs all unit tests except migration +submitty_test py-unit-utils # option: module, class, function ... +submitty_test py-unit-migration # option: module, class, function ... +submitty_test py-unit-autograder # option: module, class, function ... +submitty_test py-unit-daemon # option: module, class, function ... +``` +See also: [Python Unit Tests](/developer/testing/python_unit_tests) From e522bed938c6b2f3a54bc145ebc2aba71c228eb9 Mon Sep 17 00:00:00 2001 From: roye2 <07eeroy@gmail.com> Date: Wed, 29 Jul 2026 12:57:56 -0400 Subject: [PATCH 2/4] add link to install docker locally --- _docs/developer/testing/linting_static_analysis.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_docs/developer/testing/linting_static_analysis.md b/_docs/developer/testing/linting_static_analysis.md index a21c08ba..2a996870 100644 --- a/_docs/developer/testing/linting_static_analysis.md +++ b/_docs/developer/testing/linting_static_analysis.md @@ -109,7 +109,7 @@ This script streamlines the process of linting and testing by performing the fol 1. Builds a Docker image containing all the necessary linting/testing tools. 2. Runs the specified command inside a container, with the root of the Submitty repository mounted. -***Note:** The first time you run the script, the Docker container will take anywhere from 5 to 10 minutes to build. +***NOTE:** The first time you run the script, the Docker container will take anywhere from 5 to 10 minutes to build. Subsequent runs of the script (and therefore builds), using Docker's cached build layers, should only take seconds.* ## Running Locally (Outside the VM) @@ -127,6 +127,7 @@ On Windows, you may need to install Bash, then run the script like this: ```bash bash .setup/SUBMITTY_TEST.sh [options] ``` +***NOTE:** The instructions for installing Docker on your host machine can be found here: [Docker Docs/Get Started/Get Docker](https://docs.docker.com/get-started/get-docker/)* ## Commands: - `phpcs`: Runs PHP CodeSniffer. [option: `--fix`] From 6feef3bbedea630e104f914676537d088d9a0f9a Mon Sep 17 00:00:00 2001 From: Emma Roy <07eeroy@gmail.com> Date: Wed, 29 Jul 2026 13:34:52 -0400 Subject: [PATCH 3/4] use \ instead of / for windows instructions --- _docs/developer/testing/linting_static_analysis.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_docs/developer/testing/linting_static_analysis.md b/_docs/developer/testing/linting_static_analysis.md index 2a996870..55e3ee1c 100644 --- a/_docs/developer/testing/linting_static_analysis.md +++ b/_docs/developer/testing/linting_static_analysis.md @@ -125,7 +125,7 @@ Run the script locally from the root of your cloned Submitty repository: On Windows, you may need to install Bash, then run the script like this: ```bash -bash .setup/SUBMITTY_TEST.sh [options] +bash .setup\SUBMITTY_TEST.sh [options] ``` ***NOTE:** The instructions for installing Docker on your host machine can be found here: [Docker Docs/Get Started/Get Docker](https://docs.docker.com/get-started/get-docker/)* From 8091095fe0bdf4a5e646d4da5bfdba36ad732fbb Mon Sep 17 00:00:00 2001 From: Emma Roy <07eeroy@gmail.com> Date: Wed, 29 Jul 2026 15:07:49 -0400 Subject: [PATCH 4/4] revert \ --- _docs/developer/testing/linting_static_analysis.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_docs/developer/testing/linting_static_analysis.md b/_docs/developer/testing/linting_static_analysis.md index 55e3ee1c..2a996870 100644 --- a/_docs/developer/testing/linting_static_analysis.md +++ b/_docs/developer/testing/linting_static_analysis.md @@ -125,7 +125,7 @@ Run the script locally from the root of your cloned Submitty repository: On Windows, you may need to install Bash, then run the script like this: ```bash -bash .setup\SUBMITTY_TEST.sh [options] +bash .setup/SUBMITTY_TEST.sh [options] ``` ***NOTE:** The instructions for installing Docker on your host machine can be found here: [Docker Docs/Get Started/Get Docker](https://docs.docker.com/get-started/get-docker/)*