Here's how to set up your local development environment.
Ensure you have the following installed:
- Git - For version control
- If you've never used git, need a refresher, or need help setting it up, please check out Nebula's Git Workshop.
- Go - For building and running
- You can install from the Go website, or from Homebrew or another package manager for automatic updates
- Make (Linux/macOS) - For build automation
- Pre-installed on macOS (via
xcode-select --install) and most Linux distributions (build-essential)
- Pre-installed on macOS (via
- Docker (Optional) - For running containerized runners locally
Make is a build automation tool. Feel free to check out Makefile to see exactly what's being run.
If you're using Windows, instead of using make, you can also use our build.bat file. When you see any command starting with make, you can instead use .\build.bat.
For example instead of make setup, you can run .\build.bat setup.
Clone the repository with git clone, and then, cd into the project directory or open it in your preferred code editor.
HTTPS:
git clone https://github.com/UTDNebula/nebula-api.git
cd nebula-apior
SSH:
git clone git@github.com:UTDNebula/nebula-api.git
cd nebula-apiNow open the cloned project in your code editor!
Install the Go static analysis and formatting tools (staticcheck and goimports):
make setupor
.\build.bat setupIf you installed Go with Homebrew, you need to add Go tools to your path for tools like staticcheck and others to work.
-
For zsh (the default shell on MacOS)
echo 'export PATH=${PATH}:`go env GOPATH`/bin' >> ~/.zshrc && source ~/.zshrc
-
For bash (the default shell on most Linux distributions)
echo 'export PATH=${PATH}:`go env GOPATH`/bin' >> ~/.bashrc && source ~/.bashrc
-
For fish
echo 'fish_add_path (go env GOPATH)/bin' >> ~/.config/fish/config.fish
First, make a file called .env at the root of the project.
Then, copy the contents of .env.template into it. Some parts in nebula-api require certain environment variables, which you can fill in .env.
If you're not sure what to put, please try contacting one of our members through Discord.
[!IMPORTANT] Do NOT put any environment variables into
.env.template.
Check your code with:
make checkor
.\build.bat checkYou'll want to run this frequently while developing.
Compile the Go source code into a runnable binary (./rest-api on Linux/macOS, rest-api.exe on Windows):
make buildor
.\build.bat buildRun the test suite to confirm your environment is ready:
make testor
.\build.bat testIf all tests pass, congratulations! Your local development environment is ready.
To run rest-api locally, use:
./rest-apiCheck command output to see the route serving traffic. It's likely port 8080.
Visit http://localhost:8080 to access nebula-api locally.
[!NOTE] Some users have experienced issues with Windows Defender or other antivirus blocking
rest-api.exefrom reading files, editing files, or causing slowed performance. Consider adding an exception to yournebula-apifolder.
Now that your environment is running, it's time to dive deeper. Check out Project-Architecture.md