add entrypoint init
This commit is contained in:
parent
39c66c7433
commit
1e25473e60
13
Dockerfile
Normal file
13
Dockerfile
Normal file
@ -0,0 +1,13 @@
|
||||
FROM node:lts-alpine
|
||||
LABEL maintainer="lizheming <i@imnerd.org>"
|
||||
RUN apk upgrade --no-cache && apk add --no-cache bash
|
||||
|
||||
ENV ROOT /usr/src/app
|
||||
WORKDIR ${ROOT}
|
||||
|
||||
RUN npm install coveralls
|
||||
|
||||
ADD ./entrypoint.sh .
|
||||
RUN chmod +x ./entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/usr/src/app/entrypoint.sh"]
|
62
entrypoint.sh
Normal file
62
entrypoint.sh
Normal file
@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
start_time=$(date +%s.%N)
|
||||
files="${FILES:-$PLUGIN_FILES}"
|
||||
|
||||
echo "-- Pushing coverage to Coveralls.io..."
|
||||
|
||||
# check coveralls token exist.
|
||||
if [[ -n $PLUGIN_TOKEN ]]; then
|
||||
COVERALLS_REPO_TOKEN=$PLUGIN_TOKEN
|
||||
fi
|
||||
if [[ -z $COVERALLS_REPO_TOKEN ]]; then
|
||||
echo "-- Error: missing coveralls token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
vfiles=""
|
||||
for file in $(echo $files | tr -d '[[:space:]]' | tr "," "\n"); do
|
||||
if [[ -f $PWD/$file ]]; then
|
||||
vfiles="$vfiles -f $PWD/$file"
|
||||
|
||||
echo "-- Sending $file to Coveralls.io --"
|
||||
eval 'cat $PWD/$file | ./node_modules/coveralls/bin/coveralls.js'
|
||||
fi
|
||||
done
|
||||
|
||||
token="-t $COVERALLS_REPO_TOKEN"
|
||||
branch=""
|
||||
commit=""
|
||||
pr=""
|
||||
buildnum=""
|
||||
tag=""
|
||||
if [[ -n $DRONE_BRANCH ]]; then
|
||||
branch="-B $DRONE_BRANCH"
|
||||
fi
|
||||
if [[ -n $DRONE_COMMIT ]]; then
|
||||
commit="-C $DRONE_COMMIT"
|
||||
fi
|
||||
if [[ -n $DRONE_PULL_REQUEST ]]; then
|
||||
pr="-P $DRONE_PULL_REQUEST"
|
||||
fi
|
||||
if [[ -n $DRONE_BUILD_NUMBER ]]; then
|
||||
buildnum="-b $DRONE_BUILD_NUMBER"
|
||||
fi
|
||||
if [[ -n $DRONE_TAG ]]; then
|
||||
tag="-T $DRONE_TAG"
|
||||
fi
|
||||
|
||||
if [[ $PLUGIN_DEBUG = "true" ]]; then
|
||||
echo "-- DEBUG: running following command..."
|
||||
echo "-- DEBUG: coveralls $token $vfiles $branch $commit $pr $buildnum $tag"
|
||||
fi
|
||||
|
||||
end_time=$(date +%s.%N)
|
||||
echo "duration: $(echo "$end_time $start_titme" | awk '{printf "%f", $1 - $2}')s"
|
||||
|
||||
if [[ $exitcode -eq 0 ]]; then
|
||||
echo "-- Coverage successfully pushed to Coveralls!"
|
||||
else
|
||||
echo "-- Coverage failed to push to Coveralls!"
|
||||
fi
|
Loading…
Reference in New Issue
Block a user