From efe9cacf94b26effe978dabbc9d050fdfcbc15a5 Mon Sep 17 00:00:00 2001 From: Ernest Wong Date: Tue, 24 Apr 2018 14:31:24 -0700 Subject: [PATCH 1/3] Update configuring_your_machine.md --- .vscode/launch.json | 35 ++++++++------------------ doc/configuring_your_machine.md | 44 ++++++++++++++++++--------------- 2 files changed, 34 insertions(+), 45 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 720f01aa973..a9d875516ab 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,7 +2,7 @@ "version": "0.2.0", "configurations": [ { - "name": "Integrated Terminal/Console", + "name": "Azure CLI Debug (Integrated Console)", "type": "python", "request": "launch", "pythonPath": "${config:python.pythonPath}", @@ -19,20 +19,20 @@ ] }, { - "name": "Scripts", + "name": "Azure CLI Debug (External Console)", "type": "python", "request": "launch", + "stopOnEntry": true, "pythonPath": "${config:python.pythonPath}", - "program": "${workspaceRoot}/tools/automation/__main__.py", + "program": "${workspaceRoot}/src/azure-cli/azure/cli/__main__.py", "cwd": "${workspaceRoot}", "args": [ - "-h" + "--help" ], - "console": "integratedTerminal", + "console": "externalTerminal", "debugOptions": [ "WaitOnAbnormalExit", - "WaitOnNormalExit", - "RedirectOutput" + "WaitOnNormalExit" ] }, { @@ -40,9 +40,11 @@ "type": "python", "request": "launch", "pythonPath": "${config:python.pythonPath}", - "program": "${workspaceRoot}/tools/automation/tests/run.py", + "program": "${workspaceRoot}/tools/automation/__main__.py", "cwd": "${workspaceRoot}", "args": [ + "test", + "--help" ], "console": "integratedTerminal", "debugOptions": [ @@ -50,23 +52,6 @@ "WaitOnNormalExit", "RedirectOutput" ] - }, - { - "name": "External Terminal/Console", - "type": "python", - "request": "launch", - "stopOnEntry": true, - "pythonPath": "${config:python.pythonPath}", - "program": "${workspaceRoot}/src/azure-cli/azure/cli/__main__.py", - "cwd": "${workspaceRoot}", - "args": [ - "--help" - ], - "console": "externalTerminal", - "debugOptions": [ - "WaitOnAbnormalExit", - "WaitOnNormalExit" - ] } ] } diff --git a/doc/configuring_your_machine.md b/doc/configuring_your_machine.md index 447e23caa9e..ae62037e7a2 100644 --- a/doc/configuring_your_machine.md +++ b/doc/configuring_your_machine.md @@ -6,9 +6,9 @@ The Azure Python CLI projects sources are located on GitHub (https://github.com/ - Create pull requests against the https://github.com/azure/azure-cli repository to get your code changes merged into the project repository. ## Preparing your machine -1. Install Python 3.5.x from http://python.org. Please note that the version of Python that comes preinstalled on OSX is 2.7. -2. Clone your repository and check out the master branch. -3. Create a new virtual environment “env” for Python 3.5 in the root of your clone. You can do this by running: +1. Install Python 3.5.x from http://python.org. Please note that the version of Python that comes preinstalled on OSX is 2.7. +2. Clone your repository and check out the [`dev`](https://github.com/Azure/azure-cli/tree/dev) branch. +3. Create a new virtual environment “env” for Python 3.5 in the root of your clone. You can do this by running: #### Windows ```BatchFile @@ -18,7 +18,7 @@ The Azure Python CLI projects sources are located on GitHub (https://github.com/ ```Shell python -m venv /env ``` -4. Activate the env virtual environment by running: +4. Activate the env virtual environment by running: #### Windows ```BatchFile @@ -29,11 +29,11 @@ The Azure Python CLI projects sources are located on GitHub (https://github.com/ . /env/bin/activate ``` -5. Install the dependencies and load the command modules as local packages using pip. +5. Install the dependencies and load the command modules as local packages using pip. ```Shell python scripts/dev_setup.py ``` -6. Add `\src` to your PYTHONPATH environment variable: +6. Add `\src` to your PYTHONPATH environment variable: #### Windows ```BatchFile @@ -43,7 +43,7 @@ The Azure Python CLI projects sources are located on GitHub (https://github.com/ ```Shell export PYTHONPATH=/src:${PYTHONPATH} ``` -7. Setup tab completion (OSX/Ubuntu ONLY). +7. Setup tab completion (OSX/Ubuntu ONLY). Open Bash or zsh window and run: @@ -53,22 +53,23 @@ The Azure Python CLI projects sources are located on GitHub (https://github.com/ ## Configuring your IDE #### Visual Studio (Windows only) -1. Install Python Tools for Visual Studio. As of 2/18/2016, the current version (PTVS 2.2) can be found at http://microsoft.github.io/PTVS/. -2. Open the azure-cli.pyproj project +1. Install Python Tools for Visual Studio. As of 2/18/2016, the current version (PTVS 2.2) can be found at http://microsoft.github.io/PTVS/. +2. Open the `azure-cli.pyproj` project You should now be able to launch your project by pressing F5/start debugging #### Visual Studio Code (Any platform) Experimental steps – still haven’t been able to get virtual environments to work well with VSCode -1. Install VS Code -2. Install (one of) the python extension(s) (https://marketplace.visualstudio.com/items?itemName=donjayamanne.python) -Debugging should now work (including stepping and setting breakpoints). +1. Install VS Code +2. Install (one of) the python extension(s) (https://marketplace.visualstudio.com/items?itemName=donjayamanne.python) +3. Put [breakpoints](https://code.visualstudio.com/docs/editor/debugging#_breakpoints) in your code, then click on the Debug icon in the Activity Bar on the side of Visual Studio Code, and select `Azure CLI Debug` from the drop down menu. After that, press the play button to start debugging. +4. To add custom arguments to the command that you want to debug, press the gear icon beside the drop down menu and modify the `args` field in `launch.json` -The repo has a launch.json file that will launch the version of Python that is first on your path. +The repo has a `launch.json` file that will launch the version of Python that is first on your path. ## Running CLI #### Command line -1. Activate your virtual environment if not already done +1. Activate your virtual environment if not already done: #### OSX/Ubuntu (bash): ```Shell @@ -80,14 +81,14 @@ The repo has a launch.json file that will launch the version of Python that is f \env\scripts\activate.bat ``` -2. Invoke the CLI using: +2. Invoke the CLI using: #### Windows/OSX/Ubuntu: ``` az ``` -## Running Tests: +## Running Tests and Style Check #### Command line Running the `dev_setup.py` file installed the test and style check scripts into the `tools` directory under your `` directory and added them into the current virtualenv. @@ -96,16 +97,19 @@ The repo has a launch.json file that will launch the version of Python that is f To run the CLI tests: ``` - run_tests [-h] [--module MODULES [MODULES ...]] [--parallel] [--live] [--test TESTS] + azdev test [-h] [--series] [--live] [--src-file SRC_FILE] + [--dest-file DEST_FILE] [--ci] [--discover] + [--profile PROFILE] + [tests [tests ...]] ``` To check the CLI and command modules for style errors: ``` - check_style [-h] [--ci] [--pep8] [--pylint] [--module MODULES] + azdev style [-h] [--ci] [--pep8] [--pylint] [--module MODULES] ``` -#### VS Code - Under construction... +#### Visual Studio Code + Click on the Debug icon in the Activity Bar on the side of Visual Studio Code, and select `Azure CLI Tests` from the drop down menu. Press the play icon to start executing the tests. To add custom arguments to the test command, press the gear icon beside the drop down menu and modify the `args` field in `launch.json`. Make sure that any modification of `launch.json` is not included in your pull requests. #### Visual Studio Select `Test > Windows > Test Explorer` and click `Run All` in the Test Explorer pane. From 2ed4de95185be40e47a322c96833a66c4396f2aa Mon Sep 17 00:00:00 2001 From: Ernest Wong Date: Tue, 24 Apr 2018 14:49:08 -0700 Subject: [PATCH 2/3] More update --- .vscode/launch.json | 3 +-- doc/configuring_your_machine.md | 12 ++++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index a9d875516ab..1783ba49629 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -36,14 +36,13 @@ ] }, { - "name": "Azure CLI Tests", + "name": "Azdev Scripts", "type": "python", "request": "launch", "pythonPath": "${config:python.pythonPath}", "program": "${workspaceRoot}/tools/automation/__main__.py", "cwd": "${workspaceRoot}", "args": [ - "test", "--help" ], "console": "integratedTerminal", diff --git a/doc/configuring_your_machine.md b/doc/configuring_your_machine.md index ae62037e7a2..d0b408160c0 100644 --- a/doc/configuring_your_machine.md +++ b/doc/configuring_your_machine.md @@ -88,13 +88,17 @@ The repo has a `launch.json` file that will launch the version of Python that is az ``` -## Running Tests and Style Check +## Running Tests and Checking Code Style #### Command line - Running the `dev_setup.py` file installed the test and style check scripts into the `tools` directory under your - `` directory and added them into the current virtualenv. + Running the `dev_setup.py` file will install `azdev`, a CLI that performs useful tasks for Azure CLI developers such as executing CLI tests, CLI linter, and style checking. ##### Windows/OSX/Ubuntu: + For a list of available `azdev` commands: + ``` + azdev --help + ``` + To run the CLI tests: ``` azdev test [-h] [--series] [--live] [--src-file SRC_FILE] @@ -109,7 +113,7 @@ The repo has a `launch.json` file that will launch the version of Python that is ``` #### Visual Studio Code - Click on the Debug icon in the Activity Bar on the side of Visual Studio Code, and select `Azure CLI Tests` from the drop down menu. Press the play icon to start executing the tests. To add custom arguments to the test command, press the gear icon beside the drop down menu and modify the `args` field in `launch.json`. Make sure that any modification of `launch.json` is not included in your pull requests. + Click on the Debug icon in the Activity Bar on the side of Visual Studio Code, and select `Azdev Scripts` from the drop down menu. To execute `azdev` commands via Visual Studio Code, you will need to press the gear icon beside the drop down menu and modify the `args` field in `launch.json`. Make sure that any modification of `launch.json` is not included in your pull requests. #### Visual Studio Select `Test > Windows > Test Explorer` and click `Run All` in the Test Explorer pane. From 3ebe13e455c0b010d2230c71c14b88f9b1219712 Mon Sep 17 00:00:00 2001 From: Ernest Wong Date: Tue, 24 Apr 2018 15:38:48 -0700 Subject: [PATCH 3/3] Address PR comment --- doc/configuring_your_machine.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/configuring_your_machine.md b/doc/configuring_your_machine.md index d0b408160c0..ac76801adb9 100644 --- a/doc/configuring_your_machine.md +++ b/doc/configuring_your_machine.md @@ -6,9 +6,9 @@ The Azure Python CLI projects sources are located on GitHub (https://github.com/ - Create pull requests against the https://github.com/azure/azure-cli repository to get your code changes merged into the project repository. ## Preparing your machine -1. Install Python 3.5.x from http://python.org. Please note that the version of Python that comes preinstalled on OSX is 2.7. +1. Install Python 3.5.x or higher from http://python.org. Please note that the version of Python that comes preinstalled on OSX is 2.7. 2. Clone your repository and check out the [`dev`](https://github.com/Azure/azure-cli/tree/dev) branch. -3. Create a new virtual environment “env” for Python 3.5 in the root of your clone. You can do this by running: +3. Create a new virtual environment “env” for Python in the root of your clone. You can do this by running: #### Windows ```BatchFile