diff --git a/Dockerfile.hot.dev b/Dockerfile.hot.dev deleted file mode 100644 index d01d205..0000000 --- a/Dockerfile.hot.dev +++ /dev/null @@ -1,5 +0,0 @@ -FROM golang:1.22 -RUN go install github.com/air-verse/air@latest -WORKDIR /app -EXPOSE 3001 -CMD ["air", "-c", ".air.conf"] \ No newline at end of file diff --git a/Makefile b/Makefile index 1148c1f..e353743 100644 --- a/Makefile +++ b/Makefile @@ -2,26 +2,51 @@ SHELL := /bin/bash # go source files, ignore vendor directory SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*") +.PHONY: run test integration-test build ci-run fmt -.PHONY: fmt run +# Dev Commands -fmt: - @gofmt -l -w $(SRC) - -run: +## Runs the api service in a way that depends on the database from the askdarcel-api project +run: docker-exists docker compose -f docker-compose.dev.yml build && docker compose -f docker-compose.dev.yml up -hot-run: - env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./tmp/sheltertech-go-hot ./cmd/sheltertech-go && DOCKER_DEFAULT_PLATFORM="linux/amd64" docker compose -f docker-compose.hot.dev.yml build && docker compose -f docker-compose.hot.dev.yml up +## Runs the api service in a way that brings up its own database and does not require anything from askdarcel-api running +run-standalone: docker-exists + docker compose -f docker-compose.ci.yml build && docker compose -f docker-compose.ci.yml up -ci-run: - docker compose -f docker-compose.ci.yml build && docker compose -f docker-compose.ci.yml up -d +# Test Commands + +## Unit tests which require no other dependencies +test: go-exists + go test -v ./... + +## Expects a server running on localhost:3001 from the dev flow +integration-test: go-exists + go test -v -tags=integration ./... + +# CI Commands -build: +## Used in CI to do a quick compile check +build: go-exists go build -v ./... -test: - go test -v ./... +## Used in CI to start a database in the background along with the api service +## Running this yourself allows you to create what happens in CI +ci-run: docker-exists + docker compose -f docker-compose.ci.yml build && docker compose -f docker-compose.ci.yml up -d + +# Utility + +## Format go files in repo +fmt: go-exists + @gofmt -l -w $(SRC) + +go-exists: +ifeq (, $(shell which go)) + $(error golang is not installed on this machine, you may use `brew install go` to install it.) +endif -integration-test: - go test -v -tags=integration ./... \ No newline at end of file +docker-exists: +ifeq (, $(shell which docker)) + $(error docker is not installed on this machine, you will need to install docker.) +endif \ No newline at end of file diff --git a/docker-compose.hot.dev.yml b/docker-compose.hot.dev.yml deleted file mode 100644 index e59d7f2..0000000 --- a/docker-compose.hot.dev.yml +++ /dev/null @@ -1,25 +0,0 @@ -version: "3.5" - -services: - sheltertech-go: - build: - context: ./ - dockerfile: Dockerfile.hot.dev - environment: - DB_HOST: db - DB_PORT: 5432 - DB_NAME: askdarcel_development - DB_USER: postgres - AUTH0_DOMAIN: "dev-nykixf8szsm220fi.us.auth0.com" - networks: - - askdarcel - volumes: - - ./:/app - ports: - - "3001:3001" - - "3002:3002" - -networks: - # Used to connect to askdarcel in a different docker-compose instance - askdarcel: - name: askdarcel \ No newline at end of file