Skip to content

Commit

Permalink
move make variables into .env file
Browse files Browse the repository at this point in the history
This commit makes the repository dependent on `.env` being both a valid `.env` file for `dotenvy` to use and being valid to include in the `Makefile`.
  • Loading branch information
Dopplerian committed Aug 28, 2023
1 parent f6d90c3 commit 85e68cf
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 38 deletions.
25 changes: 25 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
POSTGRES_CONTAINER=postgres
POSTGRES_DB=fang
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DIESEL_DIR=fang/postgres_migrations
POSTGRES_MIGRATIONS=${POSTGRES_DIESEL_DIR}/migrations
POSTGRES_CONFIG=${POSTGRES_DIESEL_DIR}/diesel.toml

MYSQL_CONTAINER=mysql
MYSQL_DB=fang
MYSQL_USER=root
MYSQL_PASSWORD=mysql
MYSQL_DIESEL_DIR=fang/mysql_migrations
MYSQL_MIGRATIONS=${MYSQL_DIESEL_DIR}/migrations
MYSQL_CONFIG=${MYSQL_DIESEL_DIR}/diesel.toml

SQLITE_FILE=fang.db
SQLITE_DIESEL_DIR=fang/sqlite_migrations
SQLITE_MIGRATIONS=${SQLITE_DIESEL_DIR}/migrations
SQLITE_CONFIG=${SQLITE_DIESEL_DIR}/diesel.toml

HOST=127.0.0.1
POSTGRES_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${HOST}/${POSTGRES_DB}
MYSQL_URL=mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@${HOST}/${MYSQL_DB}
DATABASE_URL=${POSTGRES_URL}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ Cargo.lock
docs/content/docs/CHANGELOG.md
docs/content/docs/README.md
fang.db
.env
41 changes: 4 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,4 @@
POSTGRES_CONTAINER=postgres
POSTGRES_DB=fang
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DIESEL_DIR=fang/postgres_migrations
POSTGRES_MIGRATIONS=$(POSTGRES_DIESEL_DIR)/migrations
POSTGRES_CONFIG=$(POSTGRES_DIESEL_DIR)/diesel.toml

MYSQL_CONTAINER=mysql
MYSQL_DB=fang
MYSQL_USER=root
MYSQL_PASSWORD=mysql
MYSQL_DIESEL_DIR=fang/mysql_migrations
MYSQL_MIGRATIONS=$(MYSQL_DIESEL_DIR)/migrations
MYSQL_CONFIG=$(MYSQL_DIESEL_DIR)/diesel.toml

SQLITE_FILE=fang.db
SQLITE_DIESEL_DIR=fang/sqlite_migrations
SQLITE_MIGRATIONS=$(SQLITE_DIESEL_DIR)/migrations
SQLITE_CONFIG=$(SQLITE_DIESEL_DIR)/diesel.toml

HOST=127.0.0.1
DATABASE_URL=$(POSTGRES_URL)
POSTGRES_URL=postgres://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@$(HOST)/$(POSTGRES_DB)
MYSQL_URL=mysql://$(MYSQL_USER):$(MYSQL_PASSWORD)@$(HOST)/$(MYSQL_DB)
include .env

BOLD='\033[1m'
END_BOLD='\033[0m'
Expand All @@ -44,19 +20,10 @@ default: db tests ignored stop
stop $(STOP_TARGETS) \
default clippy tests ignored doc .FORCE

.SILENT: .env $(DB_TARGETS) $(WAIT_TARGETS) $(DIESEL_TARGETS) $(CLEAN_TARGETS) $(STOP_TARGETS)

.FORCE:
.SILENT: $(DB_TARGETS) $(WAIT_TARGETS) $(DIESEL_TARGETS) $(CLEAN_TARGETS) $(STOP_TARGETS)

.NOTPARALLEL: default

.env: .FORCE
printf '' > .env
echo "DATABASE_URL=$(DATABASE_URL)" >> .env
echo "POSTGRES_URL=$(POSTGRES_URL)" >> .env
echo "MYSQL_URL=$(MYSQL_URL)" >> .env
echo "SQLITE_FILE=$(SQLITE_FILE)" >> .env

db: $(DB_TARGETS)

db_postgres:
Expand Down Expand Up @@ -163,12 +130,12 @@ stop_sqlite:
clippy:
cargo clippy --verbose --all-targets --all-features -- -D warnings

tests: .env
tests:
@echo -e $(BOLD)Running tests...$(END_BOLD)
cargo test --all-features -- --color always --nocapture
$(MAKE) clean

ignored: .env
ignored:
@echo -e $(BOLD)Running ignored tests...$(END_BOLD)
cargo test --all-features -- --color always --nocapture --ignored
$(MAKE) clean
Expand Down

0 comments on commit 85e68cf

Please sign in to comment.