From abfd4957925b7d9dd6d12195bd3d6366c845e9e3 Mon Sep 17 00:00:00 2001 From: Emiliano Ciavatta Date: Wed, 1 Apr 2020 17:37:49 +0200 Subject: Add code coverage trigger --- .gitignore | 2 +- .travis.yml | 15 +++++++++++---- README.md | 3 +++ caronte.go | 2 +- docker-compose.testing.yml | 6 +++--- storage_test.go | 2 +- travis_tests.sh | 2 +- 7 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index df15af9..7991000 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,4 @@ # Build file caronte - +coverage.txt \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 801a37f..1d66f6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,11 +6,18 @@ services: before_script: - docker pull eciavatta/caronte-env + - docker pull mongo:4 - docker-compose -f docker-compose.testing.yml up -d --build -script: - - docker logs -f caronte_caronte_1 | grep "travis" | (read status; if $status -eq "travis_tests_fails"; then exit 1; fi) +script: >- + docker ps -a && + docker logs -f $(docker ps -a -q --filter="name=caronte_caronte") | grep "travis" | + (read status; if [[ $status == "travis_tests_fails" ]]; then exit 1; fi) + +after_success: + - docker cp "$(docker ps -a -q --filter='name=caronte_caronte'):/caronte/coverage.txt" coverage.txt + - bash <(curl -s https://codecov.io/bash) after_script: - - docker logs caronte_caronte_1 - - docker-compose down + - docker logs $(docker ps -a -q --filter="name=caronte_caronte") + - docker-compose -f docker-compose.testing.yml down diff --git a/README.md b/README.md index 8180132..888b88d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # [WIP] Caronte +[![Build Status](https://travis-ci.com/eciavatta/caronte.svg?branch=develop)](https://travis-ci.com/eciavatta/caronte) +[![codecov](https://codecov.io/gh/eciavatta/caronte/branch/develop/graph/badge.svg)](https://codecov.io/gh/eciavatta/caronte) + Caronte is a tool to analyze the network flow during capture the flag events of type attack/defence. It reassembles TCP packets captured in pcap files to rebuild TCP connections, and analyzes each connection to find user-defined patterns. diff --git a/caronte.go b/caronte.go index 934828d..96bb281 100644 --- a/caronte.go +++ b/caronte.go @@ -4,7 +4,7 @@ import ( "fmt" ) -func mainn() { +func main() { // testStorage() storage := NewStorage("localhost", 27017, "testing") err := storage.Connect(nil) diff --git a/docker-compose.testing.yml b/docker-compose.testing.yml index 019628c..51997d6 100644 --- a/docker-compose.testing.yml +++ b/docker-compose.testing.yml @@ -4,7 +4,7 @@ services: mongo: image: mongo:4 networks: - - caronte-net + - acheronet restart: always caronte: @@ -17,11 +17,11 @@ services: depends_on: - mongo networks: - - caronte-net + - acheronet command: "./travis_tests.sh" environment: MONGO_HOST: mongo MONGO_PORT: 27017 networks: - caronte-net: + acheronet: diff --git a/storage_test.go b/storage_test.go index 32a10a6..6b36833 100644 --- a/storage_test.go +++ b/storage_test.go @@ -106,7 +106,7 @@ func TestMain(m *testing.M) { } mongoPort, ok := os.LookupEnv("MONGO_PORT") if !ok { - mongoHost = "27017" + mongoPort = "27017" } uniqueDatabaseName := sha256.Sum256([]byte(time.Now().String())) diff --git a/travis_tests.sh b/travis_tests.sh index cb4363c..5c51823 100755 --- a/travis_tests.sh +++ b/travis_tests.sh @@ -4,7 +4,7 @@ sleep 10 # run tests -go test -v +go test -v -race -coverprofile=coverage.txt -covermode=atomic RET_CODE=$? -- cgit v1.2.3-70-g09d2