Skip to content

Commit

Permalink
[TASK] add rules for documentation, PR and testing
Browse files Browse the repository at this point in the history
(#76 )
  • Loading branch information
genofire committed Dec 31, 2017
1 parent 69079b7 commit f423da3
Show file tree
Hide file tree
Showing 21 changed files with 1,014 additions and 25 deletions.
5 changes: 5 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Contributing is welcome

Pull requests are welcome without the need of opening an issue. If you're unsure
about your feature or your implementation open an issue and discuss your
suggested changes.
16 changes: 16 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!--- Use a prefix like [TASK], [BUGFIX], [DOC] or [TEST] and provide a general summary of your changes in the Title above -->

## Description
<!--- Describe your changes -->

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->

## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] My code follows the code style of this project.
- [ ] I have added also tests for my new code.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
18 changes: 18 additions & 0 deletions .test-coverage
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,22 @@ if [ "$FAIL" -eq 0 ]; then
bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN -f profile.cov
fi

# Test if every package has testfiles
for dir in $(find . -name "*.go" -printf '%h\0'| sort -zu | sed -z 's/$/\n/');
do
if [ "$(ls $dir/*_test.go 2> /dev/null | wc -l)" -eq "0" ]; then
echo -n "no test files for $dir";
case $dir in
'.' | './cmd' | './database/graphite')
echo " - but ignored";
continue
;;
*)
echo "";
FAIL=1;
;;
esac
fi
done

exit $FAIL
15 changes: 5 additions & 10 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Howto install Yanic

## go

### Install
```sh
cd /usr/local/
wget https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz
tar xvf go1.8.linux-amd64.tar.gz
rm go1.8.linux-amd64.tar.gz
wget https://storage.googleapis.com/golang/go1.9.1.linux-amd64.tar.gz -O go-release-linux-amd64.tar.gz
tar xvf go-release-linux-amd64.tar.gz
rm go-release-linux-amd64.tar.gz
```

### Configure go
Expand All @@ -16,12 +17,6 @@ export GOPATH=/opt/go
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
```

and these in the shell startup file of a normal user:
```sh
export GOPATH=~/go
export PATH=$PATH:$GOPATH/bin
```

## Yanic

### Compile
Expand Down Expand Up @@ -65,7 +60,7 @@ the same directory as the `dataPath`. Change the path in the section

### Service
```sh
cp /opt/go/src/github.com/FreifunkBremen/yanic/contrib/init/linux-systemd/yanic.service /lib/systemd/system/
cp /opt/go/src/github.com/FreifunkBremen/yanic/contrib/init/linux-systemd/yanic.service /lib/systemd/system/yanic.service
systemctl daemon-reload
systemctl start yanic
systemctl enable yanic
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ Yet another node info collector
In the first step Yanic sends a multicast message to the group `ff02:0:0:0:0:0:2:1001` and port `1001`.
Recently seen nodes that does not reply are requested via a unicast message.

