-
Notifications
You must be signed in to change notification settings - Fork 333
Add build instructions for developers #2621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
307cdb6
only delete cabal store (keep hackage sync)
smatting d6c834d
Add hie.yaml
smatting 1713d16
Add cabal.project.local Makefile target
smatting d93381a
Update documentation
smatting 84e0e8b
changelog
smatting 6568a4a
Update building.md
smatting 68bf34d
Update building.md
smatting 5b4a53e
Update building.md
smatting File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add build instructions for developers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # How to build wire-server | ||
|
|
||
| As a prerequisiste install the [nix package manager](https://nixos.org/) and [direnv](https://direnv.net/). | ||
|
|
||
| All following commands expect that you've entered the nix-provided build-environment by running `direnv allow`. | ||
|
|
||
|
|
||
| 1. Create a `.envrc.local` file with these contents | ||
|
|
||
| ``` | ||
| export COMPILE_NGINX_USING_NIX=1 | ||
| export WIRE_BUILD_WITH_CABAL=1 | ||
| ``` | ||
|
|
||
| and reload the direnv via `direnv reload` | ||
|
|
||
| 2. Create a `cabal.project.local`. This file is not included in wire-server because it disables optimization. | ||
|
|
||
| ``` | ||
| make cabal.project.local | ||
| ``` | ||
|
|
||
| This should be re-run whenver a new local cabal package is added to the cabal project. | ||
|
|
||
| Then the following Makefile targets can be used to compile and test wire-server locally: | ||
|
|
||
| ``` | ||
| # to compile all binaries to ./dist run | ||
| make | ||
|
|
||
| # to build and install all of galley's executables | ||
| make c package=galley | ||
|
|
||
| # also run galley's unit tests | ||
| make c package=galley test=1 | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Linker errors while compiling | ||
|
|
||
| Linker errors can occur if the nix-provided build environment (see `nix/` directory) changes. Since cabal is not aware of the changed environment the cached build artifacts in `./dist-newstyle` and `~/.cabal/store/` from previous builds may be invalid causing the linker errors. | ||
|
|
||
| Haskell Language Server stores its build artifacts in `~/.cache/hie-bios` (equivalent to the `./dist-newstyle` directory) which become invalid for the same reason. | ||
|
|
||
| The easiest course of action is to to remove these directories via: | ||
|
|
||
| ``` | ||
| make delete-cache-on-linker-errors | ||
| ``` | ||
|
|
||
| # How to run integration tests | ||
|
|
||
| Integration tests require all of the haskell services (brig, galley, cannon, gundeck, proxy, cargohold, spar) to be correctly configured and running, before being able to execute e.g. the `brig-integration` binary. The test for brig also starts nginz, so make sure it has been built before. | ||
| These services require most of the deployment dependencies as seen in the architecture diagram to also be available: | ||
|
|
||
| - Required internal dependencies: | ||
| - cassandra (with the correct schema) | ||
| - elasticsearch (with the correct schema) | ||
| - redis | ||
| - Required external dependencies are the following configured AWS services (or "fake" replacements providing the same API): | ||
| - SES | ||
| - SQS | ||
| - SNS | ||
| - S3 | ||
| - DynamoDB | ||
| - Required additional software: | ||
| - netcat (in order to allow the services being tested to talk to the dependencies above) | ||
|
|
||
| Setting up these real, but in-memory internal and "fake" external dependencies is done easiest using [`docker-compose`](https://docs.docker.com/compose/install/). Run the following in a separate terminal (it will block that terminal, C-c to shut all these docker images down again): | ||
|
|
||
| ``` | ||
| deploy/dockerephemeral/run.sh | ||
| ``` | ||
|
|
||
| After all containers are up you can use these Makefile targets to run the tests locally: | ||
|
|
||
| ``` | ||
| # build and run galley's integration tests | ||
| make ci package=galley | ||
|
|
||
| # run galley's integration tests that match a pattern | ||
| TASTY_PATTERN="/MLS/" make ci package=galley | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| cradle: | ||
| cabal: {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,86 +1,13 @@ | ||
| # How to convert the project to cabal | ||
|
|
||
| 1. Run | ||
| Run | ||
|
|
||
| ```bash | ||
| ./tools/convert-to-cabal/generate.sh | ||
| ``` | ||
|
|
||
| This will generate these files | ||
| - `cabal.project.freeze` | ||
| - `cabal.project` | ||
|
|
||
| 2. Create a `cabal.project.local` file with | ||
|
|
||
| ``` | ||
| optimization: False | ||
| ``` | ||
|
|
||
| This configures that local builds fast without optimization. | ||
|
|
||
| To make sure Haskell Language Server also builds all projects without optimization run this: | ||
|
|
||
| ```bash | ||
| echo "optimization: False" > ./cabal.project.local | ||
| ./hack/bin/cabal-project-local-template.sh "ghc-options: -O0" >> ./cabal.project.local | ||
| ``` | ||
|
|
||
| Note: cabal v2-repl (which is run by hie-bios (HLS)) seem to be ignoring "optimization" flag for local dependencies, this is why we need to specify `ghc-options` explicitely. | ||
|
|
||
|
|
||
| # How to use the project with cabal | ||
|
|
||
| 1. Update your environment. | ||
| ```bash | ||
| cabal update | ||
| ``` | ||
|
|
||
| Add this to your .envrc.local | ||
| ```bash | ||
| export WIRE_BUILD_WITH_CABAL=1 | ||
| ``` | ||
|
|
||
| You should be able to build wire-server with cabal now: | ||
|
|
||
| ```bash | ||
| make install # using cabal | ||
| make c package=brig # to build and install all of brig's executables | ||
| make c package=brig test=1 # also run unit tests | ||
| make ci package=brig pattern="delete" # build and run brig's integration tests | ||
| ``` | ||
|
|
||
| 2. For Haskell Language Server change `hie.yaml` to use cabal | ||
| ```bash | ||
| WIRE_BUILD_WITH_CABAL=1 make hie.yaml | ||
| ``` | ||
|
|
||
|
|
||
|
|
||
| ## Notes | ||
|
|
||
| - `cabal v2-repl` (used by hie-bios) seem to be ignoring "optimization" flag for local dependencies. However it respects ghc-options | ||
|
|
||
| ``` | ||
| package foo | ||
| ghc-options: -O0 | ||
| ```bash | ||
| ./tools/convert-to-cabal/generate.sh | ||
| ``` | ||
|
|
||
| - With new cabal build there doesn't seem to be any way of running tests as part of a build. You have to run the tests manually. | ||
| https://github.com/haskell/cabal/issues/7267 | ||
|
|
||
| - Nix integration (`nix: True` in `~/.cabal/config`) is not supported in new-build. | ||
| https://github.com/haskell/cabal/issues/4646 | ||
| That's why you have to enter the environment defined by .envrc to use cabal. | ||
| This will generate these files | ||
| - `cabal.project.freeze` | ||
| - `cabal.project` | ||
|
|
||
| - cabal oddity? Specifying `--ghc-options` twice yields different result | ||
|
|
||
| if run | ||
| ``` | ||
| cabal build --ghc-options "-O0" exe:brig | ||
| ``` | ||
|
|
||
| and then | ||
| ``` | ||
| cabal build --ghc-options "-O0" --ghc-options "-O0" exe:brig | ||
| ``` | ||
| Cabal will retry to build brig and _all_ of its dependencies | ||
| Note: cabal v2-repl (which is run by hie-bios (HLS)) seem to be ignoring "optimization" flag for local dependencies, this is why we need to specify `ghc-options` explicitely. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to remove these variables in a separate PR