mirror of
https://github.com/peterbourgon/runsvinit.git
synced 2024-12-16 14:57:04 +00:00
Try Circle
This commit is contained in:
parent
819c47186c
commit
f197aa8f6a
8
circle.yml
Normal file
8
circle.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
machine:
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
test:
|
||||||
|
override:
|
||||||
|
- go test -v
|
||||||
|
- make CIRCLECI=true SUDO=sudo RM= -C zombietest
|
@ -1,23 +1,27 @@
|
|||||||
|
GO?=go
|
||||||
|
SUDO?=
|
||||||
|
RM?=--rm
|
||||||
|
|
||||||
.PHONY: test clean
|
.PHONY: test clean
|
||||||
|
|
||||||
test: .test.uptodate
|
test: .test.uptodate
|
||||||
./test.bash
|
./test.bash
|
||||||
|
|
||||||
.test.uptodate: runsvinit zombie run-zombie Dockerfile
|
.test.uptodate: runsvinit zombie run-zombie Dockerfile
|
||||||
docker build -t zombietest .
|
$(SUDO) docker build -t zombietest .
|
||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
runsvinit: ../*.go
|
runsvinit: ../*.go
|
||||||
env GOOS=linux GOARCH=amd64 go build -o $@ github.com/peterbourgon/runsvinit
|
env GOOS=linux GOARCH=amd64 $(GO) build -o $@ github.com/peterbourgon/runsvinit
|
||||||
|
|
||||||
zombie: .build.uptodate
|
zombie: .build.uptodate
|
||||||
docker run --rm -v $(shell pwd):/mount zombietest-build cc -Wall -Werror -o /mount/zombie /zombie.c
|
$(SUDO) docker run $(RM) -v $(shell pwd):/mount zombietest-build cc -Wall -Werror -o /mount/zombie /zombie.c
|
||||||
|
|
||||||
.build.uptodate: build/zombie.c build/Dockerfile
|
.build.uptodate: build/zombie.c build/Dockerfile
|
||||||
docker build -t zombietest-build build/
|
$(SUDO) docker build -t zombietest-build build/
|
||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf .test.uptodate .build.uptodate runsvinit zombie
|
rm -rf .test.uptodate .build.uptodate runsvinit zombie
|
||||||
docker stop zombietest zombietest-build >/dev/null 2>&1 || true
|
$(SUDO) docker stop zombietest zombietest-build >/dev/null 2>&1 || true
|
||||||
docker rm zombietest zombietest-build >/dev/null 2>&1 || true
|
$(SUDO) docker rm zombietest zombietest-build >/dev/null 2>&1 || true
|
||||||
|
@ -1,11 +1,26 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
RC=0
|
function zombies() {
|
||||||
|
if [ -z "$CIRCLECI" ]
|
||||||
|
then
|
||||||
|
docker exec $C ps -o pid,stat | grep Z | wc -l
|
||||||
|
else
|
||||||
|
# https://circleci.com/docs/docker#docker-exec
|
||||||
|
sudo lxc-attach -n "$(docker inspect --format '{{.Id}}' $C)" -- sh -c "ps -o pid,stat | grep Z | wc -l"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop_rm() {
|
||||||
|
docker stop $1
|
||||||
|
docker rm $1
|
||||||
|
}
|
||||||
|
|
||||||
SLEEP=1
|
SLEEP=1
|
||||||
|
RC=0
|
||||||
|
|
||||||
C=$(docker run -d zombietest /runsvinit -reap=false)
|
C=$(docker run -d zombietest /runsvinit -reap=false)
|
||||||
sleep $SLEEP
|
sleep $SLEEP
|
||||||
NOREAP=$(docker exec $C ps -o pid,stat | grep Z | wc -l)
|
NOREAP=$(zombies)
|
||||||
echo -n without reaping, we have $NOREAP zombies...
|
echo -n without reaping, we have $NOREAP zombies...
|
||||||
if [ "$NOREAP" -le "0" ]
|
if [ "$NOREAP" -le "0" ]
|
||||||
then
|
then
|
||||||
@ -14,12 +29,11 @@ then
|
|||||||
else
|
else
|
||||||
echo " good"
|
echo " good"
|
||||||
fi
|
fi
|
||||||
docker stop $C >/dev/null
|
stop_rm $C
|
||||||
docker rm $C >/dev/null
|
|
||||||
|
|
||||||
C=$(docker run -d zombietest /runsvinit)
|
C=$(docker run -d zombietest /runsvinit)
|
||||||
sleep $SLEEP
|
sleep $SLEEP
|
||||||
YESREAP=$(docker exec $C ps -o pid,stat | grep Z | wc -l)
|
YESREAP=$(zombies)
|
||||||
echo -n with reaping, we have $YESREAP zombies...
|
echo -n with reaping, we have $YESREAP zombies...
|
||||||
if [ "$YESREAP" -gt "0" ]
|
if [ "$YESREAP" -gt "0" ]
|
||||||
then
|
then
|
||||||
@ -28,7 +42,6 @@ then
|
|||||||
else
|
else
|
||||||
echo " good"
|
echo " good"
|
||||||
fi
|
fi
|
||||||
docker stop $C >/dev/null
|
stop_rm $C
|
||||||
docker rm $C >/dev/null
|
|
||||||
|
|
||||||
exit $RC
|
exit $RC
|
||||||
|
Loading…
Reference in New Issue
Block a user