From 65ed153eb0d23995fb5e3c29d6e98a564d3b3f10 Mon Sep 17 00:00:00 2001 From: Psnail <42728902+sdttttt@users.noreply.github.com> Date: Sat, 19 Sep 2020 20:54:41 +0800 Subject: [PATCH 1/4] enh(ci): Improve efficiency. --- .github/workflows/go.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 73371ac36..d58350caf 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -27,6 +27,17 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v2 + - name: Cache dependencies + uses: actions/cache@v2 + with: + # Cache + path: ~/go/pkg/mod + # Cache key + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + # An ordered list of keys to use for restoring the cache if no cache hit occurred for key + restore-keys: | + ${{ runner.os }}-go- + - name: Get dependencies run: | go get -v -t -d ./... @@ -48,8 +59,13 @@ jobs: - name: Build run: go build ./... + - name: Test - run: go test ./... + run: go test ./... -coverprofile=coverage.txt -covermode=atomic + + - name: Coverage + run: bash <(curl -s https://codecov.io/bash) + - name: Tool run: | go install ./... From 297ade3616ecd4912e77aa71b9504fb4c52a8f86 Mon Sep 17 00:00:00 2001 From: Psnail <42728902+sdttttt@users.noreply.github.com> Date: Sat, 19 Sep 2020 21:21:01 +0800 Subject: [PATCH 2/4] ci: Add matrix build. --- .github/workflows/go.yml | 45 +++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index d58350caf..f9201791f 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -6,17 +6,25 @@ on: pull_request: branches: [ master ] + jobs: build: - name: Build - runs-on: ubuntu-latest - steps: + name: Build on ${{ matrix.os }} - Go${{ matrix.go_version }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + go_version: + - 1.13 + os: + - ubuntu-latest - - name: Set up Go 1.13 + steps: + + - name: Set up Go ${{ matrix.go_version }} uses: actions/setup-go@v1 with: - go-version: 1.13 + go-version: ${{ matrix.go_version }} id: go - name: Set up Env @@ -66,6 +74,33 @@ jobs: - name: Coverage run: bash <(curl -s https://codecov.io/bash) + scaffold: + + name: Scaffold Test on ${{ matrix.os }} - Go${{ matrix.go_version }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + go_version: + - 1.13 + os: + - ubuntu-latest + + steps: + + - name: Set up Go ${{ matrix.go_version }} + uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go_version }} + id: go + + - name: Set up Env + run: | + echo "::set-env name=GOPATH::$(go env GOPATH)" + echo "::add-path::$(go env GOPATH)/bin" + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + - name: Tool run: | go install ./... From 90447f8af69b7317d750d8e36892db45606326fb Mon Sep 17 00:00:00 2001 From: Psnail <42728902+sdttttt@users.noreply.github.com> Date: Sat, 19 Sep 2020 21:27:48 +0800 Subject: [PATCH 3/4] ci: fix. --- .github/workflows/go.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index f9201791f..a6d7bf7f5 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -101,6 +101,36 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v2 + - name: Cache dependencies + uses: actions/cache@v2 + with: + # Cache + path: ~/go/pkg/mod + # Cache key + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + # An ordered list of keys to use for restoring the cache if no cache hit occurred for key + restore-keys: | + ${{ runner.os }}-go- + + - name: Get dependencies + run: | + go get -v -t -d ./... + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure + fi + sudo rm /usr/local/bin/docker-compose + curl -L https://github.com/docker/compose/releases/download/1.25.5/docker-compose-`uname -s`-`uname -m` > docker-compose + chmod +x docker-compose + sudo mv docker-compose /usr/local/bin + wget https://github.com/google/protobuf/releases/download/v3.11.4/protoc-3.11.4-linux-x86_64.zip + unzip protoc-3.11.4-linux-x86_64.zip + chmod +x bin/protoc + sudo mv bin/protoc /usr/local/bin + sudo mv include /usr/local/bin + go get -u github.com/golang/protobuf/protoc-gen-go + go get -u github.com/gogo/protobuf/protoc-gen-gofast + - name: Tool run: | go install ./... From 20609de39c51e16b5bd20df9bcd4109242e425d6 Mon Sep 17 00:00:00 2001 From: Psnail <42728902+sdttttt@users.noreply.github.com> Date: Sat, 19 Sep 2020 22:57:55 +0800 Subject: [PATCH 4/4] ci:Delete superfluous parts. --- .github/workflows/go.yml | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index a6d7bf7f5..9a2ebaa6b 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -6,7 +6,6 @@ on: pull_request: branches: [ master ] - jobs: build: @@ -27,11 +26,6 @@ jobs: go-version: ${{ matrix.go_version }} id: go - - name: Set up Env - run: | - echo "::set-env name=GOPATH::$(go env GOPATH)" - echo "::add-path::$(go env GOPATH)/bin" - - name: Check out code into the Go module directory uses: actions/checkout@v2 @@ -53,17 +47,6 @@ jobs: curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh dep ensure fi - sudo rm /usr/local/bin/docker-compose - curl -L https://github.com/docker/compose/releases/download/1.25.5/docker-compose-`uname -s`-`uname -m` > docker-compose - chmod +x docker-compose - sudo mv docker-compose /usr/local/bin - wget https://github.com/google/protobuf/releases/download/v3.11.4/protoc-3.11.4-linux-x86_64.zip - unzip protoc-3.11.4-linux-x86_64.zip - chmod +x bin/protoc - sudo mv bin/protoc /usr/local/bin - sudo mv include /usr/local/bin - go get -u github.com/golang/protobuf/protoc-gen-go - go get -u github.com/gogo/protobuf/protoc-gen-gofast - name: Build run: go build ./... @@ -73,7 +56,7 @@ jobs: - name: Coverage run: bash <(curl -s https://codecov.io/bash) - + scaffold: name: Scaffold Test on ${{ matrix.os }} - Go${{ matrix.go_version }} @@ -93,11 +76,25 @@ jobs: go-version: ${{ matrix.go_version }} id: go + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Cache dependencies + uses: actions/cache@v2 + with: + # Cache + path: ~/go/pkg/mod + # Cache key + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + # An ordered list of keys to use for restoring the cache if no cache hit occurred for key + restore-keys: | + ${{ runner.os }}-go- + - name: Set up Env run: | echo "::set-env name=GOPATH::$(go env GOPATH)" echo "::add-path::$(go env GOPATH)/bin" - + - name: Check out code into the Go module directory uses: actions/checkout@v2 @@ -119,10 +116,6 @@ jobs: curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh dep ensure fi - sudo rm /usr/local/bin/docker-compose - curl -L https://github.com/docker/compose/releases/download/1.25.5/docker-compose-`uname -s`-`uname -m` > docker-compose - chmod +x docker-compose - sudo mv docker-compose /usr/local/bin wget https://github.com/google/protobuf/releases/download/v3.11.4/protoc-3.11.4-linux-x86_64.zip unzip protoc-3.11.4-linux-x86_64.zip chmod +x bin/protoc