Skip to content

make-help outputs a lot of extra stuff #6

Description

@Drachenfels

Hello @Xanders,

Last time I raise this issue: #4, you fixed it and I really appreciated it! (Sorry for late feedback, but it was indeed great job).

Still this time around, I have different/other/unknown issue with make-help, my Makefile has a lot of comments and notes and it conflicts with your regexp it seems.

Makefile:

# this bit exposes variables from docker_overrides to Makefile
include shared.env
export

# NOTE1: SHARED_ENV is a way to share env variables between Docker,
# 	docker-compose and Makefile, this way we have only one source of truth
# NOTE2: in addition because SHARED_ENV variables are exported in master
# 	process, before executing docker-compose, they are not only available in a
# 	container but as well in docker-compose, allowing variable substitution
# 	there
# NOTE3: there is one drawback, Makefile prints all the variables as it runs,
# 	making it akward stdout noise
# NOTE4: overrides become handy if for example two different docker stacks run
# 	mysql/rabbitmq instances and we need to set different ports for them


# this bit loads docker_overrides to SHARED_ENV variable that can be used
# later in commands


SHARED_ENV = grep --regexp ^[A-Z] shared.env | cut -d= -f1

VERSION = `cat pyproject.toml | grep "^version = \".*\"" | cut -d '"' -f2`

SOURCE_BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
COMMIT = $(shell git rev-parse --short HEAD)

test ?=
test_switch ?= -s
db_dump ?= dump.sql
up = head
down = -1

tests%: export DB_PORT=5432
tests%: export DB_USER="user"

# Show this help message
# Multiple lines are supported too
# When it's first, both commands works:
# `make`
# `make help`
help:
	@cat $(MAKEFILE_LIST) | docker run --rm -i xanders/make-help

# Run some python code
run:
	cat example.py | python

##
## Tests
##

# Runs all tests excluding those requiring access to remote servers
run-tests:
	pytest -m 'not integration' --cov=app --cov-report html ${test_switches} ${test}

# Runs all tests excluding those requiring access to remote servers, but breaks after first error
run-tests-short:
	make run-tests test_switches='-sxv'

##
## Dockers
##

# Build Docker image
build:
	docker build -t xanders/make-help .

# Run `build` and `help` successively
test: build help

##
## Section for authorized contributors
##

# Push image to `https://hub.docker.com`
push:
	docker push xanders/make-help

And when I run make help I get:

drachenfels@zoantrope:~/Projects/experiments/makefile-experiments$ make help 

Usage: make <command> [ARGUMENT1=value1] [ARGUMENT2=value2]

Commands:

 SHARED_ENV = grep --regexp ^[A-Z] shared.env | cut -d= -f1

VERSION = `cat pyproject.toml | grep "^version = \".*\"" | cut -d '"' -f2`

SOURCE_BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
COMMIT = $(shell git rev-parse --short HEAD)

test ?=
test_switch ?= -s
db_dump ?= dump.sql
up = head
down = -1

tests% # this bit loads docker_overrides to SHARED_ENV variable that can be used
                                                                                                                                              
                                                                                                                                              
                              # later in commands

For easy reproduciton this time I have a repo you can clone to try:

https://github.com/Drachenfels/make-help-test

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions