From 0e17b1352b47de9771f379a641366ea0dabba4c3 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Thu, 13 Feb 2020 13:34:58 -0500 Subject: [PATCH] .github: init workflow --- .github/workflows/go.yaml | 132 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 .github/workflows/go.yaml diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml new file mode 100644 index 0000000..ac72c5b --- /dev/null +++ b/.github/workflows/go.yaml @@ -0,0 +1,132 @@ +name: CI +on: [push] +jobs: + build: + name: Build & Lint + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Set GOPATH + run: | + # temporary fix for https://github.com/actions/setup-go/issues/14 + echo "##[set-env name=GOPATH;]$(dirname $GITHUB_WORKSPACE)" + echo "##[add-path]$(dirname $GITHUB_WORKSPACE)/bin" + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Build + run: go build -v ./cmd/... + + - name: Vet + run: go vet ./... + + - name: Format + run: | + go install golang.org/x/tools/cmd/goimports + diff <(goimports -local github.com/chihaya/chihaya -d $(find . -type f -name '*.go' -not -path "./vendor/*")) <(printf "") + + - name: Lint + run: | + go install golang.org/x/lint/golint + (for d in $(go list ./...); do diff <(golint $d) <(printf "") || exit 1; done) + + unit: + name: Unit Tests + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Set GOPATH + run: | + # temporary fix for https://github.com/actions/setup-go/issues/14 + echo "##[set-env name=GOPATH;]$(dirname $GITHUB_WORKSPACE)" + echo "##[add-path]$(dirname $GITHUB_WORKSPACE)/bin" + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Unit Tests + run: go test -v -race $(go list ./...) + + e2e-mem: + name: E2E Tests (Memory Storage) + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Set GOPATH + run: | + # temporary fix for https://github.com/actions/setup-go/issues/14 + echo "##[set-env name=GOPATH;]$(dirname $GITHUB_WORKSPACE)" + echo "##[add-path]$(dirname $GITHUB_WORKSPACE)/bin" + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Test + run: | + go install github.com/chihaya/chihaya/cmd/chihaya + cat ./dist/example_config.yaml + chihaya --config=./dist/example_config.yaml --debug & + pid=$! + sleep 2 + chihaya e2e --debug + kill $pid + + e2e-redis: + name: E2E Tests (Redis Storage) + runs-on: ubuntu-latest + services: + redis: + image: redis + ports: ["6379:6379"] + options: --entrypoint redis-server + steps: + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Set GOPATH + run: | + # temporary fix for https://github.com/actions/setup-go/issues/14 + echo "##[set-env name=GOPATH;]$(dirname $GITHUB_WORKSPACE)" + echo "##[add-path]$(dirname $GITHUB_WORKSPACE)/bin" + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Configure redis storage + run: | + curl -LO https://github.com/jzelinskie/faq/releases/download/0.0.6/faq-linux-amd64 + chmod +x faq-linux-amd64 + ./faq-linux-amd64 '.chihaya.storage = {"config":{"gc_interval":"3m","peer_lifetime":"31m","prometheus_reporting_interval":"1s","redis_broker":"redis://127.0.0.1:6379/0","redis_connect_timeout":"15s","redis_read_timeout":"15s","redis_write_timeout":"15s"},"name":"redis"}' ./dist/example_config.yaml > ./dist/example_redis_config.yaml + cat ./dist/example_redis_config.yaml + + - name: Test + run: | + go install github.com/chihaya/chihaya/cmd/chihaya + chihaya --config=./dist/example_redis_config.yaml --debug & + pid=$! + sleep 2 + chihaya e2e --debug + kill $pid