From 847898606fa5c3e300ce265e2aaabcc5faa68ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Roth?= Date: Sun, 6 Oct 2024 18:57:32 +0200 Subject: [PATCH] cleanup makefile --- Makefile | 43 +++++++++++++++++++++++----------------- system/build-binaries | 9 --------- system/docker-wrapper | 8 +++++--- system/run-aptly-cmd | 10 ---------- system/run-golangci-lint | 6 ------ system/run-system-tests | 10 ---------- system/run-unit-tests | 11 ---------- 7 files changed, 30 insertions(+), 67 deletions(-) delete mode 100755 system/build-binaries delete mode 100755 system/run-aptly-cmd delete mode 100755 system/run-golangci-lint delete mode 100755 system/run-system-tests delete mode 100755 system/run-unit-tests diff --git a/Makefile b/Makefile index d631e68a9..ca84ae271 100644 --- a/Makefile +++ b/Makefile @@ -49,14 +49,28 @@ swagger-install: # Install swag @test -f $(BINPATH)/swag || go install github.com/swaggo/swag/cmd/swag@latest # Create docs/swagger.conf - @cp docs/swagger.conf.tpl docs/swagger.conf - @echo "// @version $(VERSION)" >> docs/swagger.conf + cp docs/swagger.conf.tpl docs/swagger.conf + echo "// @version $(VERSION)" >> docs/swagger.conf swagger: swagger-install # Generating swagger docs - @PATH=$(BINPATH)/:$(PATH) swag init -q --markdownFiles docs --generalInfo docs/swagger.conf + @PATH=$(BINPATH)/:$(PATH) swag init --markdownFiles docs --generalInfo docs/swagger.conf # GOOS=linux GOARCH=amd64 go install github.com/swaggo/swag/cmd/swag@latest +etcd-install: + # Install etcd + test -d /srv/etcd || system/t13_etcd/install-etcd.sh + +flake8: ## run flake8 on system test python files + flake8 system/ + +lint: + # Install golangci-lint + go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) + # Running lint + @PATH=$(BINPATH)/:$(PATH) golangci-lint run + + build: prepare swagger ## Build aptly go build -o build/aptly @@ -65,13 +79,6 @@ install: go generate @out=`mktemp`; if ! go install -v > $$out 2>&1; then cat $$out; rm -f $$out; echo "\nBuild failed\n"; exit 1; else rm -f $$out; fi -etcd-install: - # install etcd - test -d /srv/etcd || system/t13_etcd/install-etcd.sh - -flake8: ## run flake8 on system test python files - flake8 system/ - test: prepare swagger etcd-install ## Run unit tests @echo "\e[33m\e[1mStarting etcd ...\e[0m" @mkdir -p /tmp/etcd-data; system/t13_etcd/start-etcd.sh > /tmp/etcd-data/etcd.log 2>&1 & @@ -145,28 +152,28 @@ docker-image: ## Build aptly-dev docker image @docker build -f system/Dockerfile . -t aptly-dev docker-build: ## Build aptly in docker container - @docker run -it --rm -v ${PWD}:/work/src aptly-dev /work/src/system/run-aptly-cmd make build + @docker run -it --rm -v ${PWD}:/work/src aptly-dev /work/src/system/docker-wrapper build docker-shell: ## Run aptly and other commands in docker container - @docker run -it --rm -v ${PWD}:/work/src aptly-dev /work/src/system/run-aptly-cmd + @docker run -it --rm -v ${PWD}:/work/src aptly-dev /work/src/system/docker-wrapper || true docker-deb: ## Build debian packages in docker container - @docker run -it --rm -v ${PWD}:/work/src aptly-dev /work/src/system/build-deb + @docker run -it --rm -v ${PWD}:/work/src aptly-dev /work/src/system/docker-wrapper dpkg -docker-unit-tests: ## Run unit tests in docker container - @docker run -it --rm -v ${PWD}:/app aptly-dev /app/system/run-unit-tests +docker-unit-test: ## Run unit tests in docker container + @docker run -it --rm -v ${PWD}:/work/src aptly-dev /work/src/system/docker-wrapper test -docker-system-tests: ## Run system tests in docker container (add TEST=t04_mirror or TEST=UpdateMirror26Test to run only specific tests) +docker-system-test: ## Run system tests in docker container (add TEST=t04_mirror or TEST=UpdateMirror26Test to run only specific tests) @docker run -it --rm -v ${PWD}:/work/src aptly-dev /work/src/system/docker-wrapper system-test $(TEST) docker-server: ## Run development server (auto recompiling) on http://localhost:3142 @docker run -it --rm -p 3142:3142 -v ${PWD}:/work/src aptly-dev /work/src/system/docker-wrapper server docker-lint: ## Run golangci-lint in docker container - @docker run -it --rm -v ${PWD}:/app -e GOLANGCI_LINT_VERSION=$(GOLANGCI_LINT_VERSION) aptly-dev /app/system/run-golangci-lint + @docker run -it --rm -v ${PWD}:/work/src aptly-dev /work/src/system/docker-wrapper lint docker-binaries: ## Build binary releases (FreeBSD, MacOS, Linux tar) in docker container - @docker run -it --rm -v ${PWD}:/app aptly-dev /app/system/build-binaries + @docker run -it --rm -v ${PWD}:/work/src aptly-dev /work/src/system/docker-wrapper binaries mem.png: mem.dat mem.gp gnuplot mem.gp diff --git a/system/build-binaries b/system/build-binaries deleted file mode 100755 index 43e9de0c7..000000000 --- a/system/build-binaries +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -# cleanup -rm -rf /app/build/tmp - -usermod -u `stat -c %u /app` aptly >/dev/null -chown -R `stat -c %u /app` /var/lib/aptly - -su - aptly -c "cd /app; export GOPATH=/app/.go; make binaries" diff --git a/system/docker-wrapper b/system/docker-wrapper index e129ba0b3..baabaab2d 100755 --- a/system/docker-wrapper +++ b/system/docker-wrapper @@ -1,12 +1,14 @@ #!/bin/sh -e +# make sure files are written with correct user ownership usermod -u `stat -c %u /work/src` aptly >/dev/null chown -R `stat -c %u /work/src` /var/lib/aptly if [ -z "$@" ]; then - echo Error: no make target specified - exit 1 + cmd="bash" +else + cmd="make $@" fi cd /work/src -su aptly -c "GOPATH=$PWD/.go make $@" +sudo -u aptly GOPATH=/work/src/.go $cmd diff --git a/system/run-aptly-cmd b/system/run-aptly-cmd deleted file mode 100755 index b3d0ad1f1..000000000 --- a/system/run-aptly-cmd +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -cmd=$@ -test -z "$cmd" && cmd="bash" - -usermod -u `stat -c %u /work/src` aptly >/dev/null -chown -R `stat -c %u /work/src` /var/lib/aptly - -cd /work/src -exec sudo -u aptly PATH=$PATH:/work/src/build GOPATH=/work/src/.go $cmd diff --git a/system/run-golangci-lint b/system/run-golangci-lint deleted file mode 100755 index 149211218..000000000 --- a/system/run-golangci-lint +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -e - -usermod -u `stat -c %u /app` aptly >/dev/null -chown -R `stat -c %u /app` /var/lib/aptly - -su aptly -c "set -e; cd /app; export GOPATH=/app/.go; go install github.com/golangci/golangci-lint/cmd/golangci-lint@$GOLANGCI_LINT_VERSION; PATH=\$PATH:/app/.go/bin golangci-lint run" diff --git a/system/run-system-tests b/system/run-system-tests deleted file mode 100755 index 58ac82f56..000000000 --- a/system/run-system-tests +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# cleanup -rm -rf /app/tmp -rm -rf /tmp/aptly* - -usermod -u `stat -c %u /app` aptly >/dev/null -chown -R `stat -c %u /app` /var/lib/aptly - -su - aptly -c "cd /app; export GOPATH=/app/.go; make docker-test TEST=$@" diff --git a/system/run-unit-tests b/system/run-unit-tests deleted file mode 100755 index 34b98bc47..000000000 --- a/system/run-unit-tests +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -# cleanup -rm -rf /app/tmp -rm -rf /tmp/aptly* - -mkdir -p /srv -usermod -u `stat -c %u /app` aptly >/dev/null -chown -R `stat -c %u /app` /var/lib/aptly /srv - -su - aptly -c "cd /app; export export GOPATH=/app/.go; go mod tidy; make test"