diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63a15efe..156f3043 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,27 +3,76 @@ on: - push - pull_request +env: + GO_VERSION: "1.17" + jobs: + lint: + name: Lint + runs-on: "windows-2019" + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: ${{ env.GO_VERSION }} + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + args: --verbose --timeout 8m --max-issues-per-linter 0 --max-same-issues 0 + continue-on-error: true # remove when lint issues are fixed + + go-generate: + name: Validate Go Generate + runs-on: "windows-2019" + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: ${{ env.GO_VERSION }} + - name: Verify generated files + shell: powershell + run: | + Write-Output "::group::go generate" + go generate -x .\... + Write-Output "::endgroup::" + if ($LASTEXITCODE -ne 0) { + Write-Output "::error title=Go Generate::Error running go generate." + exit $LASTEXITCODE + } + git add -N . + Write-Output "::group::git diff" + git diff --stat --exit-code + Write-Output "::endgroup::" + if ($LASTEXITCODE -ne 0) { + Write-Output "::error ::Generated files are not up to date. Please run ``go generate .\...``." + exit $LASTEXITCODE + } + test: + needs: + - lint + - go-generate runs-on: ${{ matrix.os }} strategy: matrix: os: [windows-2019, windows-2022, ubuntu-latest] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 with: - go-version: '^1.17.0' + go-version: ${{ env.GO_VERSION }} - run: go test -gcflags=all=-d=checkptr -v ./... build: - runs-on: 'windows-2019' + needs: + - test + runs-on: "windows-2019" steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 with: - go-version: '^1.17.0' - + go-version: ${{ env.GO_VERSION }} - run: go build ./pkg/etw/sample/ - run: go build ./tools/etw-provider-gen/ - - run: go build ./wim/validate/ \ No newline at end of file + - run: go build ./tools/mkwinsyscall/ + - run: go build ./wim/validate/ diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..8a60f3fa --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,38 @@ +run: + timeout: 2m + +output: + print-issued-lines: false + +issues: + max-same-issues: 5 + +linters: + enable: + - containedctx # struct contain a context + - contextcheck # function uses a non-inherited context + - dupl # code clone + - errname # erorrs are named correctly + - errorlint # errors not wrapped for 1.13 + - goconst # strings that should be constants + - gofmt + - gosec # security + - misspell + - nestif # deeply nested ifs + - nilnil # returns nil error and invalid value + - prealloc + - predeclared # shadows Go predeclared identifier + - revive # go-lint replacement + - structcheck # unused struct fields + - stylecheck + - unconvert # unnecessary conversions + - unparam # unused function params + - wastedassign + - whitespace # leading and trailing whitespace + +linters-settings: + stylecheck: + checks: + - "all" + govet: + enable-all: true