diff --git a/.travis.yml b/.travis.yml index c7d3bd3..5bf8f63 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,4 +5,4 @@ go: - 1.x script: - - go test . ./lib + - go test ./... diff --git a/CONFIG.md b/CONFIG.md index d4a99b5..c5a17c3 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -58,11 +58,12 @@ This includes Raspbian and Ubuntu. recent version. - See [official instructions](https://golang.org/doc/install#install) for help. +- Create a `gohci` standard account (optional). - Setup `$PATH` to include `~/go/bin` - Install git. -- Install `gohci`. +- Install `gohci-worker`. - Create the directory `gohci`. -- Set up the system to run `gohci` automatically and update it every +- Set up the system to run `gohci-worker` automatically and update it every day via [`systemd/setup.sh`](systemd/setup.sh) . Overall it looks like this: @@ -71,7 +72,7 @@ Overall it looks like this: sudo apt install git export PATH="$PATH:$HOME/go/bin" echo 'export PATH="$PATH:$HOME/go/bin"' >> ~/.bash_aliases -go get -u -v periph.io/x/gohci +go get -u -v periph.io/x/gohci/cmd/gohci-worker mkdir -p ~/gohci $HOME/go/src/periph.io/x/gohci/systemd/setup.sh ``` @@ -84,7 +85,8 @@ $HOME/go/src/periph.io/x/gohci/systemd/setup.sh - See [official instructions](https://golang.org/doc/install#install) for help. - Install [git](https://git-scm.com) -- First enable auto-login (optionally on a fresh low privilege account). +- Create a `gohci` standard account (optional). +- Enable auto-login. - Win-R - `netplwiz` - Uncheck _Users must enter a user name and password to use this computer_. @@ -97,23 +99,23 @@ $HOME/go/src/periph.io/x/gohci/systemd/setup.sh title gohci cd %USERPROFILE%\gohci :loop - gohci + gohci-worker goto loop ``` - Auto-update can be done via the task scheduler. The following command will - auto-update `gohci` every day: + auto-update `gohci-worker` every day: ``` - schtasks /create /tn "Update gohci" /tr "go get -v -u periph.io/x/gohci" /sc minute /mo 1439 + schtasks /create /tn "Update gohci-worker" /tr "go get -v -u periph.io/x/gohci/cmd/gohci-worker" /sc minute /mo 1439 ``` - The task should show up with: `schtasks /query /fo table | more` or navigating the GUI with `taskschd.msc`. - Open `cmd` and run: ``` - go get -u -v periph.io/x/gohci + go get -u -v periph.io/x/gohci/cmd/gohci-worker mkdir %USERPROFILE%/gohci cd %USERPROFILE%/gohci ``` -- Run `gohci` twice to make sure the firewall popup is shown and you allow the +- Run `gohci-worker` twice to make sure the firewall popup is shown and you allow the app. @@ -125,9 +127,9 @@ $HOME/go/src/periph.io/x/gohci/systemd/setup.sh help. - Install [Homebrew](https://brew.sh) (optional). - Create a `gohci` standard account (optional). -- Install `gohci` and setup for auto-start: +- Install `gohci-worker` and setup for auto-start: ``` - go get -u -v periph.io/x/gohci + go get -u -v periph.io/x/gohci/cmd/gohci-worker mkdir -p ~/Library/LaunchAgents cp $HOME/go/src/periph.io/x/gohci/macos/gohci.plist ~/Library/LaunchAgents mkdir -p ~/gohci @@ -141,7 +143,7 @@ $HOME/go/src/periph.io/x/gohci/systemd/setup.sh ``` mkdir -p ~/gohci cd ~/gohci - gohci + gohci-worker ``` - It will look like this, with comments added here: ``` @@ -158,16 +160,16 @@ $HOME/go/src/periph.io/x/gohci/systemd/setup.sh - Edit the values based on your needs. - `oauth2accesstoken` must be set to the `AccessToken` you created at the step [OAuth2 token](#oauth2-token). -- Run `gohci` again and it will start a web server. When `gohci` is running, - updating `gohci.yml` will make the process quit (after completing any enqueued - checks). -- Reboot the host and make sure `gohci` starts correctly. +- Run `gohci-worker` again and it will start a web server. When `gohci-worker` + is running, updating `gohci.yml` will make the process quit (after completing + any enqueued checks). +- Reboot the host and make sure `gohci-worker` starts correctly. ### Private repository -`gohci` will automatically switch from HTTPS to SSH checkout when the repository -is private. For it to work you must: +`gohci-worker` will automatically switch from HTTPS to SSH checkout when the +repository is private. For it to work you must: - On your device, create a key via `ssh-keygen -C "raspberrypi"` and do not specify a password. - Visit `github.com///settings/keys`. diff --git a/FAQ.md b/FAQ.md index 48da6f8..60132bb 100644 --- a/FAQ.md +++ b/FAQ.md @@ -25,15 +25,15 @@ which means the attacker can: ## Test on multiple kind of hardware simultaneously? -- Install `gohci` on each of your devices, e.g. a +- Install `gohci-worker` on each of your devices, e.g. a [C.H.I.P.](https://getchip.com/), a [Raspberry Pi](https://www.raspberrypi.org/), a [BeagleBone](https://beagleboard.org/), macOS, Windows, etc. - Register [one webhook](CONFIG.md#webhook) on your repository per device. For each hook, use URLs in the format `https://1.2.3.4/gohci/deviceX` or as your choosing. -- Each `gohci` worker is completely independent. They do not need to be all - located at the same physical location. +- Each `gohci-worker` worker is completely independent. They do not need to be + all located at the same physical location. - Setup your `Caddyfile` like this: ``` @@ -58,10 +58,10 @@ ci.example.com { ## Won't the auto-updater break my CI when you push broken code? -Maybe. I'll try to keep `gohci` always in a working condition but it can fail -from time to time. So feel free to fork the `gohci` repository and run from your -copy. Don't forget to update `gohci_update.timer` to pull from your repository -instead. +Maybe. I'll try to keep `gohci-worker` always in a working condition but it can +fail from time to time. So feel free to fork the `gohci` repository and run from +your copy. Don't forget to update `gohci_update.timer` to pull from your +repository instead. ## What's the maximum testing rate per hour? @@ -79,9 +79,10 @@ requests. Each test run does: So a configuration defining 7 tests would sum for `3 + 1 + (2 * (7+2))` = 22 requests. 5000/13 = *227 test runs/hour*. If you have 3 workers, this means an -upper bound of *75 test runs/hour*. In practice, `gohci` throttles its requests -by buffering all the updates that happen within a second so the effective number -of requests per build is lower, i.e. you can run more tests in practice. +upper bound of *75 test runs/hour*. In practice, `gohci-worker` throttles its +requests by buffering all the updates that happen within a second so the +effective number of requests per build is lower, i.e. you can run more tests in +practice. ## Can you add support for `gd`, `glide`, `vgo`, etc? diff --git a/README.md b/README.md index 3843fce..36341ed 100644 --- a/README.md +++ b/README.md @@ -61,8 +61,8 @@ It hardly can get any simpler: - Each check's stdout is attached to the gist as they complete. - The commit's status is updated "_live_" on Github. This is pretty cool to see in action on a GitHub PR. -- `gohci` exits whenever the executable or `gohci.yml` is updated; making it - easy to use an auto-updating mechanism. +- `gohci-worker` exits whenever the executable or `gohci.yml` is updated; making + it easy to use an auto-updating mechanism. Not convinced? Read the [FAQ.md](FAQ.md) for additional information. diff --git a/config.go b/cmd/gohci-worker/config.go similarity index 100% rename from config.go rename to cmd/gohci-worker/config.go diff --git a/job.go b/cmd/gohci-worker/job.go similarity index 100% rename from job.go rename to cmd/gohci-worker/job.go diff --git a/job_test.go b/cmd/gohci-worker/job_test.go similarity index 100% rename from job_test.go rename to cmd/gohci-worker/job_test.go diff --git a/lib/lib.go b/cmd/gohci-worker/lib.go similarity index 84% rename from lib/lib.go rename to cmd/gohci-worker/lib.go index 2ded07a..8f44b83 100644 --- a/lib/lib.go +++ b/cmd/gohci-worker/lib.go @@ -5,4 +5,4 @@ // Package lib exposes SetConsoleTitle. // // This is mainly useful on Windows. -package lib // import "periph.io/x/gohci/lib" +package main diff --git a/lib/lib_curse.go b/cmd/gohci-worker/lib_curse.go similarity index 97% rename from lib/lib_curse.go rename to cmd/gohci-worker/lib_curse.go index 4ea6725..6bb249a 100644 --- a/lib/lib_curse.go +++ b/cmd/gohci-worker/lib_curse.go @@ -4,7 +4,7 @@ // +build !windows -package lib +package main // SetConsoleTitle sets the console title. func SetConsoleTitle(title string) error { diff --git a/lib/lib_windows.go b/cmd/gohci-worker/lib_windows.go similarity index 97% rename from lib/lib_windows.go rename to cmd/gohci-worker/lib_windows.go index 9e75fe1..b41ad98 100644 --- a/lib/lib_windows.go +++ b/cmd/gohci-worker/lib_windows.go @@ -2,7 +2,7 @@ // Use of this source code is governed under the Apache License, Version 2.0 // that can be found in the LICENSE file. -package lib +package main import ( "syscall" diff --git a/main.go b/cmd/gohci-worker/main.go similarity index 97% rename from main.go rename to cmd/gohci-worker/main.go index 8f2da61..56afc8d 100644 --- a/main.go +++ b/cmd/gohci-worker/main.go @@ -11,7 +11,7 @@ // - github webhook webserver that triggers on pushes and PRs // - runs a Go build and a list of user supplied commands // - posts the stdout to a Github gist and updates the commit's status -package main // import "periph.io/x/gohci" +package main // import "periph.io/x/gohci/cmd/gohci-worker" import ( "errors" diff --git a/server.go b/cmd/gohci-worker/server.go similarity index 99% rename from server.go rename to cmd/gohci-worker/server.go index 6d37a9c..52fa664 100644 --- a/server.go +++ b/cmd/gohci-worker/server.go @@ -18,7 +18,6 @@ import ( "github.com/google/go-github/github" fsnotify "gopkg.in/fsnotify.v1" - "periph.io/x/gohci/lib" ) // runServer runs the web server. @@ -52,7 +51,7 @@ func runServer(c serverConfig, wkr worker, fileName string) error { log.Printf("Failed to initialize watcher: %v", err) } - lib.SetConsoleTitle(fmt.Sprintf("gohci - %s", a)) + SetConsoleTitle(fmt.Sprintf("gohci - %s", a)) if err == nil { select { case <-w.Events: diff --git a/worker.go b/cmd/gohci-worker/worker.go similarity index 100% rename from worker.go rename to cmd/gohci-worker/worker.go diff --git a/macos/gohci.plist b/macos/gohci.plist index 64a3dc8..f114c3d 100644 --- a/macos/gohci.plist +++ b/macos/gohci.plist @@ -6,7 +6,7 @@ gohci ProgramArguments - /Users/gohci/go/bin/gohci + /Users/gohci/go/bin/gohci-worker