@@ -11,12 +11,17 @@ ifeq ($(PLATFORM),Linux)
1111 uid_args := "--build-arg uid=$(shell id -u) --build-arg gid=$(shell id -g)"
1212endif
1313
14+ SETUPTOOLS_SCM_PRETEND_VERSION_DOCKER ?= $(shell git describe --match '[0-9]* ' --dirty='.m' --always --tags 2>/dev/null | sed -r 's/-([0-9]+) /.dev\1/' | sed 's/-/+/')
15+ ifeq ($(SETUPTOOLS_SCM_PRETEND_VERSION_DOCKER ) ,)
16+ SETUPTOOLS_SCM_PRETEND_VERSION_DOCKER = "dev"
17+ endif
18+
1419.PHONY : all
1520all : test
1621
1722.PHONY : clean
1823clean :
19- -docker rm -f dpy-dind-py3 dpy-dind-certs dpy-dind-ssl
24+ -docker rm -f dpy-dind dpy-dind-certs dpy-dind-ssl
2025 find -name " __pycache__" | xargs rm -rf
2126
2227.PHONY : build-dind-ssh
@@ -25,51 +30,62 @@ build-dind-ssh:
2530 --pull \
2631 -t docker-dind-ssh \
2732 -f tests/Dockerfile-ssh-dind \
33+ --build-arg VERSION=${SETUPTOOLS_SCM_PRETEND_VERSION_DOCKER} \
2834 --build-arg ENGINE_VERSION=${TEST_ENGINE_VERSION} \
2935 --build-arg API_VERSION=${TEST_API_VERSION} \
3036 --build-arg APT_MIRROR .
3137
32- .PHONY : build-py3
33- build-py3 :
38+ .PHONY : build
39+ build :
3440 docker build \
3541 --pull \
3642 -t docker-sdk-python3 \
3743 -f tests/Dockerfile \
44+ --build-arg VERSION=${SETUPTOOLS_SCM_PRETEND_VERSION_DOCKER} \
3845 --build-arg APT_MIRROR .
3946
4047.PHONY : build-docs
4148build-docs :
42- docker build -t docker-sdk-python-docs -f Dockerfile-docs $(uid_args ) .
49+ docker build \
50+ -t docker-sdk-python-docs \
51+ -f Dockerfile-docs \
52+ --build-arg VERSION=${SETUPTOOLS_SCM_PRETEND_VERSION_DOCKER} \
53+ $(uid_args ) \
54+ .
4355
4456.PHONY : build-dind-certs
4557build-dind-certs :
46- docker build -t dpy-dind-certs -f tests/Dockerfile-dind-certs .
58+ docker build \
59+ -t dpy-dind-certs \
60+ -f tests/Dockerfile-dind-certs \
61+ --build-arg VERSION=${SETUPTOOLS_SCM_PRETEND_VERSION_DOCKER} \
62+ .
4763
4864.PHONY : test
49- test : ruff unit-test-py3 integration-dind integration-dind-ssl
65+ test : ruff unit-test integration-dind integration-dind-ssl
5066
51- .PHONY : unit-test-py3
52- unit-test-py3 : build-py3
67+ .PHONY : unit-test
68+ unit-test : build
5369 docker run -t --rm docker-sdk-python3 py.test tests/unit
5470
55- .PHONY : integration-test-py3
56- integration-test-py3 : build-py3
71+ .PHONY : integration-test
72+ integration-test : build
5773 docker run -t --rm -v /var/run/docker.sock:/var/run/docker.sock docker-sdk-python3 py.test -v tests/integration/${file}
5874
5975.PHONY : setup-network
6076setup-network :
6177 docker network inspect dpy-tests || docker network create dpy-tests
6278
6379.PHONY : integration-dind
64- integration-dind : integration-dind-py3
80+ integration-dind : integration-dind
6581
66- .PHONY : integration-dind-py3
67- integration-dind-py3 : build-py3 setup-network
68- docker rm -vf dpy-dind-py3 || :
82+ .PHONY : integration-dind
83+ integration-dind : build setup-network
84+ docker rm -vf dpy-dind || :
6985
7086 docker run \
7187 --detach \
72- --name dpy-dind-py3 \
88+ --name dpy-dind \
7389 --network dpy-tests \
7490 --pull=always \
7591 --privileged \
@@ -82,22 +98,22 @@ integration-dind-py3: build-py3 setup-network
8298 --rm \
8399 --tty \
84100 busybox \
85- sh -c 'while ! nc -z dpy-dind-py3 2375; do sleep 1; done'
101+ sh -c 'while ! nc -z dpy-dind 2375; do sleep 1; done'
86102
87103 docker run \
88- --env="DOCKER_HOST=tcp://dpy-dind-py3 :2375" \
104+ --env="DOCKER_HOST=tcp://dpy-dind:2375" \
89105 --env="DOCKER_TEST_API_VERSION=${TEST_API_VERSION}" \
90106 --network dpy-tests \
91107 --rm \
92108 --tty \
93109 docker-sdk-python3 \
94110 py.test tests/integration/${file}
95111
96- docker rm -vf dpy-dind-py3
112+ docker rm -vf dpy-dind
97113
98114
99115.PHONY : integration-dind-ssh
100- integration-dind-ssh : build-dind-ssh build-py3 setup-network
116+ integration-dind-ssh : build-dind-ssh build setup-network
101117 docker rm -vf dpy-dind-ssh || :
102118 docker run -d --network dpy-tests --name dpy-dind-ssh --privileged \
103119 docker-dind-ssh dockerd --experimental
@@ -116,7 +132,7 @@ integration-dind-ssh: build-dind-ssh build-py3 setup-network
116132
117133
118134.PHONY : integration-dind-ssl
119- integration-dind-ssl : build-dind-certs build-py3 setup-network
135+ integration-dind-ssl : build-dind-certs build setup-network
120136 docker rm -vf dpy-dind-certs dpy-dind-ssl || :
121137 docker run -d --name dpy-dind-certs dpy-dind-certs
122138
@@ -164,13 +180,13 @@ integration-dind-ssl: build-dind-certs build-py3 setup-network
164180 docker rm -vf dpy-dind-ssl dpy-dind-certs
165181
166182.PHONY : ruff
167- ruff : build-py3
183+ ruff : build
168184 docker run -t --rm docker-sdk-python3 ruff docker tests
169185
170186.PHONY : docs
171187docs : build-docs
172188 docker run --rm -t -v ` pwd` :/src docker-sdk-python-docs sphinx-build docs docs/_build
173189
174190.PHONY : shell
175- shell : build-py3
191+ shell : build
176192 docker run -it -v /var/run/docker.sock:/var/run/docker.sock docker-sdk-python3 python
0 commit comments