-
Notifications
You must be signed in to change notification settings - Fork 93
/
Copy pathMakefile
132 lines (109 loc) · 3.95 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
SOURCES := $(shell find cmd internal -type d -o -name "*.go")
RESOURCES := $(shell find resources)
GENERATED := internal/backends/python/pypi_map.sqlite
LD_FLAGS := "-X 'github.com/replit/upm/internal/cli.version=$${VERSION:-development version}'"
export GO111MODULE=on
.PHONY: upm
upm: cmd/upm/upm ## Build the UPM binary
install: cmd/upm/upm
go install ./cmd/upm
internal/backends/python/pypi_map.sqlite: internal/backends/python/download_stats.json
cd internal/backends/python; go run ./gen_pypi_map gen
generated: $(GENERATED)
cmd/upm/upm: $(SOURCES) $(RESOURCES) generated
cd cmd/upm && go build -ldflags $(LD_FLAGS)
build-release: $(SOURCES) $(RESOURCES) generated
goreleaser build
clean-gen:
rm -f $(GENERATED)
.PHONY: dev
dev: ## Run a shell with UPM source code and all package managers inside Docker
docker build . -f Dockerfile.dev -t upm:dev
docker run -it --rm -v "$$PWD:/upm" upm:dev
.PHONY: light
light: ## Build a Docker image with just the UPM binary
docker build . -f Dockerfile.light -t upm:light --build-arg VERSION
.PHONY: full
full: ## Build a Docker image with the UPM binary and all package managers
docker build . -f Dockerfile.full -t upm:full --build-arg VERSION
.PHONY: doc
doc: ## Open Godoc in web browser
docker build . -f Dockerfile.godoc -t upm:godoc
@echo
@echo "starting godoc; your browser will be opened once it is ready" >&2
@scripts/browse-godoc.bash &
@docker run -it --rm -p 6060:6060 \
-v "$$PWD:/tmp/go/src/github.com/replit/upm" \
upm:godoc
.PHONY: deploy
deploy: light full ## Publish UPM snapshot Docker images to Docker Hub
docker tag upm:light replco/upm:light
docker tag upm:full replco/upm:full
docker tag upm:full replco/upm:latest
docker push replco/upm:light
docker push replco/upm:full
docker push replco/upm:latest
.PHONY: pkgbuild
pkgbuild: ## Update and test PKGBUILD
git clean -fdX packaging/aur
docker build . -f Dockerfile.arch -t upm:arch
docker run -it --rm -v "$$PWD/packaging/aur:/upm" upm:arch \
/tmp/update-pkgbuild.bash
.PHONY: clean
clean: clean-gen ## Remove build artifacts
rm -rf cmd/upm/upm dist
.PHONY: help
help: ## Show this message
@echo "usage:" >&2
@grep -h "[#]# " $(MAKEFILE_LIST) | \
sed 's/^/ make /' | \
sed 's/:[^#]*[#]# /|/' | \
sed 's/%/LANG/' | \
column -t -s'|' >&2
.PHONY: test
test:
go test ./... -v
ifdef TEST_SUITE
GO_TEST_RUN_OPTS=$(TEST_SUITE)
else
GO_TEST_RUN_OPTS=.
endif
.PHONY: test-suite
ifdef UPM_CI
test-suite:
go get gotest.tools/gotestsum
# TODO: Move the following setup out into before/after or a separate
# environment-specific runner
venv="$$(mktemp -d)"; \
python -m venv "$$venv"; \
source "$$venv/bin/activate"; \
go run gotest.tools/gotestsum --junitfile ./junit.xml ./test-suite
else
test-suite:
go test -run $(GO_TEST_RUN_OPTS) ./test-suite
# I don't have a great name for these. The cases are as follows:
# make test-python3 # This runs inside nix develop and gates test suite
# # execution on any backend starting with python3
# make unwrapped-test-python3 # This sets the requisite envvars to run the filtered
# # test suite execution, but letting you run
# # _outside of nix_, should you need a virtualenv or
# # something special.
# make wrapped-test-python3 # This is the underlying command that powers the above
# # two modes. It isn't very useful when run directly,
# # since it doesn't know where upm or the PYPI_MAP_DB are.
test-%:
make wrapped-$@
unwrapped-test-%:
label="$@"; \
label="$${label#unwrapped-}"; \
PATH=$$PWD/cmd/upm/:"$$PATH" \
PYPI_MAP_DB=$$PWD/internal/backends/python/pypi_map.sqlite \
make wrapped-$$label
wrapped-test-%:
suite_prefix="$$(echo "$@" | cut -d- -f 3-)"; \
echo "Running $$suite_prefix"; \
cd test-suite; \
UPM_SUITE_PREFIX="$$suite_prefix" go test
endif
format:
go fmt github.com/replit/upm/...