Actions (#458)
* remove coverage report from docker, add build and test step to actions * install deps to actions * formatting fix * install go 1.13 * change linter location
This commit is contained in:
@@ -10,37 +10,52 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Docker version
|
||||
run: docker version
|
||||
- name: Debug if needed
|
||||
|
||||
- name: debug if needed
|
||||
run: |
|
||||
export DEBUG=${DEBUG:-false}
|
||||
|
||||
if [[ "$DEBUG" == "true" ]]; then
|
||||
env
|
||||
fi
|
||||
env:
|
||||
DEBUG: ${{secrets.DEBUG}}
|
||||
- name: Build image
|
||||
|
||||
- name: install go
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: 1.13
|
||||
|
||||
- name: build and test backend
|
||||
run: |
|
||||
export GIT_BRANCH="${GITHUB_REF/refs\/heads\//}"
|
||||
export GIT_TAG="${GITHUB_REF/refs\/tags\//}"
|
||||
export TZ="America/Chicago"
|
||||
date
|
||||
cd backend/app
|
||||
go test -mod=vendor -timeout=60s -covermode=count -coverprofile=$GITHUB_WORKSPACE/profile.cov_tmp ./...
|
||||
cat $GITHUB_WORKSPACE/profile.cov_tmp | grep -v "_mock.go" > $GITHUB_WORKSPACE/profile.cov
|
||||
|
||||
if [[ "$GIT_TAG" != "$GITHUB_REF" ]]; then
|
||||
export GIT_BRANCH=$GIT_TAG
|
||||
fi
|
||||
- name: install golangci-lint and goveralls
|
||||
run: |
|
||||
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $GITHUB_WORKSPACE v1.20.0
|
||||
go get -u github.com/mattn/goveralls
|
||||
ls -la $(go env GOPATH)/bin/goveralls
|
||||
|
||||
docker build \
|
||||
--build-arg CI=github \
|
||||
--build-arg GIT_BRANCH=$GIT_BRANCH \
|
||||
--build-arg GITHUB_REF=$GITHUB_REF \
|
||||
--build-arg GITHUB_SHA=$GITHUB_SHA \
|
||||
--build-arg GITHUB_EVENT_NAME=$GITHUB_EVENT_NAME \
|
||||
--build-arg GITHUB_EVENT_PATH=$GITHUB_EVENT_PATH \
|
||||
--build-arg GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
|
||||
--build-arg COVERALLS_TOKEN=$COVERALLS_TOKEN \
|
||||
.
|
||||
- name: run backend linters
|
||||
run: |
|
||||
cd backend
|
||||
$GITHUB_WORKSPACE/golangci-lint run --out-format=tab --disable-all --tests=false --enable=unconvert \
|
||||
--enable=megacheck --enable=structcheck --enable=gas --enable=gocyclo --enable=dupl --enable=misspell \
|
||||
--enable=unparam --enable=varcheck --enable=deadcode --enable=typecheck \
|
||||
--enable=ineffassign --enable=varcheck ./... ;
|
||||
|
||||
- name: submit coverage
|
||||
run: |
|
||||
cd backend
|
||||
$(go env GOPATH)/bin/goveralls -service="GitHub Action" -coverprofile=$GITHUB_WORKSPACE/profile.cov -repotoken $COVERALLS_TOKEN
|
||||
env:
|
||||
COVERALLS_TOKEN: ${{secrets.COVERALLS_TOKEN}}
|
||||
COVERALLS_TOKEN: ${{secrets.COVERALLS_TOKEN}}
|
||||
|
||||
- name: build docker image
|
||||
run: docker build --build-arg SKIP_BACKEND_TEST=true --build-arg CI=github .
|
||||
|
||||
+1
-21
@@ -1,15 +1,6 @@
|
||||
FROM umputun/baseimage:buildgo-latest as build-backend
|
||||
|
||||
ARG COVERALLS_TOKEN
|
||||
ARG CI
|
||||
ARG GIT_BRANCH
|
||||
|
||||
ARG GITHUB_SHA
|
||||
ARG GITHUB_REF
|
||||
ARG GITHUB_REPOSITORY
|
||||
ARG GITHUB_EVENT_NAME
|
||||
ARG GITHUB_EVENT_PATH
|
||||
|
||||
ARG DRONE
|
||||
ARG DRONE_TAG
|
||||
ARG DRONE_COMMIT
|
||||
@@ -25,28 +16,17 @@ WORKDIR /build/backend
|
||||
|
||||
ENV GOFLAGS="-mod=vendor"
|
||||
|
||||
RUN env
|
||||
|
||||
# run tests
|
||||
RUN \
|
||||
cd app && \
|
||||
if [ -z "$SKIP_BACKEND_TEST" ] ; then \
|
||||
go test -p 1 -timeout="${BACKEND_TEST_TIMEOUT:-30s}" -covermode=count -coverprofile=/profile.cov_tmp ./... && \
|
||||
cat /profile.cov_tmp | grep -v "_mock.go" > /profile.cov ; \
|
||||
else echo "skip backend test" ; fi
|
||||
|
||||
# linters
|
||||
RUN if [ -z "$SKIP_BACKEND_TEST" ] ; then \
|
||||
golangci-lint run --out-format=tab --disable-all --tests=false --enable=unconvert \
|
||||
--enable=megacheck --enable=structcheck --enable=gas --enable=gocyclo --enable=dupl --enable=misspell \
|
||||
--enable=unparam --enable=varcheck --enable=deadcode --enable=typecheck \
|
||||
--enable=ineffassign --enable=varcheck ./... ; \
|
||||
else echo "skip backend linters" ; fi
|
||||
|
||||
# submit coverage to coverals if COVERALLS_TOKEN in env
|
||||
RUN if [ -z "$COVERALLS_TOKEN" ] ; then \
|
||||
echo "coverall not enabled" ; \
|
||||
else goveralls -coverprofile=/profile.cov -repotoken $COVERALLS_TOKEN || echo "coverall failed!"; fi
|
||||
else echo "skip backend tests and linter" ; fi
|
||||
|
||||
# if DRONE presented use DRONE_* git env to make version
|
||||
RUN \
|
||||
|
||||
Reference in New Issue
Block a user