forked from kardianos/service
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55c314e
commit 4d55771
Showing
2 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Linter | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
go-staticcheck: | ||
name: go-staticcheck | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.23.x | ||
|
||
- name: Run go-staticcheck | ||
run: | | ||
go get honnef.co/go/tools/cmd/staticcheck@latest # ideally we should version pin | ||
PKGS=$(go list ./... | grep -v /vendor/ | grep -v pkg/ui | grep -v cmd/mte_service_ui ) | ||
go run honnef.co/go/tools/cmd/staticcheck $PKGS | ||
go-vet: | ||
name: go-vet | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.23.x | ||
|
||
- name: Run go-vet | ||
run: | | ||
PKGS=$(go list ./... | grep -v /vendor/ | grep -v pkg/ui | grep -v cmd/mte_service_ui ) | ||
go vet -json $PKGS | tee vet-report.json | ||
- name: Upload results | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: go-vet-results | ||
path: vet-report.json | ||
|
||
|
||
golangci-lint: | ||
name: golangci-lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.23.x | ||
|
||
- name: Install golangci-lint | ||
run: | | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0 | ||
- name: Run golangci-lint | ||
run: | | ||
go run github.com/golangci/golangci-lint/cmd/golangci-lint run -v --timeout 10m0s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# This workflow will install Go dependencies, run tests for 4 versions of Go | ||
# For more information see: https://support.github.com/features/actions | ||
|
||
name: Unit tests | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- ".github/workflows/*.yml" | ||
- "**/*.go" | ||
- "**/go.mod" | ||
- "**/go.sum" | ||
|
||
permissions: | ||
contents: read | ||
pull-requests: write | ||
|
||
jobs: | ||
go-test: | ||
name: Run go unit tests | ||
strategy: | ||
matrix: | ||
go-version: ["1.13", "1.16", "1.18", "1.19", "1.23"] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: "Install Go" | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- uses: actions/checkout@v3 | ||
|
||
- name: Install test dependencies | ||
run: | | ||
go get github.com/boumenot/gocover-cobertura | ||
- name: Install project dependencies | ||
run: go build | ||
|
||
- name: Run test | ||
run: | | ||
# run test: | ||
PKGS=$(go list ./... | grep -v /vendor/) | ||
DEPS=$(go list ./... | grep -v vendor | grep -v test | xargs | sed 's/ /,/g') | ||
go test ${PKGS} -v \ | ||
-coverprofile=coverage_${{ matrix.go-version }}.out \ | ||
-covermode=count \ | ||
-coverpkg ${DEPS} 2>&1 | ||
- name: Generate code coverage report | ||
run: | | ||
go run github.com/boumenot/gocover-cobertura < coverage_${{ matrix.go-version }}.out > coverage-unit_${{ matrix.go-version }}.xml | ||
- name: compute valid coverage total | ||
run: | | ||
go tool cover -func=coverage_${{ matrix.go-version }}.out | ||
- name: Code Coverage Report | ||
uses: irongut/[email protected] | ||
if: matrix.go-version == '1.19' | ||
with: | ||
# will generate code-coverage-results.md | ||
filename: coverage-unit_*.xml | ||
badge: true | ||
fail_below_min: true | ||
format: markdown | ||
hide_branch_rate: false | ||
hide_complexity: true | ||
indicators: true | ||
output: both | ||
thresholds: "60 80" | ||
|
||
- name: Add coverage comment to PR | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
if: matrix.go-version == '1.19' && github.event_name == 'pull_request' | ||
with: | ||
path: code-coverage-results.md | ||
|
||
- name: Upload coverage results | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: go-coverage-results | ||
path: coverage-unit_*.xml |