keep-around/948fa0ddec6a590e5e72618465acd903930133f8
Martin/Geno 4 years ago
parent bfb3da9338
commit 948fa0ddec
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
  1. 8
      .ci/check-gofmt
  2. 25
      .ci/check-testfiles
  3. 34
      .drone.yml
  4. 50
      .gitlab-ci.yml
  5. 47
      README.md
  6. 0
      config_example.conf

@ -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")

@ -1,34 +0,0 @@
workspace:
base: /go
path: src/dev.sum7.eu/genofire/wifictld-analyzer
pipeline:
build:
image: golang:latest
commands:
- go get ./...
- go build
codestyle:
image: golang:latest
commands:
- go get github.com/client9/misspell/cmd/misspell
- misspell -error .
- if [ -n "$(gofmt -s -l .)" ]; then echo "Go code is not formatted, run 'gofmt -s -w .'" >&2; exit 1; fi
test:
image: golang:latest
commands:
- go get github.com/stretchr/testify/assert
- go test ./... -v -cover
test-race:
image: golang:latest
commands:
- go get github.com/stretchr/testify/assert
- go test ./... -v -race
release:
image: plugins/gitea-release
base_url: https://dev.sum7.eu
secrets: [ gitea_token ]
files: /go/bin/analyzer
draft: true
when:
event: tag

@ -0,0 +1,50 @@
image: golang:latest
stages:
- build
- test
- deploy
before_script:
- mkdir -p "/go/src/dev.sum7.eu/$CI_PROJECT_NAMESPACE/"
- cp -R "/builds/$CI_PROJECT_PATH" "/go/src/dev.sum7.eu/$CI_PROJECT_NAMESPACE/"
- cd "/go/src/dev.sum7.eu/$CI_PROJECT_PATH"
- go get -d -t ./...
build-my-project:
stage: build
script:
- go install "dev.sum7.eu/$CI_PROJECT_PATH"
- mv "/go/bin/$CI_PROJECT_NAME" "/builds/$CI_PROJECT_PATH"
artifacts:
paths:
- config_example.conf
- "$CI_PROJECT_NAME"
test-my-project:
stage: test
script:
- go get github.com/client9/misspell/cmd/misspell
- misspell -error .
- ./.ci/check-gofmt
- ./.ci/check-testfiles
- go test $(go list ./... | grep -v /vendor/) -v -coverprofile .testCoverage.txt
artifacts:
paths:
- .testCoverage.txt
test-race-my-project:
stage: test
script:
- go test -race ./...
deploy:
stage: deploy
only:
- master
script:
- go install "dev.sum7.eu/$CI_PROJECT_PATH"
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- scp -6 -o StrictHostKeyChecking=no -P $SSH_PORT "/go/bin/$CI_PROJECT_NAME" "$CI_PROJECT_NAME@$SSH_HOST":/opt/$CI_PROJECT_NAME/bin
- ssh -6 -o StrictHostKeyChecking=no -p $SSH_PORT "$CI_PROJECT_NAME@$SSH_HOST" sudo /usr/bin/systemctl restart $CI_PROJECT_NAME

@ -0,0 +1,47 @@
# wifictld-analyzer
[![Build Status](https://dev.sum7.eu/genofire/wifictld-analyzer/badges/master/build.svg)](https://dev.sum7.eu/genofire/wifictld-analyzer/pipelines)
[![Go Report Card](https://goreportcard.com/badge/dev.sum7.eu/genofire/wifictld-analyzer)](https://goreportcard.com/report/dev.sum7.eu/genofire/wifictld-analyzer)
[![GoDoc](https://godoc.org/dev.sum7.eu/genofire/wifictld-analyzer?status.svg)](https://godoc.org/dev.sum7.eu/genofire/wifictld-analyzer)
## Get wifictld-analyzer
#### Download
Latest Build binary from ci here:
[Download All](https://dev.sum7.eu/genofire/wifictld-analyzer/-/jobs/artifacts/master/download/?job=build-my-project) (with config example)
[Download Binary](https://dev.sum7.eu/genofire/wifictld-analyzer/-/jobs/artifacts/master/raw/wifictld-analyzer?inline=false&job=build-my-project)
#### Build
```bash
go get -u dev.sum7.eu/genofire/wifictld-analyzer
```
## Configure
see `config_example.conf`
## Start / Boot
_/lib/systemd/system/wifictld-analyzer.service_ :
```
[Unit]
Description=wifictld-analyzer
After=network.target
[Service]
Type=simple
# User=notRoot
ExecStart=/opt/go/bin/wifictld-analyzer controller /etc/wifictld-analyzer.conf
Restart=always
RestartSec=5sec
[Install]
WantedBy=multi-user.target
```
Start: `systemctl start wifictld-analyzer`
Autostart: `systemctl enable wifictld-analyzer`
Loading…
Cancel
Save