Skip to content

Commit

Permalink
Fix github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
veqryn committed Dec 21, 2023
1 parent f97afe3 commit 090b08b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 40 deletions.
53 changes: 27 additions & 26 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
push:
tags:
branches:
- main
pull_request:
branches:

Expand All @@ -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
Expand All @@ -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 }}
25 changes: 12 additions & 13 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 ./...
6 changes: 6 additions & 0 deletions examples/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
run:
tests: false

linters:
disable:
- errcheck
2 changes: 1 addition & 1 deletion handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 2 additions & 0 deletions otel/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run:
tests: false

0 comments on commit 090b08b

Please sign in to comment.