Project: Opstrace (Observability and Analysis / Observability)
File: setting-up-your-dev-env.md

The reference build environment is the "CI container" as defined in `containers/ci`. A native host environment probably deviates from this reference environment in various minor or major ways. This document attempts to help setting up a local development environment that resembles that of the CI container. Overview of requirements: Node 16+ Yarn v1.x Go 1.16+ Docker GCP and/or AWS CLIs (`gcloud`/`aws`) `git` `golangci-lint` `markdownlint` Build tooling essentials such as `make` and `g++` (among others, for building binary extensions to some npm packages like `snappy`) The sections below hopefully help with setting up some of these! Disable TSLint extension in VSCode. Use the workspace settings file `opstrace.code-workspace` at the root of the repository. Install and enable these extensions in VSCode: ESLint and Prettier. These are also the 'recommended extensions' as part of our VSCode workspace configuration file. The Prettier extension output in VSCode should look like this (this is mainly about how it picks up its configuration): ```text ["INFO" - 11:19:26 AM] Extension Name: esbenp.prettier-vscode. ["INFO" - 11:19:26 AM] Extension Version: 8.1.0. ["INFO" - 11:19:48 AM] Formatting /home/jp/dev/opstrace/test/test-remote/test_alerts.ts ["INFO" - 11:19:48 AM] Using config file at '/home/jp/dev/opstrace/.prettierrc' ["INFO" - 11:19:48 AM] Using ignore file (if present) at /home/jp/dev/opstrace/.prettierignore ["INFO" - 11:19:48 AM] File Info: { "ignored": false, "inferredParser": "typescript" } ["INFO" - 11:19:48 AM] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used ["INFO" - 11:19:48 AM] Prettier Options: ``` The ESLint extension output in VSCode should look like this: ```text [Info - 11:19:26 AM] ESLint server is starting [Info - 11:19:27 AM] ESLint server running in node v14.16.0 [Info - 11:19:27 AM] ESLint server is running. [Info - 11:19:27 AM] ESLint library loaded from: /home/jp/dev/opstrace/node_modules/eslint/lib/api.js 2021-08-05T09:19:28.078Z eslint:rules Loading rule 'constructor-super' (remaining=283) 2021-08-05T09:19:28.079Z eslint:rules Loading rule 'for-direction' (remaining=282) ... ``` Our recommendation is to use for managing NodeJS installations. At the time of writing we are using NodeJS 16.x: Recommended setup: 1) Install and activate it (follow the instructions in the README). 2) Use NVM to install and activate NodeJS 16.x via `nvm install 16 && nvm use 16`. 3) Globally install `yarn` for that version of NodeJS via `npm install -g yarn`. In the `opstrace` repository you should now be able to `make cli`. To build locally, visit our page. We are currently using Golang 1.15. Go code is a small portion of our code base (under the `go/` directory), so this is not terribly important. We use to lint the Go codebase. You'll need to it and have it available in your PATH to run the pre-commit hooks locally. You may need to set `GOPRIVATE` to be able to build the project in Visual Studio Code. Also, you may want to use the following the following in your `preferences.json` to configure the Go plugin. ```json "go.toolsEnvVars": { "GO111MODULE": "on", "GOPRIVATE": "github.com/opstrace", }, ``` is required for all commits. Opstrace is following the process instead of requiring a CLA in order to reduce friction toward contributions. All git commits must be have an explicit sign-off asserting the contents of the DCO to pass our CI checks.