## [Documentation](https://www.gitbook.com/book/freifunkbremen/yanic/details)
* [Webview](https://freifunkbremen.gitbooks.io/yanic/content/)
* [PDF](https://www.gitbook.com/download/pdf/book/freifunkbremen/yanic)
* [Mobi](https://www.gitbook.com/download/mobi/book/freifunkbremen/yanic)
* [ePUB](https://www.gitbook.com/download/epub/book/freifunkbremen/yanic)
## Documentation
Take a look at the [git](https://github.com/FreifunkBremen/yanic/blob/master/SUMMARY.md) or [Gitbook](https://freifunkbremen.gitbooks.io/yanic/content/)


## Configuration
Read comments in [config_example.toml](config_example.toml) for more information.
Expand Down
15 changes: 15 additions & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Summary

* [Home](/docs/index.md)
* [About](/docs/home_about.md)
* [Running](/docs/home_running.md)

* Documentation
* [Build and Install](/docs/docs_install.md)
* [Usage](/docs/docs_usage.md)
* [Quick Configuration](/docs/docs_quick_conf.md)
* [Configuration](/docs/docs_configuration.md)

* Developing
* [Add new database type](/docs/dev_database.md)
* [Add new output type](/docs/dev_output.md)
22 changes: 22 additions & 0 deletions book.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"plugins": [
"theme-api",
"anchors",
"sitemap"
],
"pluginsConfig": {
"theme-api": {
"split": true,
"languages": [
{
"lang": "toml",
"name": "TOML",
"default": true
}
]
},
"sitemap": {
"hostname": "https://freifunkbremen.gitbooks.io/yanic/"
}
}
}
15 changes: 7 additions & 8 deletions config_example.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is the config file for Yanic written in "Tom's Obvious, Minimal Language."
# syntax: https://github.com/toml-lang/toml
# (if you need somethink multiple times, checkout out the [[table]] section)
# (if you need somethink multiple times, checkout out the [[array of table]] section)

# Send respondd request to update information
[respondd]
Expand All @@ -27,7 +27,6 @@ webroot = "/var/www/html/meshviewer"


[nodes]
enable = true
# Cache file
# a json file to cache all data collected directly from respondd
state_path = "/var/lib/yanic/state.json"
Expand Down Expand Up @@ -138,17 +137,12 @@ password = ""
# Tagging of the data (optional)
[database.connection.influxdb.tags]
# Tags used by Yanic would override the tags from this config
# nodeid, hostname, owner, model and firmware are tags which are already used
# nodeid, hostname, owner, model, firmware_base, firmware_release,frequency11g and frequency11a are tags which are already used
#tagname1 = "tagvalue 1"
# some usefull e.g.:
#system = "productive"
#site = "ffhb"

# Logging
[[database.connection.logging]]
enable = false
path = "/var/log/yanic.log"

# Graphite settings
[[database.connection.graphite]]
enable = false
Expand All @@ -160,3 +154,8 @@ address = "localhost:2003"
# then the prefix can be set to anything (including the empty string) since you
# probably wont care much about "polluting" the namespace.
prefix = "freifunk"

# Logging
[[database.connection.logging]]
enable = false
path = "/var/log/yanic.log"
49 changes: 49 additions & 0 deletions docs/dev_database.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Add new database type

Write a new package to implement the interface [database.Connection:](https://github.com/FreifunkBremen/yanic/blob/master/database/database.go)

```go
type Connection interface {
InsertNode(node *runtime.Node)

InsertLink(*runtime.Link, time.Time)

InsertGlobals(*runtime.GlobalStats, time.Time, string)

PruneNodes(deleteAfter time.Duration)

Close()
}
```

**InsertNode** is stores statistics per node

**InsertLink** is stores statistics per link

**InsertGlobals** is stores global statistics (by `site_code`, and "global" like in `runtime.GLOBAL_SITE` overall sites).

**PruneNodes** is prunes historical per-node data

**Close** is called during shutdown of Yanic.



For startup, you need to bind your database type by calling `database.RegisterAdapter("typeofdatabase",ConnectFunction)`

it should be in the `func init() {}` of your package.



The _typeofdatabase_ is used as mapping in the configuration `[[database.connection.typeofdatabase]]` the `map[string]interface{}` of the content are parsed to the _ConnectFunction_ and on of your implemented `Connection` or a `error` is needed as result.



Short: the function signature of _ConnectFunction_ should be `func Connect(configuration interface{}) (Connection, error)`



At last add you import string to compile the your database as well in this [all](https://github.com/FreifunkBremen/yanic/blob/master/database/all/main.go) package.



TIP: take a look in the easy database type [logging](https://github.com/FreifunkBremen/yanic/blob/master/database/logging/file.go).
30 changes: 30 additions & 0 deletions docs/dev_output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Add new output type

Write a new package to implement the interface [output.Output:](https://github.com/FreifunkBremen/yanic/blob/master/output/output.go)

```go
type Output interface {
Save(nodes *runtime.Nodes)
}
```

**Save** a pre-filtered state of the Nodes



For startup, you need to bind your output type by calling
`output.RegisterAdapter("typeofoutput",Register)`

it should be in the `func init() {}` of your package.



The _typeofoutput_ is used as mapping in the configuration `[[nodes.output.typeofoutput]]` the `map[string]interface{}` of the content are parsed to the _Register_ and on of your implemented `Output` or a `error` is needed as result.



Short: the function signature of _Register_ should be `func Register(configuration map[string]interface{}) (Output, error)`



At last add you import string to compile the your database as well in this [all](https://github.com/FreifunkBremen/yanic/blob/master/output/all/main.go) package.
Loading

0 comments on commit f423da3

Please sign in to comment.