Contributing Code with IntelliJ - magma/magma GitHub Wiki
Developing Magma with IntelliJ
For IntelliJ IDEA, we provide a set of run configurations that support rapidly testing Magma code. See Testing Tips for more details.
Go Setup
- Ensure the Go plugin has been installed by going to
Preferences > Plugins > search for the plugin "Go"
- Specify the location of the Go SDK by going to
Preferences > Languages & Frameworks > Go > GOROOT
and selecting the relevant location - Create a Go module for the project by going to
Files > Project Structure > Project Settings > Modules > Click on "+" sign in the toolbar > New Module > Next
. When you reach the new module creation page, enter the following information:- Module name:
magma
- Content root, module file location: full path to your local Magma clone, e.g.
/Users/your_username/magma
- Module name:
After completing the above steps, restart your IDE and ensure the environment is properly set up
- Open "Project" on the left toolbar, and display "Project Files". All the files in the root
magma
directory should be displayed without a yellow background. This indicates IntelliJ recognizes the files as part of the module. - At the top-right corner of your IDE, you should see a drop-down menu showing a list of run configurations for the Magma test suites, with a green triangular button that allows you to run the selected test. Alternatively, when you open your run configurations (
Run > Edit Configurations
), you should see something like the below
You can now run all (Orchestrator) tests in one click.
NOTE: a minority of tests require a running Postgres instance, and will otherwise fail with connection errors. You can use orc8r/cloud/docker/run.py
to spin up the required test DB.
Python Setup
In the VM, execute rm -rf ~/python_ide_env && cd $MAGMA_ROOT && bazel run //dev_tools:python_env ~/python_ide_env
. Set the Python SDK Path to sftp://vagrant@localhost:2222/home/vagrant/python_ide_env/bin/python
This requires IntelliJ IDEA Ultimate.