From 65912925802ea8b758a077bdc4df36e5d8816abf Mon Sep 17 00:00:00 2001 From: chupei Date: Wed, 13 May 2020 11:39:17 +0800 Subject: [PATCH] add github action ci check (#5) * add github action ci check * fix gofmt error Co-authored-by: chupei --- .github/workflows/style_check.yml | 40 +++++++++++++++++++++++++++++++ .github/workflows/ut_check.yml | 31 ++++++++++++++++++++++++ cmd/goc/app/root.go | 10 ++++---- cmd/goc/app/server.go | 10 ++++---- 4 files changed, 81 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/style_check.yml create mode 100644 .github/workflows/ut_check.yml diff --git a/.github/workflows/style_check.yml b/.github/workflows/style_check.yml new file mode 100644 index 0000000..dea3f50 --- /dev/null +++ b/.github/workflows/style_check.yml @@ -0,0 +1,40 @@ +name: style-check +on: + # Trigger the workflow on push or pull request, + # but only for the master branch + push: + branches: + - master + paths-ignore: + - '**.md' + pull_request: + paths-ignore: + - '**.md' +jobs: + run: + name: go style check + strategy: + matrix: + go-version: [1.13.x, 1.14.x] + platform: [ubuntu-latest] + runs-on: ${{ matrix.platform }} + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + # This step checks out a copy of your repository. + - name: Checkout code + uses: actions/checkout@v2 + - name: Go vet check + run: | + go vet ./... + - name: Gofmt check + run: | + diff=`find . -name "*.go" | xargs gofmt -s -d` + if [[ -n "${diff}" ]]; then + echo "Gofmt check failed :" + echo "${diff}" + echo "Please run this command to fix: [find . -name "*.go" | xargs gofmt -s -w]" + exit 1 + fi diff --git a/.github/workflows/ut_check.yml b/.github/workflows/ut_check.yml new file mode 100644 index 0000000..d8f0b01 --- /dev/null +++ b/.github/workflows/ut_check.yml @@ -0,0 +1,31 @@ +name: ut-check +on: + # Trigger the workflow on push or pull request, + # but only for the master branch + push: + branches: + - master + paths-ignore: + - '**.md' + pull_request: + paths-ignore: + - '**.md' +jobs: + run: + name: go test + strategy: + matrix: + go-version: [1.13.x, 1.14.x] + platform: [ubuntu-latest] + runs-on: ${{ matrix.platform }} + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + # This step checks out a copy of your repository. + - name: Checkout code + uses: actions/checkout@v2 + - name: Go test + run: | + go test ./... diff --git a/cmd/goc/app/root.go b/cmd/goc/app/root.go index 815bb39..5497fc1 100644 --- a/cmd/goc/app/root.go +++ b/cmd/goc/app/root.go @@ -1,18 +1,18 @@ -/* +/* Copyright 2020 Qiniu Cloud (七牛云) - + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - */ +*/ package app diff --git a/cmd/goc/app/server.go b/cmd/goc/app/server.go index 51fa325..8fd2d32 100644 --- a/cmd/goc/app/server.go +++ b/cmd/goc/app/server.go @@ -1,18 +1,18 @@ -/* +/* Copyright 2020 Qiniu Cloud (七牛云) - + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - */ +*/ package app