describe how to run tests and about CI

This commit is contained in:
rhysd 2018-02-11 23:36:50 +09:00
parent 02a5d46e86
commit 281445119d

View file

@ -8,7 +8,8 @@ Self-Update Mechanism for Go Commands using GitHub
[go-github-selfupdate][] is a Go library to provide self-update mechanism to command line tools. [go-github-selfupdate][] is a Go library to provide self-update mechanism to command line tools.
Go does not provide the way to install/update the stable version of tools. By default, Go command line tools are updated Go does not provide the way to install/update the stable version of tools. By default, Go command line
tools are updated:
- using `go get -u` (updating to HEAD) - using `go get -u` (updating to HEAD)
- using system's package manager (depending on the platform) - using system's package manager (depending on the platform)
@ -18,8 +19,10 @@ By using this library, you will get 4th choice:
- from your command line tool directly (and automatically) - from your command line tool directly (and automatically)
go-github-selfupdate detects the information of the latest release via [GitHub Releases API][] and check the current version. [go-github-selfupdate][] detects the information of the latest release via [GitHub Releases API][] and
If newer version than itself is detected, it downloads released binary from GitHub and replaces itself. check the current version.
If newer version than itself is detected, it downloads released binary from GitHub and replaces
itself.
- Automatically detects the latest version of released binary on GitHub - Automatically detects the latest version of released binary on GitHub
- Retrieve the proper binary for the OS and arch where the binary is running - Retrieve the proper binary for the OS and arch where the binary is running
@ -63,7 +66,8 @@ $ selfupdate-example -selfupdate
It should replace itself and finally shows a message containing release notes. It should replace itself and finally shows a message containing release notes.
Please check the binary version is updated to `v1.2.4` with `-version`. The binary is up-to-date. So running `-selfupdate` again only shows 'Current binary is the latest version'. Please check the binary version is updated to `v1.2.4` with `-version`. The binary is up-to-date.
So running `-selfupdate` again only shows 'Current binary is the latest version'.
### Real World Examples ### Real World Examples
@ -282,9 +286,33 @@ In summary, structure of releases on GitHub looks like:
- ... (Other binaries for v1.1.3) - ... (Other binaries for v1.1.3)
- ... (older versions) - ... (older versions)
Tags which don't contain a version number are ignored (i.e. `nightly`). And releases marked as `pre-release` are also ignored. Tags which don't contain a version number are ignored (i.e. `nightly`). And releases marked
as `pre-release` are also ignored.
### Debugging ### Development
#### Running tests
All library sources are put in `/selfupdate` directory. So you can run tests as following
at the top of the repository:
```
$ go test -v ./selfupdate
```
Some tests are not run without setting a GitHub API token because they call GitHub API too many times.
To run them, please generate an API token and set it to an environment variable.
```
$ export GITHUB_TOKEN="{token generated by you}"
$ go test -v ./selfupdate
```
Above command run almost all tests and it's enough to check the behavior before creating a pull request.
Some tests are still not tested because they depend on my personal API access token, though; for repositories
on GitHub Enterprise or private repositories on GitHub.
#### Debugging
This library can output logs for debugging. By default, logger is disabled. This library can output logs for debugging. By default, logger is disabled.
You can enable the logger by following and can know the details of the self update. You can enable the logger by following and can know the details of the self update.
@ -293,6 +321,12 @@ You can enable the logger by following and can know the details of the self upda
selfupdate.EnableLog() selfupdate.EnableLog()
``` ```
#### CI
Tests run on CIs (Travis CI, Appveyor) are run with the token I generated. However, because of security
reason, it is not used for the tests for pull requests. In the tests, a GitHub API token is not set and
API rate limit is often exceeding. So please ignore the test failures on creating a pull request.
## Dependencies ## Dependencies
This library utilizes [go-github][] to retrieve the information of releases and [go-update][] to replace This library utilizes [go-github][] to retrieve the information of releases and [go-update][] to replace