diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index c7f7fe6..f9d70e3 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -7,6 +7,7 @@ on: push: tags: branches: + - main pull_request: branches: @@ -27,25 +28,25 @@ jobs: working-directory: ${{ matrix.go-module }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Set up Go ${{ matrix.go-version }} + - name: Set up Go ${{ matrix.go-version }} ${{ matrix.go-module }} uses: actions/setup-go@v4 with: go-version: ${{ matrix.go-version }} - - name: Display Go version + - name: Display Go version ${{ matrix.go-version }} ${{ matrix.go-module }} run: go version - - name: Install dependencies + - name: Install dependencies ${{ matrix.go-version }} ${{ matrix.go-module }} run: | go get -t -u golang.org/x/tools/cmd/cover go mod download - - name: Build + - name: Build ${{ matrix.go-version }} ${{ matrix.go-module }} run: go build -v ./... - - name: Test + - name: Test ${{ matrix.go-version }} ${{ matrix.go-module }} run: go test -v ./... # Build and Test as a workspace, create unified test coverage file @@ -56,29 +57,29 @@ jobs: go-version: [ '1.21' ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Set up Go ${{ matrix.go-version }} - uses: actions/setup-go@v4 - with: - go-version: ${{ matrix.go-version }} + - name: Set up Go ${{ matrix.go-version }} + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} - - name: Display Go version - run: go version + - name: Display Go version + run: go version - - name: Create workspace - run: | - go work init . - go work use ./examples - go work use ./otel + - name: Create workspace + run: | + go work init . + go work use ./examples + go work use ./otel - - name: Build - run: go build -v ./... ./otel/... ./examples/... + - name: Build + run: go build -v ./... ./otel/... ./examples/... - - name: Test - run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./... ./otel/... ./examples/... + - name: Test + run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./... ./otel/... ./examples/... - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 799aed4..d75d858 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -14,13 +14,21 @@ jobs: golangci: name: lint runs-on: ubuntu-latest + strategy: + matrix: + go-module: [ '.', './otel', './examples'] + + defaults: + run: + working-directory: ${{ matrix.go-module }} + steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: go-version: 'stable' cache: false - - name: golangci-lint root + - name: Github-action golangci-lint ${{ matrix.go-module }} uses: golangci/golangci-lint-action@v3 with: # Require: The version of golangci-lint to use. @@ -52,15 +60,6 @@ jobs: # Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'. # install-mode: "goinstall" - - name: golangci-lint otel - uses: golangci/golangci-lint-action@v3 - with: - version: latest - working-directory: ./otel - only-new-issues: true - - name: golangci-lint examples - uses: golangci/golangci-lint-action@v3 - with: - version: latest - working-directory: ./examples - only-new-issues: true + + - name: Manual golangci-lint ${{ matrix.go-module }} + run: golangci-lint run ./... diff --git a/examples/.golangci.yml b/examples/.golangci.yml new file mode 100644 index 0000000..c5cf1a9 --- /dev/null +++ b/examples/.golangci.yml @@ -0,0 +1,6 @@ +run: + tests: false + +linters: + disable: + - errcheck diff --git a/handler_test.go b/handler_test.go index a4607db..f15676c 100644 --- a/handler_test.go +++ b/handler_test.go @@ -72,7 +72,7 @@ func TestHandler(t *testing.T) { } if unmarshalled.Source.Function != "github.com/veqryn/slog-context.TestHandler" || - !strings.HasSuffix(unmarshalled.Source.File, "github.com/veqryn/slog-context/handler_test.go") || + !strings.HasSuffix(unmarshalled.Source.File, "slog-context/handler_test.go") || unmarshalled.Source.Line != 42 { t.Errorf("Expected source fields are incorrect: %#+v\n", unmarshalled) } diff --git a/otel/.golangci.yml b/otel/.golangci.yml new file mode 100644 index 0000000..29cd34d --- /dev/null +++ b/otel/.golangci.yml @@ -0,0 +1,2 @@ +run: + tests: false