3.2 KiB
Building from Source
Pre-requisites
- Go
- GolangCI - A meta-linter which runs several linters in parallel
- To install, follow the local installation instructions
- Yarn - Yarn package manager
- Run
yarn install --frozen-lockfilein thestash/ui/v2.5folder (before running make generate for first time).
- Run
NOTE: You may need to run the go get commands outside the project directory to avoid modifying the projects module file.
Environment
Windows
- Download and install Go for Windows
- Download and install MingW
- Search for "advanced system settings" and open the system properties dialog.
- Click the
Environment Variablesbutton - Under system variables find the
Path. Edit and addC:\Program Files\mingw-w64\*\mingw64\bin(replace * with the correct path).
- Click the
NOTE: The make command in Windows will be mingw32-make with MingW.
macOS
- If you don't have it already, install the Homebrew package manager.
- Install dependencies:
brew install go git yarn gcc make
Commands
make pre-ui- Installs the UI dependencies. Only needs to be run once before building the UI for the first time, or if the dependencies are updatedmake generate- Generate Go and UI GraphQL filesmake fmt-ui- Formats the UI source codemake ui- Builds the frontendmake build- Builds the binary (make sure to build the UI as well... see below)make docker-build- Locally builds and tags a complete 'stash/build' docker imagemake lint- Run the linter on the backendmake fmt- Rungo fmtmake it- Run the unit and integration testsmake validate- Run all of the tests and checks required to submit a PRmake ui-start- Runs the UI in development mode. Requires a running stash server to connect to. Stash server port can be changed from the default of9999using environment variableVITE_APP_PLATFORM_PORT. UI runs on port3000or the next available port.
Building a release
- Run
make generateto create generated files - Run
make uito compile the frontend - Run
make buildto build the executable for your current platform
Cross compiling
This project uses a modification of the CI-GoReleaser docker container to create an environment
where the app can be cross-compiled. This process is kicked off by CI via the scripts/cross-compile.sh script. Run the following
command to open a bash shell to the container to poke around:
docker run --rm --mount type=bind,source="$(pwd)",target=/stash -w /stash -i -t stashappdev/compiler:latest /bin/bash
Profiling
Stash can be profiled using the --cpuprofile <output profile filename> command line flag.
The resulting file can then be used with pprof as follows:
go tool pprof <path to binary> <path to profile filename>
With graphviz installed and in the path, a call graph can be generated with:
go tool pprof -svg <path to binary> <path to profile filename> > <output svg file>