add gitlab-ci build
This commit is contained in:
parent
f597f29f72
commit
e063fa2e12
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
result="$(gofmt -s -l . | grep -v '^vendor/' )"
|
||||||
|
if [ -n "$result" ]; then
|
||||||
|
echo "Go code is not formatted, run 'gofmt -s -w .'" >&2
|
||||||
|
echo "$result"
|
||||||
|
exit 1
|
||||||
|
fi
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# checks if every desired package has test files
|
||||||
|
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
source_re = re.compile(".*\.go")
|
||||||
|
test_re = re.compile(".*_test\.go")
|
||||||
|
missing = False
|
||||||
|
|
||||||
|
for root, dirs, files in os.walk("."):
|
||||||
|
# ignore some paths
|
||||||
|
if root == "." or root.startswith("./vendor") or root.startswith("./."):
|
||||||
|
continue
|
||||||
|
|
||||||
|
# source files but not test files?
|
||||||
|
if len(filter(source_re.match, files)) > 0 and len(filter(test_re.match, files)) == 0:
|
||||||
|
print("no test files for {}".format(root))
|
||||||
|
missing = True
|
||||||
|
|
||||||
|
if missing:
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
print("every package has test files")
|
|
@ -0,0 +1,35 @@
|
||||||
|
image: golang:latest
|
||||||
|
stages:
|
||||||
|
- build
|
||||||
|
- test
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- mkdir -p /go/src/github.com/FreifunkBremen/
|
||||||
|
- cp -R $CI_PROJECT_DIR /go/src/github.com/FreifunkBremen/
|
||||||
|
- go get -v github.com/FreifunkBremen/$CI_PROJECT_NAME
|
||||||
|
- cd /go/src/github.com/FreifunkBremen/$CI_PROJECT_NAME
|
||||||
|
|
||||||
|
build-my-project:
|
||||||
|
stage: build
|
||||||
|
script:
|
||||||
|
- mkdir $CI_PROJECT_DIR/bin/
|
||||||
|
- cp /go/bin/$CI_PROJECT_NAME $CI_PROJECT_DIR/bin/$CI_PROJECT_NAME
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- bin/$CI_PROJECT_NAME
|
||||||
|
- config_example.conf
|
||||||
|
|
||||||
|
test-my-project:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- ./.ci/check-gofmt
|
||||||
|
- ./.ci/check-testfiles
|
||||||
|
- go get -d github.com/stretchr/testify/assert
|
||||||
|
- go test $(go list ./... | grep -v /vendor/ | grep -v /webroot/) -v -coverprofile .testCoverage.txt
|
||||||
|
- go tool cover -func=.testCoverage.txt
|
||||||
|
|
||||||
|
test-race-my-project:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- go get -d github.com/stretchr/testify/assert
|
||||||
|
- go test -race ./...
|
Loading…
Reference in New Issue