diff --git a/Makefile b/Makefile index cc6cab8..f018301 100644 --- a/Makefile +++ b/Makefile @@ -235,20 +235,3 @@ check: ## Concurrently runs a whole bunch of static analysis tools .PHONY: run run: build ## runs the service locally $(SERVER_BIN) - -.PHONY: tools -tools: ## Installs all necessary tools - @echo "Installing gometalinter" - @go get -u github.com/alecthomas/gometalinter - - @echo "Installing ginkgo" - @go get -u github.com/onsi/ginkgo/ginkgo - - @echo "Installing gock" - @go get -u gopkg.in/h2non/gock.v1 - - @echo "Installing goimports" - @go get -u golang.org/x/tools/cmd/goimports - - @echo "Installing goa" - @go get -u github.com/goadesign/goa \ No newline at end of file diff --git a/README.adoc b/README.adoc index bd4f6d5..861a403 100644 --- a/README.adoc +++ b/README.adoc @@ -1,40 +1,61 @@ = Build Tool Detector -:test: gometaliner +Little service which will detect what build tool you are using. -Little service which will detect what build tool you are using +=== Build [[build]] -=== Start hacking [[hacking]] -Use `config-template.yml` as a template to create your own `config.yml` file with the appropriate environment variable values. The application will not run unless a github client id and github client secret are provided. - -Use `setup.sh` script we ship in this repository to get started right away! Simply run following `curl` command to get -latest and the greatest setup. +==== Pre-requisites +* link:https://golang.org/doc/install[Golang prerequisites] and `$GOPATH` setup. +NOTE: Stick to Golang version 10 because of link:https://github.com/goadesign/goa/pull/1548[goa and golang 11]. Have a look how link:https://github.com/moovweb/gvm[Go Version Manager] can help you simplifying configuration and management of different versions of Go. +* clone the repo in your GOPATH: [source,bash] ---- -$ curl -sSL https://git.io/fAPbw | bash +$ git clone https://github.com/fabric8-services/build-tool-detector $GOPATH/src/github.com/fabric8-services/build-tool-detector ---- +==== Setup +* Use `config-template.yml` as a template to create your own `config.yml` file with the appropriate environment variable values. +[source,bash] +---- +$ cp config-template.yml config.yml +---- +* You need to configure GH OAuth app to test it locally: -Assuming that you have all the link:https://golang.org/doc/install[Golang prerequisites] in place (such as `$GOPATH`), clone the repository first. - -NOTE: Have a look how link:https://github.com/moovweb/gvm[Go Version Manager] can help you simplifying configuration and management of different versions of Go. +1. Go to https://github.com/settings/applications/new[OAuth app] +1. Create a new developer application, in the `Authorization callback URL`, +1. Enter the url `http://localhost:8099`. -Then run the build by simply executing `make` from the root directory. This will perform following actions: +You'll get a page with `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` that you should use in your `config.xml`: +``` +github: + clientID: "GITHUB_CLIENT_ID" + clientSecret: "GITHUB_CLIENT_SECRET" +``` +==== Build -. Clean artifacts from the previous build -. Fetch or update dependencies using `godep` -. Compile and build binaries -. Run tests -. Run static code analysis +[source,bash] +---- +$ make build +---- +This will perform following actions: fetch dependencies, generate Goa files from design folder, compile. When in doubt just `make help`. -=== Continuous Testing [[testing]] +=== Test [[test]] In order to continuously run the tests whenever code change occur execute following command from the root directory of the project: [source,bash] ---- -$ ginkgo watch -r +$ make test ---- and keep it running in the terminal. + +=== Run [[run]] + +Run the server: + +[source,bash] +---- +$ make run +---- diff --git a/main.go b/main.go index 2c75b2a..5835573 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,3 @@ -//go:generate goagen bootstrap -d github.com/fabric8-services/build-tool-detector/design package main diff --git a/setup.sh b/setup.sh deleted file mode 100755 index d547eee..0000000 --- a/setup.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh - -LIGHT_GREEN='\033[1;32m' -GREEN='\033[0;32m' -CLEAR='\033[0m' -if [ -n "$(which sudo 2>/dev/null)" ]; then - SUDO=sudo -fi - -function install_packages() { - echo -e "${CLEAR}${LIGHT_GREEN}Install prerequisites${CLEAR}" - - # Fedora - if [ -n "$(command -v dnf)" ]; then - ${SUDO} dnf -y install gcc git wget make which - fi - - # Ubuntu - if [ -n "$(command -v apt-get)" ]; then - ${SUDO} apt-get -y install gcc git wget make which - fi -} - -function install_go_bins() { - GO_VERSION=go1.10.2 - GO_LOCATION=/usr/local - - if [ -z $(which go 2>/dev/null) ]; then - echo -e "${CLEAR}${LIGHT_GREEN}Installing target Go version ${GO_VERSION}${CLEAR} to ${GO_LOCATION}" - ${SUDO} wget -P /tmp --no-verbose https://dl.google.com/go/${GO_VERSION}.linux-amd64.tar.gz \ - && echo "4b677d698c65370afa33757b6954ade60347aaca310ea92a63ed717d7cb0c2ff /tmp/${GO_VERSION}.linux-amd64.tar.gz" > /tmp/go-bin-checksum \ - && sha256sum -c /tmp/go-bin-checksum \ - && tar -C ${GO_LOCATION} -xzf /tmp/${GO_VERSION}.linux-amd64.tar.gz \ - && rm -f /tmp/${GO_VERSION}.linux-amd64.tar.gz - - if [ -z ${GOPATH} ]; then - export GOPATH=${HOME}/go-workspace - fi - mkdir -p ${GOPATH} - - GO_BIN_LOCATION=${GO_LOCATION}/go/bin - export PATH=$PATH:${GO_BIN_LOCATION}:${GOPATH}/bin - - echo -e "${CLEAR}${GREEN}Go has been installed to ${GO_LOCATION} and ${CLEAR}\$GOPATH${GREEN} variable set to ${GOPATH}." \ - "Don't forget to add the Go binary directory along with ${GOPATH}/bin to your ${CLEAR}\$PATH${GREEN}: \n${CLEAR}" \ - "${LIGHT_GREEN}export PATH=\$PATH:${GO_BIN_LOCATION}:${GOPATH}/bin" && - echo -e "${CLEAR}${GREEN}You can also extend your ${CLEAR}\$GOPATH${GREEN} to contain your workspace, e.g.: \n${CLEAR}" \ - "${LIGHT_GREEN}export GOPATH=\$GOPATH:~/code/golang${CLEAR}" - fi - - if [ -z $(which dep 2>/dev/null) ]; then - echo -e "${CLEAR}${LIGHT_GREEN}Installing dep${CLEAR}" - curl https://raw.githubusercontent.com/golang/dep/1550da37d8fab9ed2dbc4bd04290e6c8dd3ff04a/install.sh | sh - fi -} - -if [[ $1 != "--only-go-bins" ]]; then - install_packages -fi -install_go_bins - -if [[ $1 != "--only-go-bins" ]]; then - echo -e "${CLEAR}${LIGHT_GREEN}Installing required go packages${CLEAR}" - make tools - echo -e "${CLEAR}${LIGHT_GREEN}Installing project dependencies${CLEAR}" - make install -fi