Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
eth-log-alerting
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Server Tools
eth-log-alerting
Commits
f1c8a697
Commit
f1c8a697
authored
6 years ago
by
Erick Hitter
Browse files
Options
Downloads
Plain Diff
Merge branch 'fix/7-improve-ci' into 'master'
Better CI Closes
#7
See merge request
!4
parents
286f5a47
d23d4184
No related branches found
No related tags found
1 merge request
!4
Better CI
Pipeline
#4427
failed
3 years ago
Stage: test
Stage: build
Changes
4
Pipelines
187
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitlab-ci.yml
+48
-23
48 additions, 23 deletions
.gitlab-ci.yml
Makefile
+39
-0
39 additions, 0 deletions
Makefile
eth-log-alerting_test.go
+19
-0
19 additions, 0 deletions
eth-log-alerting_test.go
tools/coverage.sh
+29
-0
29 additions, 0 deletions
tools/coverage.sh
with
135 additions
and
23 deletions
.gitlab-ci.yml
+
48
−
23
View file @
f1c8a697
# This file is a template, and might need editing before it works on your project.
image
:
golang:latest
image
:
containers.ethitter.com:443/docker/images/golang:latest
variables
:
REPO_NAME
:
git.ethitter.com/debian/eth-log-alerting
# The problem is that to be able to use go get, one needs to put
# the repository in the $GOPATH. So for example if your gitlab domain
# is gitlab.com, and that your repository is namespace/project, and
# the default GOPATH being /go, then you'd need to have your
# repository in /go/src/gitlab.com/namespace/project
# Thus, making a symbolic link corrects this.
cache
:
paths
:
-
/apt-cache
-
$GOPATH/src/github.com
-
$GOPATH/src/golang.org
-
$GOPATH/src/google.golang.org
-
$GOPATH/src/gopkg.in
stages
:
-
test
-
build
before_script
:
-
mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
-
ln -svf
$CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
-
cp -R
$CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
-
cd $GOPATH/src/$REPO_NAME
-
cp config-sample.json config.json
-
go version
-
export CC=clang-5.0
-
go get github.com/asaskevich/govalidator
-
go get github.com/ashwanthkumar/slack-go-webhook
-
go get github.com/hpcloud/tail
-
make dep
stages
:
-
test
-
build
unit_tests
:
stage
:
test
script
:
-
make test
race_detector
:
stage
:
test
script
:
-
make race
memory_sanitizer
:
stage
:
test
script
:
-
make msan
code_coverage
:
stage
:
test
script
:
-
make coverage
code_coverage_report
:
stage
:
test
script
:
-
make coverhtml
only
:
-
master
format
:
lint_code
:
stage
:
test
script
:
-
go tool vet -composites=false -shadow=true *.go
-
go test -race $(go list ./... | grep -v /vendor/)
-
make lint
comp
il
e
:
bu
il
d
:
stage
:
build
script
:
-
go get github.com/mitchellh/gox
-
gox -output="eth-log-alerting-builds/{{.Dir}}_{{.OS}}_{{.Arch}}" -parallel=4
-
make
artifacts
:
paths
:
-
eth-log-alerting-builds/
-
eth-log-alerting-builds/
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Makefile
0 → 100644
+
39
−
0
View file @
f1c8a697
PROJECT_NAME
:=
"eth-log-alerting"
PKG
:=
"git.ethitter.com/debian/
$(
PROJECT_NAME
)
"
PKG_LIST
:=
$(
shell go list
${
PKG
}
/... |
grep
-v
/vendor/
)
GO_FILES
:=
$(
shell find
.
-name
'*.go'
|
grep
-v
/vendor/ |
grep
-v
_test.go
)
.PHONY
:
all dep build clean test coverage coverhtml lint
all
:
build
lint
:
@
golint
-set_exit_status
${
PKG_LIST
}
test
:
@
go
test
-v
${
PKG_LIST
}
race
:
dep
@
go
test
-v
-race
${
PKG_LIST
}
msan
:
dep
@
go
test
-v
-msan
${
PKG_LIST
}
coverage
:
./tools/coverage.sh
;
coverhtml
:
./tools/coverage.sh html
;
dep
:
@
go get
-v
-d
./...
@
go get github.com/mitchellh/gox
build
:
dep
@
gox
-output
=
"
${
CI_PROJECT_DIR
}
/eth-log-alerting-builds/{{.Dir}}_{{.OS}}_{{.Arch}}"
-parallel
=
4
clean
:
@
rm
-f
$(
PROJECT_NAME
)
help
:
@
grep
-h
-E
'^[a-zA-Z_-]+:.*?## .*$$'
$(
MAKEFILE_LIST
)
|
awk
'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
This diff is collapsed.
Click to expand it.
eth-log-alerting_test.go
0 → 100644
+
19
−
0
View file @
f1c8a697
package
main
import
"testing"
func
TestValidatePath
(
t
*
testing
.
T
)
{
emptyString
:=
""
notValid
:=
validatePath
(
&
emptyString
)
if
notValid
==
true
{
t
.
Error
(
"Empty path shouldn't validate"
)
}
sampleConfig
:=
"./config-sample.json"
valid
:=
validatePath
(
&
sampleConfig
)
if
valid
!=
true
{
t
.
Error
(
"Couldn't validate path to sample config"
)
}
}
This diff is collapsed.
Click to expand it.
tools/coverage.sh
0 → 100755
+
29
−
0
View file @
f1c8a697
#!/bin/bash
#
# Code coverage generation
COVERAGE_DIR
=
"
${
COVERAGE_DIR
:-
coverage
}
"
PKG_LIST
=
$(
go list ./... |
grep
-v
/vendor/
)
# Create the coverage files directory
mkdir
-p
"
$COVERAGE_DIR
"
;
# Create a coverage file for each package
for
package
in
${
PKG_LIST
}
;
do
go
test
-covermode
=
count
-coverprofile
"
${
COVERAGE_DIR
}
/
${
package
##*/
}
.cov"
"
$package
"
;
done
;
# Merge the coverage profile files
echo
'mode: count'
>
"
${
COVERAGE_DIR
}
"
/coverage.cov
;
tail
-q
-n
+2
"
${
COVERAGE_DIR
}
"
/
*
.cov
>>
"
${
COVERAGE_DIR
}
"
/coverage.cov
;
# Display the global code coverage
go tool cover
-func
=
"
${
COVERAGE_DIR
}
"
/coverage.cov
;
# If needed, generate HTML report
if
[
"
$1
"
==
"html"
]
;
then
go tool cover
-html
=
"
${
COVERAGE_DIR
}
"
/coverage.cov
-o
coverage.html
;
fi
# Remove the coverage files directory
rm
-rf
"
$COVERAGE_DIR
"
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment