Skip to content

Commit

Permalink
doc: Update contributing documentation and README (#793)
Browse files Browse the repository at this point in the history
  • Loading branch information
yohamta authored Jan 17, 2025
1 parent 65395f5 commit d06ff21
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 242 deletions.
29 changes: 25 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
.PHONY: run run-server run-server-https run-scheduler test test-coverage lint build certs swagger

##############################################################################
# Arguments
##############################################################################
Expand Down Expand Up @@ -81,16 +79,19 @@ OPENSSL_CONF=${CONFIG_DIR}/openssl.local.conf
##############################################################################

# run starts the frontend server and the scheduler.
.PHONY: run
run: ${FE_BUNDLE_JS}
@echo "${COLOR_GREEN}Starting the frontend server and the scheduler...${COLOR_RESET}"
@go run ./cmd start-all

# server build the binary and start the server.
.PHONY: run-server
run-server: golangci-lint build-bin
@echo "${COLOR_GREEN}Starting the server...${COLOR_RESET}"
${LOCAL_BIN_DIR}/${APP_NAME} server

# scheduler build the binary and start the scheduler.
.PHONY: run-scheduler
run-scheduler: golangci-lint build-bin
@echo "${COLOR_GREEN}Starting the scheduler...${COLOR_RESET}"
${LOCAL_BIN_DIR}/${APP_NAME} scheduler
Expand All @@ -101,39 +102,47 @@ ${FE_BUNDLE_JS}:
@echo "${COLOR_RED}Please run 'make build-ui' before starting the server.${COLOR_RESET}"

# https starts the server with the HTTPS protocol.
.PHONY: run-server-https
run-server-https: ${SERVER_CERT_FILE} ${SERVER_KEY_FILE}
@echo "${COLOR_GREEN}Starting the server with HTTPS...${COLOR_RESET}"
@DAGU_CERT_FILE=${SERVER_CERT_FILE} \
DAGU_KEY_FILE=${SERVER_KEY_FILE} \
go run ./cmd start-all

# test runs all tests.
.PHONY: test
test: build-bin
@echo "${COLOR_GREEN}Running tests...${COLOR_RESET}"
@GOBIN=${LOCAL_BIN_DIR} go install ${PKG_gotestsum}
@go clean -testcache
@${LOCAL_BIN_DIR}/gotestsum ${GOTESTSUM_ARGS} -- ${GO_TEST_FLAGS} ./...

# test-coverage runs all tests with coverage.
.PHONY: test-coverage
test-coverage:
@echo "${COLOR_GREEN}Running tests with coverage...${COLOR_RESET}"
@GOBIN=${LOCAL_BIN_DIR} go install ${PKG_gotestsum}
@${LOCAL_BIN_DIR}/gotestsum ${GOTESTSUM_ARGS} -- ${GO_TEST_FLAGS} -coverprofile="coverage.txt" -covermode=atomic ./...

# open-coverage opens the coverage file
.PHONY: open-coverage
open-coverage:
@go tool cover -html=coverage.txt

# lint runs the linter.
.PHONY: lint
lint: golangci-lint

# api generates the swagger server code.
.PHONY: swagger
api: clean-swagger gen-swagger

# certs generates the certificates to use in the development environment.
.PHONY: certs
certs: ${CERTS_DIR} ${SERVER_CERT_FILE} ${CLIENT_CERT_FILE} certs-check

# build build the binary.
.PHONY: build
build: build-ui build-bin

# build-image build the docker image and push to the registry.
Expand All @@ -143,21 +152,26 @@ build: build-ui build-bin
# ```
# {version} should be the version number such as "1.13.0".

build-image: build-image-version build-image-latest
.PHONY: build-image
build-image: build-image-version

.PHONY: build-image-latest
build-image-version:
ifeq ($(VERSION),)
$(error "VERSION is not set")
endif
echo "${COLOR_GREEN}Building the docker image with the version $(VERSION)...${COLOR_RESET}"
$(DOCKER_CMD) -t ghcr.io/dagu-org/${APP_NAME}:$(VERSION) .
$(DOCKER_CMD) -t ghcr.io/dagu-org/${APP_NAME}:$(VERSION) -t ghcr.io/dagu-org/${APP_NAME}:latest .

# build-image-latest build the docker image with the latest tag and push to
# the registry.
.PHONY: build-image-latest
build-image-latest:
@echo "${COLOR_GREEN}Building the docker image...${COLOR_RESET}"
$(DOCKER_CMD) -t ghcr.io/dagu-org/${APP_NAME}:latest .

# gomerger merges all go files into a single file.
.PHONY: gomerger
gomerger: ${LOCAL_DIR}/merged
@echo "${COLOR_GREEN}Merging Go files...${COLOR_RESET}"
@rm -f ${LOCAL_DIR}/merged/merged_project.go
Expand All @@ -169,6 +183,7 @@ ${LOCAL_DIR}/merged:
@mkdir -p ${LOCAL_DIR}/merged

# addlicnese adds license header to all files.
.PHONY: addlicense
addlicense:
@echo "${COLOR_GREEN}Adding license headers...${COLOR_RESET}"
@GOBIN=${LOCAL_BIN_DIR} go install ${PKG_addlicense}
Expand Down Expand Up @@ -198,12 +213,14 @@ addlicense:
##############################################################################

# build-bin builds the go application.
.PHONY: build-bin
build-bin:
@echo "${COLOR_GREEN}Building the binary...${COLOR_RESET}"
@mkdir -p ${BIN_DIR}
@go build -ldflags="$(LDFLAGS)" -o ${BIN_DIR}/${APP_NAME} ./cmd

# build-ui builds the frontend codes.
.PHONY: build-ui
build-ui:
@echo "${COLOR_GREEN}Building UI...${COLOR_RESET}"
@cd ui; \
Expand All @@ -213,18 +230,21 @@ build-ui:
@cp ${FE_BUILD_DIR}/* ${FE_ASSETS_DIR}

# golangci-lint run linting tool.
.PHONY: golangci-lint
golangci-lint:
@echo "${COLOR_GREEN}Running linter...${COLOR_RESET}"
@GOBIN=${LOCAL_BIN_DIR} go install $(PKG_golangci_lint)
@${LOCAL_BIN_DIR}/golangci-lint run ./...

# clean-swagger removes generated go files for swagger.
.PHONY: clean-swagger
clean-swagger:
@echo "${COLOR_GREEN}Cleaning the swagger files...${COLOR_RESET}"
@rm -rf ${FE_GEN_DIR}/restapi/models
@rm -rf ${FE_GEN_DIR}/restapi/operations

# gen-swagger generates go files for the API schema.
.PHONY: gen-swagger
gen-swagger:
@echo "${COLOR_GREEN}Generating the swagger server code...${COLOR_RESET}"
@GOBIN=${LOCAL_BIN_DIR} go install $(PKG_swagger)
Expand Down Expand Up @@ -271,6 +291,7 @@ ${CERTS_DIR}:
@echo "${COLOR_GREEN}Creating the certificates directory...${COLOR_RESET}"
@mkdir -p ${CERTS_DIR}

.PHONY: certs-check
certs-check:
@echo "${COLOR_GREEN}Checking CA certificate...${COLOR_RESET}"
@openssl x509 -in ${SERVER_CERT_FILE} -noout -text
Loading

0 comments on commit d06ff21

Please sign in to comment.