diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63a15efe..c528562c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,27 +3,88 @@ 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 }} + cache: true + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + args: >- + --verbose + --timeout=8m + --max-issues-per-linter=0 + --max-same-issues=0 + --modules-download-mode=readonly + 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 }} + cache: true + - 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: + name: Run Tests + 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 }} + cache: true - run: go test -gcflags=all=-d=checkptr -v ./... build: - runs-on: 'windows-2019' + name: Build Repo + 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 }} + cache: true - 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..ecc214ad --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,109 @@ +run: + timeout: 2m + +issues: + max-same-issues: 5 + max-issues-per-linter: 100 + +linters: + enable: + # style + - containedctx # struct contains a context + - goconst # strings that should be constants + - misspell + - predeclared # shadows predeclared Go identifier + - stylecheck + - unconvert # unnecessary conversions + + # bugs and others... + - contextcheck # function uses a non-inherited context + - dupl # code clone + - errname # erorrs are named correctly + - errorlint # errors not wrapped for 1.13 + - exhaustive # check exhaustiveness of enum switch statements + - exportloopref # using loop variable pointer + - gofmt + - gosec # security + - nestif # deeply nested ifs + - nilerr # returns nil even with non-nil error + - prealloc # slices that can be pre-allocated + - revive # golint replacement + - structcheck # unused struct fields + - unparam # unused function params + +linters-settings: + govet: + enable-all: true + check-shadowing: true + settings: + shadow: + strict: false + stylecheck: + checks: + - all + initialisms: + # defaults (https://staticcheck.io/docs/configuration/options/#initialisms) + - ACL + - API + - ASCII + - CPU + - CSS + - DNS + - EOF + - GUID + - HTML + - HTTP + - HTTPS + - ID + - IP + - JSON + - QPS + - RAM + - RPC + - SLA + - SMTP + - SQL + - SSH + - TCP + - TLS + - TTL + - UDP + - UI + - GID + - UID + - UUID + - URI + - URL + - UTF8 + - VM + - XML + - XMPP + - XSRF + - XSS + - SIP + - RTP + - AMQP + - DB + - TS + + # specific + - CID + - CRI + - CTRD + - ETW + - GCS + - GMSA + - HCS + - IO + - LCOW + - LPAC + - LTSC + - MMIO + - OCI + - RX + - TX + - VHD + - VHDX + - VMID + - VPCI + - WCOW diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..2792dffc --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "go.lintTool": "golangci-lint", + "go.lintOnSave": "package", + "go.lintFlags": [ + "--fix", + "--verbose", + ], +} \ No newline at end of file