From 69da2f85262504862536ec40697446bfbff35055 Mon Sep 17 00:00:00 2001 From: loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com> Date: Sun, 30 Aug 2020 23:55:00 +0800 Subject: [PATCH 1/4] Coverage: cache Go modules --- .github/workflows/coverage.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 252fce8a..b63d65b6 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -15,10 +15,20 @@ jobs: with: go-version: ^1.14 - - name: Checkout default branch + - name: Checkout codebase uses: actions/checkout@v2 + - name: Cache go module + uses: actions/cache@v2 + id: cache-gomodules + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Get dependencies + if: steps.cache-gomodules.outputs.cache-hit != 'true' run: | go get -v -t -d ./... From 42e33ddde6658a1dc21eb850fc8ca9195ae8c94c Mon Sep 17 00:00:00 2001 From: loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com> Date: Mon, 31 Aug 2020 01:09:45 +0800 Subject: [PATCH 2/4] Lint: include format --- .github/workflows/linter.yml | 46 ++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index ba62bcfc..8176c886 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -11,13 +11,49 @@ jobs: lint: runs-on: ubuntu-latest steps: - - name: Checkout default branch + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ^1.14 + + - name: Checkout codebase uses: actions/checkout@v2 - - name: Lint Code Base + - name: Cache go module + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: ${{ runner.os }}-go- + + - name: Show if need to format code + if: ${{ always() }} + run: | + filesNeedToFormat=$(go fmt ./...) + if [[ $filesNeedToFormat ]]; then + echo -e "\033[0;36m[Error] The following Go files need to be formatted:\033[0m" + echo -e "\033[0;31m$filesNeedToFormat\033[0m" + exit 1 + fi + + - name: Lint *.go files + if: ${{ always() }} + run: | + go vet $(go list ./... | grep -v /external/) + if [[ $? != 0 ]]; then + exit 1 + fi + + - name: Lint other files + if: ${{ always() }} uses: github/super-linter@v3.8.3 env: - VALIDATE_ALL_CODEBASE: false - VALIDATE_JSON: false - VALIDATE_ANSIBLE: false GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VALIDATE_ALL_CODEBASE: false + VALIDATE_BASH: false + VALIDATE_DOCKERFILE: false + VALIDATE_DOCKERFILE_HADOLINT: false + VALIDATE_GO: false + VALIDATE_JSON: false + VALIDATE_MD: false + VALIDATE_PROTOBUF: false From c974908e19f9c05bf2c338f8528a39f117b537b6 Mon Sep 17 00:00:00 2001 From: loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com> Date: Mon, 31 Aug 2020 01:10:28 +0800 Subject: [PATCH 3/4] Test: refine & cache Go modules --- .github/workflows/test.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1b21ef20..cc6f0617 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,6 +7,7 @@ on: - "**/*.go" pull_request: branches: [master] + types: [opened, synchronize, reopened] paths: - "**/*.go" @@ -22,12 +23,15 @@ jobs: with: go-version: ^1.14 - - name: Checkout default branch + - name: Checkout codebase uses: actions/checkout@v2 - - name: Get dependencies - run: | - go get -v -t -d ./... + - name: Cache go module + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: ${{ runner.os }}-go- - name: Test - run: go test -parallel 1 -timeout 6h -v ./... + run: go test -timeout 1h -v ./... From 8b377a08cd9e34015f24424bfbfd13973317cf4d Mon Sep 17 00:00:00 2001 From: loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com> Date: Mon, 31 Aug 2020 01:28:47 +0800 Subject: [PATCH 4/4] Update: refine --- .github/workflows/updateGeofile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/updateGeofile.yml b/.github/workflows/updateGeofile.yml index 0fb5c854..9ba3a6af 100644 --- a/.github/workflows/updateGeofile.yml +++ b/.github/workflows/updateGeofile.yml @@ -8,7 +8,7 @@ jobs: update: runs-on: ubuntu-latest steps: - - name: Checkout default branch + - name: Checkout codebase uses: actions/checkout@v2 - name: Download