From 1372f610724f5127d50ebacc3c0caa7ae49dcce6 Mon Sep 17 00:00:00 2001 From: Planxnx Date: Sun, 14 Apr 2024 05:53:33 +0700 Subject: [PATCH] ci: add lint and test ci --- .github/workflows/code-analysis.yml | 59 +++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/code-analysis.yml diff --git a/.github/workflows/code-analysis.yml b/.github/workflows/code-analysis.yml new file mode 100644 index 0000000..53de22d --- /dev/null +++ b/.github/workflows/code-analysis.yml @@ -0,0 +1,59 @@ +name: Code Analysis & Tests +on: + workflow_dispatch: + pull_request: + branches: + - develop + - main + +env: + MIN_GO_VERSION: 1.19.x + +jobs: + lint: + strategy: + matrix: + os: ["ubuntu-latest", "macos-latest", "windows-latest"] + go-version: ["${{ env.MIN_GO_VERSION }}", "1.x"] + name: Lint (${{ matrix.os }}/${{ matrix.go-version }}) + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: "0" + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + cache: true # caching and restoring go modules and build outputs. + - run: echo "GOVERSION=$(go version)" >> $GITHUB_ENV + + - name: Lint + uses: reviewdog/action-golangci-lint@v2 + with: # https://github.com/reviewdog/action-golangci-lint#inputs + go_version_file: "go.mod" + workdir: ./ + golangci_lint_flags: "--config=./.golangci.yaml --verbose --new-from-rev=${{ github.event.pull_request.base.sha }}" + fail_on_error: true + test: + strategy: + matrix: + os: ["ubuntu-latest", "macos-latest", "windows-latest"] + go-version: ["${{ env.MIN_GO_VERSION }}", "1.x"] + name: Test (${{ matrix.os }}/${{ matrix.go-version }}) + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: "0" + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + cache: true # caching and restoring go modules and build outputs. + - run: echo "GOVERSION=$(go version)" >> $GITHUB_ENV + + - name: Test + run: go test ./...