Skip to content

Commit

Permalink
chore: add codeclimate (#56)
Browse files Browse the repository at this point in the history
* add codeclimate
* remove codecov
* add entropy troubleshooting
* fix flag type
  • Loading branch information
briangann authored Jun 29, 2021
1 parent 75d6cc8 commit 4bfcfc9
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 24 deletions.
83 changes: 65 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ parameters:
ssh-fingerprint:
type: string
default: ${GITHUB_SSH_FINGERPRINT}
codeclimate-reporter-id:
type: string
default: ${CC_TEST_REPORTER_ID}

aliases:
# Workflow filters
Expand All @@ -15,23 +18,33 @@ workflows:
version: 2
build_workflow:
jobs:
- cmd_lint
- cmd_test
- build:
requires:
- cmd_lint
- cmd_test
- approve_release:
type: approval
requires:
- build
filters: *filter-only-main
- publish_github_release:
requires:
- approve_release
filters: *filter-only-main
- cmd_lint
- cmd_test
- build:
requires:
- cmd_lint
- cmd_test
- code_coverage:
requires:
- cmd_lint
- cmd_test
- upload_coverage:
requires:
- code_coverage
- approve_release:
type: approval
requires:
- upload_coverage
filters: *filter-only-main
- publish_github_release:
requires:
- approve_release
filters: *filter-only-main

executors:
default_exec:
docker:
- image: grafana/grafana-plugin-ci:1.1.2-alpine
go_exec:
docker:
- image: circleci/golang:1.16
Expand Down Expand Up @@ -68,17 +81,51 @@ jobs:
name: Test and Coverage
command: |
mkdir -p coverage
#go test -covermode=count -coverprofile=coverage/count.out ./...
go test -v -coverpkg=./... --coverprofile=coverage/coverage.out ./...
go test ./... -coverprofile coverage/cover.out; go tool cover -func coverage/cover.out
go tool cover -html=coverage/coverage.out -o coverage/coverage.html
go tool cover -func coverage/coverage.out
go tool cover -html=coverage/coverage.out -o coverage/coverage.html
- persist_to_workspace:
root: .
paths:
- coverage
- store_artifacts:
path: coverage

code_coverage:
executor: go_exec
working_directory: /go/src/github.com/grafana/grafana-kiosk
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Run coverage report
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter format-coverage -t gocov --debug -o ci/jobs/code_coverage/codeclimate.json coverage/coverage.out || true
- persist_to_workspace:
root: .
paths:
- ci/jobs/code_coverage
- store_artifacts:
path: ci/jobs/code_coverage

upload_coverage:
executor: go_exec
working_directory: /go/src/github.com/grafana/grafana-kiosk
steps:
- attach_workspace:
at: .
- run:
name: Upload coverage results to Code Climate
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter upload-coverage -i ci/jobs/code_coverage/codeclimate.json
- store_artifacts:
path: ci/jobs/upload_coverage

publish_github_release:
working_directory: /go/src/github.com/grafana/grafana-kiosk
docker:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 1.0.4

- Fix startup issue with new flags

## 1.0.3

- OAuth merged
Expand Down
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Grafana Kiosk

[![CircleCI](https://circleci.com/gh/grafana/grafana-kiosk.svg?style=svg)](https://circleci.com/gh/grafana/grafana-kiosk)
[![Go Report Card](https://goreportcard.com/badge/github.com/grafana/grafana-kiosk)](https://goreportcard.com/report/github.com/grafana/grafana-kiosk) [![codecov](https://codecov.io/gh/grafana/grafana-kiosk/branch/master/graph/badge.svg)](https://codecov.io/gh/grafana/grafana-kiosk)
[![Go Report Card](https://goreportcard.com/badge/github.com/grafana/grafana-kiosk)](https://goreportcard.com/report/github.com/grafana/grafana-kiosk)
[![Maintainability](https://api.codeclimate.com/v1/badges/8cdc385a20fe3d480455/maintainability)](https://codeclimate.com/github/grafana/grafana-kiosk/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/8cdc385a20fe3d480455/test_coverage)](https://codeclimate.com/github/grafana/grafana-kiosk/test_coverage)

A very useful feature of Grafana is the ability to display dashboards and playlists on a large TV.

Expand Down Expand Up @@ -313,6 +315,21 @@ Logs:
journalctl -u grafana-kiosk
```

## Troubleshooting

### Timeout Launching

```LOG
2020/08/24 10:18:41 Launching local login kiosk
panic: websocket url timeout reached
```

Often this is due to lack of entropy, for linux you would need to install `rng-tools` (or an equivalent).

```BASH
apt install rng-tools
```

## Building

A Makefile is provided for building the utility.
Expand All @@ -325,7 +342,6 @@ This will generate executables in "bin" that can be run on a variety of platform

## TODO

- Support for OAuth2 logins
- RHEL/CentOS auto-startup
- Everything in issues!

Expand Down
2 changes: 1 addition & 1 deletion pkg/kiosk/anonymous_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func GrafanaKioskAnonymous(cfg *Config) {
chromedp.Flag("ignore-certificate-errors", cfg.Target.IgnoreCertificateErrors),
chromedp.Flag("test-type", cfg.Target.IgnoreCertificateErrors),
chromedp.Flag("window-position", cfg.General.WindowPosition),
chromedp.Flag("check-for-update-interval", 31536000),
chromedp.Flag("check-for-update-interval", "31536000"),
chromedp.UserDataDir(dir),
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/kiosk/grafana_com_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func GrafanaKioskGCOM(cfg *Config) {
chromedp.Flag("disable-notifications", true),
chromedp.Flag("disable-overlay-scrollbar", true),
chromedp.Flag("window-position", cfg.General.WindowPosition),
chromedp.Flag("check-for-update-interval", 31536000),
chromedp.Flag("check-for-update-interval", "31536000"),
chromedp.UserDataDir(dir),
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/kiosk/grafana_genericoauth_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func GrafanaKioskGenericOauth(cfg *Config) {
chromedp.Flag("disable-notifications", true),
chromedp.Flag("disable-overlay-scrollbar", true),
chromedp.Flag("window-position", cfg.General.WindowPosition),
chromedp.Flag("check-for-update-interval", 31536000),
chromedp.Flag("check-for-update-interval", "31536000"),
chromedp.UserDataDir(dir),
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/kiosk/local_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func GrafanaKioskLocal(cfg *Config) {
chromedp.Flag("ignore-certificate-errors", cfg.Target.IgnoreCertificateErrors),
chromedp.Flag("test-type", cfg.Target.IgnoreCertificateErrors),
chromedp.Flag("window-position", cfg.General.WindowPosition),
chromedp.Flag("check-for-update-interval", 31536000),
chromedp.Flag("check-for-update-interval", "31536000"),
chromedp.UserDataDir(dir),
}

Expand Down

0 comments on commit 4bfcfc9

Please sign in to comment.