@@ -26,24 +26,20 @@ PROJECT := github.com/opencontainers/umoci
26
26
CMD := ${PROJECT}/cmd/umoci
27
27
28
28
# We use Docker because Go is just horrific to deal with.
29
- UMOCI_IMAGE := umoci_dev
29
+ UMOCI_IMAGE := umoci/ci:latest
30
30
31
31
# TODO: We should test umoci with all of the security options disabled so that
32
32
# we can make sure umoci inside containers works fine (all of these
33
33
# security options are necessary for the test code to run, not umoci
34
34
# itself). The AppArmor/SELinux settings are needed because of the
35
35
# mount-related tests, and the seccomp/systempaths settings are required
36
36
# for the runc tests for rootless containers.
37
- # XXX: Ideally we'd use --security-opt systempaths=unconfined, but the version
38
- # of Docker in Travis-CI doesn't support that. Bind-mounting the host's
39
- # proc into the container is more dangerous but has the same effect on the
40
- # in-kernel mnt_too_revealing() checks and works on old Docker.
41
- DOCKER_RUN := docker run --rm -it \
37
+ DOCKER_RUN := docker run --rm \
42
38
-v ${PWD}:/go/src/${PROJECT} \
43
- --security-opt seccomp=unconfined \
44
39
--security-opt apparmor=unconfined \
45
40
--security-opt label=disable \
46
- -v /proc:/tmp/.HOTFIX-stashed-proc
41
+ --security-opt seccomp=unconfined \
42
+ --security-opt systempaths=unconfined
47
43
DOCKER_ROOTPRIV_RUN := $(DOCKER_RUN ) --privileged --cap-add=SYS_ADMIN
48
44
DOCKER_ROOTLESS_RUN := $(DOCKER_RUN ) -u 1000:1000 --cap-drop=all
49
45
@@ -113,11 +109,11 @@ uninstall:
113
109
114
110
.PHONY : clean
115
111
clean :
116
- rm -f umoci umoci.static umoci.cov*
112
+ rm -f umoci umoci.static umoci-ci.tar umoci .cov*
117
113
rm -f $(MANPAGES )
118
114
119
115
.PHONY : validate
120
- validate : umociimage
116
+ validate : ci-image
121
117
$(DOCKER_RUN ) $(UMOCI_IMAGE ) make local-validate
122
118
123
119
.PHONY : local-validate
@@ -170,19 +166,15 @@ doc/man/%.1: doc/man/%.1.md
170
166
docs : $(MANPAGES )
171
167
172
168
# Used for tests.
173
- DOCKER_IMAGE :=opensuse/amd64:tumbleweed
174
-
175
- .PHONY : umociimage
176
- umociimage :
177
- docker build -t $(UMOCI_IMAGE ) --build-arg DOCKER_IMAGE=$(DOCKER_IMAGE ) .
169
+ DOCKER_IMAGE ?=opensuse/amd64:tumbleweed
178
170
179
171
ifndef COVERAGE
180
172
COVERAGE := $(notdir $(shell mktemp -u umoci.cov.XXXXXX) )
181
- export COVERAGE
182
173
endif
174
+ export COVERAGE
183
175
184
176
.PHONY : test-unit
185
- test-unit : umociimage
177
+ test-unit : ci-image
186
178
touch $(COVERAGE ) && chmod a+rw $(COVERAGE )
187
179
$(DOCKER_ROOTPRIV_RUN ) -e COVERAGE $(UMOCI_IMAGE ) make local-test-unit
188
180
$(DOCKER_ROOTLESS_RUN ) -e COVERAGE $(UMOCI_IMAGE ) make local-test-unit
@@ -192,7 +184,7 @@ local-test-unit:
192
184
GO=$(GO ) hack/test-unit.sh
193
185
194
186
.PHONY : test-integration
195
- test-integration : umociimage
187
+ test-integration : ci-image
196
188
touch $(COVERAGE ) && chmod a+rw $(COVERAGE )
197
189
$(DOCKER_ROOTPRIV_RUN ) -e COVERAGE -e TESTS $(UMOCI_IMAGE ) make local-test-integration
198
190
$(DOCKER_ROOTLESS_RUN ) -e COVERAGE -e TESTS $(UMOCI_IMAGE ) make local-test-integration
@@ -202,17 +194,49 @@ local-test-integration: umoci.cover
202
194
TESTS=" ${TESTS} " hack/test-integration.sh
203
195
204
196
.PHONY : shell
205
- shell : umociimage
206
- $(DOCKER_RUN ) $(UMOCI_IMAGE ) bash
197
+ shell : ci-image
198
+ $(DOCKER_RUN ) -it $(UMOCI_IMAGE ) bash
207
199
208
200
.PHONY : root-shell
209
- root-shell : umociimage
210
- $(DOCKER_ROOTPRIV_RUN ) $(UMOCI_IMAGE ) bash
201
+ root-shell : ci-image
202
+ $(DOCKER_ROOTPRIV_RUN ) -it $(UMOCI_IMAGE ) bash
211
203
212
204
.PHONY : rootless-shell
213
- rootless-shell : umociimage
214
- $(DOCKER_ROOTLESS_RUN ) $(UMOCI_IMAGE ) bash
205
+ rootless-shell : ci-image
206
+ $(DOCKER_ROOTLESS_RUN ) -it $(UMOCI_IMAGE ) bash
207
+
208
+ CACHE := .cache
209
+ CACHE_IMAGE := $(CACHE ) /ci-image.tar.zst
210
+
211
+ .PHONY : ci-image
212
+ ci-image :
213
+ docker pull opensuse/leap:latest
214
+ ! [ -f " $( CACHE_IMAGE) " ] || unzstd < " $( CACHE_IMAGE) " | docker load
215
+ DOCKER_BUILDKIT=1 docker build -t $(UMOCI_IMAGE ) \
216
+ --progress plain \
217
+ --cache-from $(UMOCI_IMAGE ) \
218
+ --build-arg DOCKER_IMAGE=$(DOCKER_IMAGE ) \
219
+ --build-arg BUILDKIT_INLINE_CACHE=1 .
220
+
221
+ .PHONY : ci-cache
222
+ ci-cache : ci-image
223
+ rm -rf $(CACHE ) && mkdir -p $(CACHE )
224
+ docker save $(UMOCI_IMAGE ) | zstd > $(CACHE_IMAGE )
225
+
226
+ .PHONY : ci-validate
227
+ ci-validate : umoci umoci.static
228
+ make docs local-validate
229
+
230
+ .PHONY : ci-unit
231
+ ci-unit : umoci.cover
232
+ make test-unit
233
+
234
+ .PHONY : ci-integration
235
+ ci-integration : umoci.cover
236
+ make test-integration
215
237
216
238
.PHONY : ci
217
- ci : umoci umoci.static umoci.cover validate docs test-unit test-integration
239
+ ci :
240
+ @echo " NOTE: This is not identical to the upstream CI, but the tests are the same."
241
+ make ci-validate ci-unit ci-integration
218
242
hack/ci-coverage.sh $(COVERAGE )
0 commit comments