Skip to content

Commit

Permalink
Switch from make to just. (#14)
Browse files Browse the repository at this point in the history
* Switch from `make` to `just`.

It's a simpler format. See the docs for all the reasons why I prefer it:
https://github.com/casey/just#what-are-the-idiosyncrasies-of-make-that-just-avoids

Also adds some improvements to the Nix setup that I discovered when
actually trying to run these commands.

* Lowercase "justfile".
  • Loading branch information
SamirTalwar authored Jun 30, 2023
1 parent 1908d38 commit 6ebf955
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 58 deletions.
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

source_env_if_exists .envrc.local
14 changes: 8 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Generated by Cargo
# will have compiled files and executables
# Rust
## will have compiled files and executables
debug/
target/

# These are backup files generated by rustfmt
## These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
## MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
*.swp

# direnv
/.direnv
.envrc.local
45 changes: 0 additions & 45 deletions Makefile

This file was deleted.

8 changes: 8 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,20 @@

devShells.default = pkgs.mkShell {
buildInputs = [
# build
pkgs.cargo
pkgs.cargo-watch
pkgs.clippy
pkgs.rust-analyzer
pkgs.rustPlatform.rustcSrc
pkgs.rustc
pkgs.rustfmt

# runtime
pkgs.protobuf

# development
pkgs.just
];
};
});
Expand Down
41 changes: 41 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
POSTGRESQL_CONNECTION_STRING := "postgresql://postgres:password@localhost:64002"

# we use this port because it's hardcoded in the metadata too
POSTGRES_DC_PORT := "8666"

# watch the code and re-run on changes
dev:
RUST_LOG=DEBUG \
PORT={{POSTGRES_DC_PORT}} \
POSTGRESQL_CONNECTION_STRING={{POSTGRESQL_CONNECTION_STRING}} \
cargo watch -c -x test -x run

# run postgres + jaeger
start-docker:
# start jaeger, configured to listen to V3
docker compose -f ../v3-experiments/crates/engine/services/dev.docker-compose.yaml up -d jaeger
# start our local postgres
docker compose up --wait

run-v3: start-docker
@echo "http://localhost:3000/ for graphiql console"
@echo "http://localhost:4002/ for jaeger console"
# Run graphql-engine using static Chinook metadata
# we expect the `v3-experiments` repo to live next door to this one
RUST_LOG=DEBUG cargo run --release \
--manifest-path ../v3-experiments/Cargo.toml --bin engine -- \
--metadata-path ./static/metadata-example.json \
--data-connectors-config ./static/data-connectors-config-example.json \
--secrets-path ./static/secrets-example.json

# run-postgres-dc, pointing it at local postgres etc
run-postgres-dc: start-docker
RUST_LOG=DEBUG \
PORT={{POSTGRES_DC_PORT}} \
POSTGRESQL_CONNECTION_STRING={{POSTGRESQL_CONNECTION_STRING}} \
cargo run --release

# start a postgres docker image and connect to it using psql
repl-postgres:
@docker compose up --wait postgres
psql {{POSTGRESQL_CONNECTION_STRING}}
17 changes: 10 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
### Prequisites

1. Install [rustup](https://www.rust-lang.org/tools/install).
2. Install additional tools: `cargo install watch rustfmt`, `rustup component add rust-analyzer`.
3. Install [docker](https://www.docker.com/)
4. Install protoc. Here are a few options:
- `brew install protobuf`
- `apt-get install protobuf-compiler`
- `dnf install protobuf-compiler`
5. Clone v3 experiments in a directory near this one: `(cd .. && git clone [email protected]:hasura/v3-experiments.git)`
2. Install additional tools:
- `cargo install watch rustfmt`
- `rustup component add rust-analyzer`
3. Install [just](https://github.com/casey/just)
4. Install [docker](https://www.docker.com/)
5. Install protoc. Here are a few options:
- `brew install protobuf`
- `apt-get install protobuf-compiler`
- `dnf install protobuf-compiler`
6. Clone v3 experiments in a directory near this one: `(cd .. && git clone [email protected]:hasura/v3-experiments.git)`

### Compile

Expand Down

0 comments on commit 6ebf955

Please sign in to comment.