diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..bca9edb --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,54 @@ +name: Go +on: [push] +jobs: + build: + name: Build by go ${{ matrix.go }} + runs-on: ubuntu-18.04 + strategy: + matrix: + go: ["1.12", "1.13"] + steps: + - name: Set up Go 1.12 + uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go }} + id: go + + - name: Install lirc + run: | + sudo apt -qq update && sudo apt -qq install \ + autoconf libtool libxml2-dev xsltproc python3-dev python3-setuptools + cd /tmp + git clone git://git.code.sf.net/p/lirc/git -b lirc-0.10.1 --depth 1 lirc + cd lirc + ./autogen.sh + ./configure + make + sudo make install + sudo ldconfig + sudo mkdir -p /var/run/lirc + lircd -v + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Launch lircd + run: | + export LIRC_RUN_PATH=/home/runner/work/lirc-web-api/lirc-web-api/lirc/test + sudo cp $LIRC_RUN_PATH/lircd.conf \ + /usr/local/etc/lirc/lircd.conf.d/lighting.conf + sudo lircd --logfile=$LIRC_RUN_PATH/lirc.log \ + --allow-simulate \ + --driver simsend + + - name: Get dependencies + run: | + go get -v -t -d ./... + + - name: Build + run: | + go build -v . + + - name: Test + run: | + go test ./... diff --git a/.gitignore b/.gitignore index 68e9155..9d39110 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .* !.gitignore +!.github # golang vendor diff --git a/glide.lock b/glide.lock deleted file mode 100644 index 93431be..0000000 --- a/glide.lock +++ /dev/null @@ -1,45 +0,0 @@ -hash: 7ce2af9d10b2361fab5ac9024b9b1ec60ab9a85c4ca299b8092a7aa91c80ca7a -updated: 2017-02-21T22:52:11.080387224+09:00 -imports: -- name: github.com/dgrijalva/jwt-go - version: 9ed569b5d1ac936e6494082958d63a6aa4fff99a -- name: github.com/golang/mock - version: bd3c8e81be01eef76d4b503f5e687d2d1354d2d9 - subpackages: - - gomock -- name: github.com/labstack/echo - version: 8d504c1b699c757b267255c53b3e5219f9974abc - subpackages: - - middleware -- name: github.com/labstack/gommon - version: 447fe7433567c785af957e549aadae2bf2000071 - subpackages: - - bytes - - color - - log - - random -- name: github.com/mattn/go-colorable - version: d228849504861217f796da67fae4f6e347643f15 -- name: github.com/mattn/go-isatty - version: 30a891c33c7cde7b02a981314b4228ec99380cca -- name: github.com/syndtr/goleveldb - version: 23851d93a2292dcc56e71a18ec9e0624d84a0f65 -- name: github.com/tylerb/graceful - version: 4df1190835320af7076dfcf27b3d071fd3612caf -- name: github.com/valyala/fasttemplate - version: 3b874956e03f1636d171bda64b130f9135f42cff -- name: golang.org/x/crypto - version: 9b1a210a06ea1176ec1f0a1ddf83ad7463b8ea3e - subpackages: - - acme - - acme/autocert -- name: golang.org/x/net - version: 45e771701b814666a7eb299e6c7a57d0b1799e91 - subpackages: - - context - - context/ctxhttp -- name: golang.org/x/sys - version: d75a52659825e75fff6158388dddc6a5b04f9ba5 - subpackages: - - unix -testImports: [] diff --git a/glide.yaml b/glide.yaml deleted file mode 100644 index 3077a17..0000000 --- a/glide.yaml +++ /dev/null @@ -1,8 +0,0 @@ -package: github.com/ww24/lirc-web-api -import: -- package: github.com/labstack/echo - version: ^3.0.3 -- package: github.com/syndtr/goleveldb -- package: github.com/golang/mock - subpackages: - - gomock diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..8034476 --- /dev/null +++ b/go.mod @@ -0,0 +1,18 @@ +module github.com/ww24/lirc-web-api + +go 1.13 + +require ( + github.com/dgrijalva/jwt-go v3.0.1-0.20161101193935-9ed569b5d1ac+incompatible // indirect + github.com/golang/mock v0.0.0-20160127222235-bd3c8e81be01 + github.com/labstack/echo v3.0.3+incompatible + github.com/labstack/gommon v0.1.1-0.20161202074203-447fe7433567 + github.com/mattn/go-colorable v0.0.7 // indirect + github.com/mattn/go-isatty v0.0.0-20161123143637-30a891c33c7c // indirect + github.com/stretchr/testify v1.4.0 // indirect + github.com/tylerb/graceful v1.2.14-0.20161117165325-4df119083532 // indirect + github.com/valyala/fasttemplate v0.0.0-20160315193134-3b874956e03f // indirect + golang.org/x/crypto v0.0.0-20161216171927-9b1a210a06ea // indirect + golang.org/x/net v0.0.0-20161215194249-45e771701b81 // indirect + golang.org/x/sys v0.0.0-20161214190518-d75a52659825 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..41b764e --- /dev/null +++ b/go.sum @@ -0,0 +1,33 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v3.0.1-0.20161101193935-9ed569b5d1ac+incompatible h1:nBDeei+Kh2/zeFbpeGxwTTw/3cpazdo4cyURcV8PXs8= +github.com/dgrijalva/jwt-go v3.0.1-0.20161101193935-9ed569b5d1ac+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/golang/mock v0.0.0-20160127222235-bd3c8e81be01 h1:rtnkE5nwSSDcZrbt4gcVsFPeSXXe7Nq2vCn9DBb0Y8I= +github.com/golang/mock v0.0.0-20160127222235-bd3c8e81be01/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/labstack/echo v3.0.3+incompatible h1:L5+M/D4EeWi1QVqnJYu8UTHCyNdPR4WcNPcYzr1r3tM= +github.com/labstack/echo v3.0.3+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= +github.com/labstack/gommon v0.1.1-0.20161202074203-447fe7433567 h1:NprNtaZLLOhcYDjnouE33GSqvHHiOsrbJ7m/6DAfryc= +github.com/labstack/gommon v0.1.1-0.20161202074203-447fe7433567/go.mod h1:/tj9csK2iPSBvn+3NLM9e52usepMtrd5ilFYA+wQNJ4= +github.com/mattn/go-colorable v0.0.7 h1:zh4kz16dcPG+l666m12h0+dO2HGnQ1ngy7crMErE2UU= +github.com/mattn/go-colorable v0.0.7/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.0-20161123143637-30a891c33c7c h1:YHHK/dEmr2Jo1cWD1VMB2waEeHJhHFp3CEylwWy/VcY= +github.com/mattn/go-isatty v0.0.0-20161123143637-30a891c33c7c/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/tylerb/graceful v1.2.14-0.20161117165325-4df119083532 h1:jEsmCC6/AZjDfYV3hC/iK3X9FaOS2ZK0kr6OYtosyEg= +github.com/tylerb/graceful v1.2.14-0.20161117165325-4df119083532/go.mod h1:LPYTbOYmUTdabwRt0TGhLllQ0MUNbs0Y5q1WXJOI9II= +github.com/valyala/fasttemplate v0.0.0-20160315193134-3b874956e03f h1:qL0GulPcltegqmwdnhakM62NW+QeDQ+p1OpfnG8ExQ8= +github.com/valyala/fasttemplate v0.0.0-20160315193134-3b874956e03f/go.mod h1:50wTf68f99/Zt14pr046Tgt3Lp2vLyFZKzbFXTOabXw= +golang.org/x/crypto v0.0.0-20161216171927-9b1a210a06ea h1:gJbDpr1hNdfHVz3vkc+HJ978KPoVcx7cjffd1ll2TqU= +golang.org/x/crypto v0.0.0-20161216171927-9b1a210a06ea/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/net v0.0.0-20161215194249-45e771701b81 h1:fw6vKYqWlQqaVrIv7KcFK8YHLSj7xKY86A9h28yw1ws= +golang.org/x/net v0.0.0-20161215194249-45e771701b81/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/sys v0.0.0-20161214190518-d75a52659825 h1:4d9VvrP9mESHxCpAwE1G5e1D8Ybj9v7pX19HkGQV0lk= +golang.org/x/sys v0.0.0-20161214190518-d75a52659825/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/wercker.yml b/wercker.yml deleted file mode 100644 index 117c3b4..0000000 --- a/wercker.yml +++ /dev/null @@ -1,125 +0,0 @@ -box: golang - -build: - steps: - - script: - name: set API_VERSION - code: export API_VERSION="v0.2.10" - - - script: - name: install lirc - code: | - apt -qq update - apt -qq install autoconf libtool libxml2-dev xsltproc python3 - cd /tmp - git clone git://git.code.sf.net/p/lirc/git lirc - cd lirc - git checkout lirc-0_9_2a - ./autogen.sh - ./configure - make - make install - ldconfig - - - script: - name: print version - code: | - go version - lircd -v - echo "API_VERSION=$API_VERSION" - - - script: - name: launch lircd - code: | - export LIRC_RUN_PATH=$WERCKER_SOURCE_DIR/lirc/test - cp $LIRC_RUN_PATH/lircd.conf /usr/local/etc/lirc/lircd.conf.d/lighting.conf - mkdir -p /var/run/lirc - lircd --logfile=$LIRC_RUN_PATH/lirc.log \ - --allow-simulate \ - --driver simsend - - - setup-go-workspace: - package-dir: github.com/ww24/lirc-web-api - - - script: - name: glide install - code: | - curl https://glide.sh/get | sh - glide install - - - script: - name: go get - code: | - go get -u github.com/mitchellh/gox - - - script: - name: go test - code: | - go test -v $(glide nv) - - - script: - name: show lircd log - code: | - cat $LIRC_RUN_PATH/lirc.log - - - script: - name: cross compile - code: | - target="darwin/amd64 linux/386 linux/amd64 linux/arm" - mkdir -p build - - gox \ - -osarch="$target" \ - -tags="prod" \ - -ldflags="-X main.version=$API_VERSION" \ - -output="build/api_{{.OS}}_{{.Arch}}" - - - script: - name: create tarball - code: | - cd build - mv ../frontend . - - for t in $(echo $target); do - osarch=($(echo $t | tr '/' ' ')) - ext= - tarball="$WERCKER_OUTPUT_DIR/api_${osarch[0]}_${osarch[1]}.tar.gz" - if [ "${osarch[0]}" = "windows" ]; then - ext=".exe" - fi - tar czvf $tarball "api_${osarch[0]}_${osarch[1]}${ext}" frontend - done - - - script: - name: copy to output - code: | - cp "$WERCKER_SOURCE_DIR/build/api_linux_386" "$WERCKER_OUTPUT_DIR" - cp "$WERCKER_SOURCE_DIR/README.md" "$WERCKER_OUTPUT_DIR" - - - shellcheck: - files: install.sh uninstall.sh - -deploy: - steps: - - install-packages: - packages: lirc file - - - github-create-release: - token: $GITHUB_TOKEN - tag: $(./api_linux_386 -v) - - - github-upload-asset: - token: $GITHUB_TOKEN - file: api_darwin_amd64.tar.gz - - - github-upload-asset: - token: $GITHUB_TOKEN - file: api_linux_386.tar.gz - - - github-upload-asset: - token: $GITHUB_TOKEN - file: api_linux_amd64.tar.gz - - - github-upload-asset: - token: $GITHUB_TOKEN - file: api_linux_arm.tar.gz