mirror of
https://github.com/DominicBreuker/pspy.git
synced 2025-12-21 19:54:53 +00:00
try code coverage reporting on circle
This commit is contained in:
@@ -6,5 +6,5 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- setup_remote_docker
|
- setup_remote_docker
|
||||||
- run: docker build -f ./docker/Dockerfile.testing -t local/pspy-testing:latest .
|
- run: docker build -f ./docker/Dockerfile.testing -v `pwd`/.git:/go/src/github.com/dominicbreuker/pspy/.git -t local/pspy-testing:latest .
|
||||||
- run: docker run -it local/pspy-testing:latest
|
- run: docker run -it local/pspy-testing:latest
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -8,7 +8,7 @@ TEST_DOCKERFILE = $(PROJECT_DIR)/docker/Dockerfile.testing
|
|||||||
|
|
||||||
test:
|
test:
|
||||||
docker build -f $(TEST_DOCKERFILE) -t $(TEST_IMAGE) .
|
docker build -f $(TEST_DOCKERFILE) -t $(TEST_IMAGE) .
|
||||||
docker run -it --rm $(TEST_IMAGE)
|
docker run -it --rm -v $(PROJECT_DIR)/.git:/go/src/github.com/dominicbreuker/pspy/.git $(TEST_IMAGE)
|
||||||
|
|
||||||
dev-build:
|
dev-build:
|
||||||
docker build -f $(DEV_DOCKERFILE) -t $(DEV_IMAGE) .
|
docker build -f $(DEV_DOCKERFILE) -t $(DEV_IMAGE) .
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ FROM golang:1.10-stretch
|
|||||||
RUN apt-get update && apt-get -y install cron python3 sudo procps
|
RUN apt-get update && apt-get -y install cron python3 sudo procps
|
||||||
|
|
||||||
### Test and build ###
|
### Test and build ###
|
||||||
|
|
||||||
# copy source code
|
# copy source code
|
||||||
COPY main.go /go/src/github.com/dominicbreuker/pspy/main.go
|
COPY main.go /go/src/github.com/dominicbreuker/pspy/main.go
|
||||||
COPY cmd /go/src/github.com/dominicbreuker/pspy/cmd
|
COPY cmd /go/src/github.com/dominicbreuker/pspy/cmd
|
||||||
@@ -27,7 +28,7 @@ RUN useradd -ms /bin/bash myuser && \
|
|||||||
adduser myuser sudo && \
|
adduser myuser sudo && \
|
||||||
echo 'myuser ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
echo 'myuser ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
||||||
USER myuser
|
USER myuser
|
||||||
|
RUN sudo chown -R myuser:myuser /go/*
|
||||||
|
|
||||||
# drop into bash shell
|
# drop into bash shell
|
||||||
COPY docker/entrypoint-testing.sh /entrypoint.sh
|
COPY docker/entrypoint-testing.sh /entrypoint.sh
|
||||||
|
|||||||
@@ -1,5 +1,40 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
### test covereage
|
||||||
|
|
||||||
|
if [ -z ${CC_TEST_REPORTER_ID+x} ]; then
|
||||||
|
echo "[+] skipping test coverage"
|
||||||
|
else
|
||||||
|
echo "[+] reporting test coverage"
|
||||||
|
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
||||||
|
chmod +x ./cc-test-reporter
|
||||||
|
|
||||||
|
# git config --global user.email "dummy@example.com"
|
||||||
|
# git config --global user.name "Mr Robot"
|
||||||
|
# git init
|
||||||
|
# git add .
|
||||||
|
# git commit -m 'commit that makes cc test reporter happy'
|
||||||
|
|
||||||
|
./cc-test-reporter before-build
|
||||||
|
|
||||||
|
for pkg in $(go list ./... | grep -v main); do
|
||||||
|
echo "doing $pkg"
|
||||||
|
go test -coverprofile=$(echo $pkg | tr / -).cover $pkg
|
||||||
|
done
|
||||||
|
echo "mode: set" > c.out
|
||||||
|
grep -h -v "^mode:" ./*.cover >> c.out
|
||||||
|
rm -f *.cover
|
||||||
|
|
||||||
|
echo "reporting now"
|
||||||
|
./cc-test-reporter after-build
|
||||||
|
|
||||||
|
rm c.out
|
||||||
|
|
||||||
|
rm ./cc-test-reporter
|
||||||
|
fi
|
||||||
|
|
||||||
|
### integration test
|
||||||
|
|
||||||
sudo cron -f &
|
sudo cron -f &
|
||||||
sleep 1
|
sleep 1
|
||||||
sudo ps | grep cron 1>/dev/null
|
sudo ps | grep cron 1>/dev/null
|
||||||
|
|||||||
Reference in New Issue
Block a user