Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🧰 Maintenance'
labels:
- 'chore'
- 'documentation'
autolabeler:
- label: 'chore'
files:
- '*.md'
branch:
- '/docs{0,1}\/.+/'
- label: 'bug'
branch:
- '/fix\/.+/'
title:
- '/fix/i'
- label: 'enhancement'
branch:
- '/feature\/.+/'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
template: |
## Changes

$CHANGES
90 changes: 90 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.18', '1.19', '1.20', '1.21', '1.22' , '1.23']

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Install dependencies
run: go mod download

go install mvdan.cc/[email protected]

# - name: Run golangci-lint
# uses: golangci/golangci-lint-action@v3
# with:
# version: latest
# args: --out-format=colored-line-number

- name: Run go build
run: |
go build ./...

# - name: Run gofumpt
# run: |
# if ! test -z "$(gofumpt -d -e . | tee /dev/stderr)"; then
# echo "❗️ gofumpt check failed"
# exit 1
# fi

- name: Run tests with coverage
run: |
go test -race -coverprofile=coverage.out $(go list ./... | grep -v /examples/)
go tool cover -func=coverage.out

- name: Check coverage threshold
run: |
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print substr($3, 1, length($3)-1)}')
THRESHOLD=70
if (( $(echo "$COVERAGE < $THRESHOLD" | bc -l) )); then
echo "Code coverage $COVERAGE% is below threshold of $THRESHOLD%"
exit 1
fi
echo "Code coverage $COVERAGE% is above threshold of $THRESHOLD%"

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
test_success:
# this aggregates success state of all jobs listed in `needs`
# this is the only required check to pass CI
name: "Test success"
if: always()
runs-on: ubuntu-latest
needs: [ test ]
steps:
- name: "Success"
if: needs.test.result == 'success'
run: true
shell: bash
- name: "Failure"
if: needs.test.result != 'success'
run: false
shell: bash

draft:
runs-on: ubuntu-latest
needs: test_success
if: github.ref == 'refs/heads/main'
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion examples/trace/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func BenchmarkMyFunctionWithQPS(b *testing.B) {

// run benchmark test
b.ResetTimer()
time.Sleep(1000 * time.Second) // wait
time.Sleep(1 * time.Second) // run duration
close(done)
}

Expand Down
15 changes: 7 additions & 8 deletions internal/trace/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func Test_GetSpanFromHeader(t *testing.T) {
opts := StartSpanOptions{
StartTime: time.Now(),
ParentSpanID: "1433434",
TraceID: "1111111111111",
TraceID: "12345678901234567890123456789012",
Baggage: map[string]string{"key": "value"},
}
PatchConvey("Test FromHeader failed", t, func() {
Expand All @@ -65,14 +65,13 @@ func Test_GetSpanFromHeader(t *testing.T) {

PatchConvey("Test FromHeader success", t, func() {
t := &Provider{}
expectedSpan := &Span{
SpanContext: SpanContext{
TraceID: "1234567890",
SpanID: "0987654321",
},
expectedSpan := &SpanContext{
TraceID: "1234567890",
SpanID: "0987654321",
}

Mock(FromHeader).Return(expectedSpan).Build()
actual := t.GetSpanFromHeader(nil, nil)
So(actual, ShouldEqual, expectedSpan)
x := t.GetSpanFromHeader(nil, nil)
So(x, ShouldEqual, expectedSpan)
})
}
2 changes: 1 addition & 1 deletion internal/util/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "testing"
func TestIsValidMDNBase64(t *testing.T) {
testStr := "data:image/png;base64,SGVsbG8sIFdvcmxkIQ=="
t.Run("TestIsValidMDNBase64", func(t *testing.T) {
if got := ParseValidMDNBase64(testStr); !got {
if _, got := ParseValidMDNBase64(testStr); !got {
t.Errorf("ParseValidMDNBase64() = %v", got)
}
})
Expand Down
Loading