From 50eaf6c0bb8c06db1c8c3471499ab3100cc508e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Roth?= Date: Wed, 6 Mar 2024 12:46:44 +0100 Subject: [PATCH] update docker / makefile --- Makefile | 17 +++++++++++------ system/Dockerfile | 5 ++++- system/run-system-tests | 5 ++++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 85e5a2a15..498f6daf7 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,11 @@ COVERAGE_DIR?=$(shell mktemp -d) all: modules test bench check system-test +# Self-documenting Makefile +# https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +help: ## Print this help + @grep -E '^[a-zA-Z][a-zA-Z0-9_-]*:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + prepare: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.51.2 @@ -78,19 +83,19 @@ release: goxc mkdir -p build/ mv xc-out/$(VERSION)/aptly_$(VERSION)_* build/ -man: +man: ## Create man pages make -C man -version: +version: ## Print aptly version @echo $(VERSION) -docker-build: +docker-build-system-tests: ## Build system-test docker image docker build -f system/Dockerfile . -t aptly-system-test -docker-system-tests: +docker-system-tests: ## Run system tests in docker container docker run -t --rm -v ${PWD}:/app aptly-system-test -golangci-lint: +golangci-lint: ## Run golangci-line in docker container docker run -t --rm -v ~/.cache/golangci-lint/v1.56.2:/root/.cache -v ${PWD}:/app -w /app golangci/golangci-lint:v1.56.2 golangci-lint run -.PHONY: man modules version release goxc docker-build docker-system-tests +.PHONY: help man modules version release goxc docker-build docker-system-tests diff --git a/system/Dockerfile b/system/Dockerfile index 9335a9320..d3ee1377f 100644 --- a/system/Dockerfile +++ b/system/Dockerfile @@ -4,7 +4,7 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends curl gnupg & RUN echo deb http://deb.debian.org/debian bookworm-backports main > /etc/apt/sources.list.d/backports.list RUN apt-get update && \ - apt-get install -y --no-install-recommends apg bzip2 xz-utils ca-certificates golang/bookworm-backports golang-go/bookworm-backports golang-doc/bookworm-backports golang-src/bookworm-backports make git python3 && \ + apt-get install -y --no-install-recommends apg bzip2 xz-utils ca-certificates golang/bookworm-backports golang-go/bookworm-backports golang-doc/bookworm-backports golang-src/bookworm-backports make git python3 python3-venv && \ apt-get clean && rm -rf /var/lib/apt/lists/* RUN useradd -m --shell /bin/sh --home-dir /var/lib/aptly aptly @@ -12,4 +12,7 @@ RUN useradd -m --shell /bin/sh --home-dir /var/lib/aptly aptly RUN mkdir app WORKDIR /app +RUN su - aptly -c "git clone https://github.com/aptly-dev/aptly-fixture-db.git" +RUN su - aptly -c "git clone https://github.com/aptly-dev/aptly-fixture-pool.git" + CMD /app/system/run-system-tests diff --git a/system/run-system-tests b/system/run-system-tests index 3b5643837..27441a7dd 100755 --- a/system/run-system-tests +++ b/system/run-system-tests @@ -10,4 +10,7 @@ chown -R `stat -c %u /app` /var/lib/aptly mkdir -p /home/runner chown -R `stat -c %u /app` /home/runner -exec su - aptly -c "cd /app; go mod tidy; HOME=/home/runner make system-test" +su - aptly -c "cd /app; python3 -m venv system/env" +su - aptly -c "cd /app; go mod tidy; HOME=/home/runner make system-test" + +rm -rf system/env