- Preparing your machine
- Environment Setup
- Configuring IDE
- Running Tests
- Running mssql-scripter
- Packaging
See the Architecture Guide for details on how mssql-scripter is designed and implemented.
mssql-scripter sources are located on GitHub (https://github.com/Microsoft/mssql-scripter). In order to contribute to the project, you are expected to:
- Have a GitHub account. For Microsoft contributors, follow the guidelines on https://opensourcehub.microsoft.com/ to create, configure and link your account
- Fork the https://github.com/Microsoft/mssql-scripterrepository into your private GitHub account
- Create pull requests against the https://github.com/Microsoft/mssql-scripter repository to get your code changes merged into the project repository.
-
Install latest Python from http://python.org. Please note that the version of Python that comes preinstalled on OSX is 2.7. It is recommended to install both Python 2.7 and Python3.6 to ensure backwards compatibility for testing.
- The latest Python installation package can be downloaded from here.
- During installation, select the 'Add Python to PATH' option. Python must be in the PATH environment variable.
-
Clone the repo from https://github.com/Microsoft/mssql-scripter
When developing on a Python project, it is recommended to do so in a virtual environment. A virtual environment is a sandbox that maintains a copy of all libraries necessary to run python in a isolated environment without interfering with the system or global python. For more information on virtual environments, go to Virtual Environment Info.
If not developing in a virtual environment, please proceed to Development Setup
-
Create a virtual environment in a subdirectory of your
<clone_root>
, using<clone_root>/env
as a example:python -m venv <clone_root>\env
python –m venv <clone_root>/env
-
Activate the env virtual environment by running:
<clone_root>\env\scripts\activate.bat
. <clone_root>/env/bin/activate
-
To deactivate the virtual environment:
<clone_root>\env\scripts\deactivate.bat
deactivate
General development steps that apply to both a virtual environment or a global environment. If working in a virtual environment, do ensure the virtual environment is activated.
-
Add
<clone_root>
to your PYTHONPATH environment variable:set PYTHONPATH=<clone_root>;%PYTHONPATH%
export PYTHONPATH=<clone_root>:${PYTHONPATH}
-
Install the dependencies:
python <clone_root>/dev_setup.py clean
- Install Python Tools for Visual Studio
- Open the
<clone_root>\mssql-scripter.pyproj
project in Visual Studio
- Install VS Code
- Install the the VS Code Python extension
The repo has a launch.json file that will launch the version of Python that is first on your path.
Provided your PYTHONPATH was set correctly, you can run the tests from your <clone_root>
directory.
-
Run end to end tests (code format, unit tests, packaging, integration,) with tox:
tox
Note: Tox is used run full suite of tests in each python version. Running the command above will run the full suite of tests against Python 2.7 and Python 3.6, if installed. More info can be found at tox testing.
Run tox tests against specific Python version:
tox -e py27 tox -e py36
Recommended: Recreate virtual environment on each run to ensure tests are not executing against cached changes.
tox --recreate -e py27 tox --recreate -e py36
-
Run unit tests with code coverage only:
pytest --cov mssqlscripter
-
Running tests for specific components:
To test the mssqlscripter:
pytest mssqlscripter/tests
To test the jsonrpc library:
pytest mssqlscripter/jsonrpc/tests
To test the scripting service:
pytest mssqlscripter/jsonrpc/contracts/tests
-
Invoke mssql-scripter using:
mssql-scripter -h
<clone_root>\mssql-scripter.bat -h
which is equivalent to the following:
python -m mssqlscripter -h