Skip to content

build(deps): bump go.opentelemetry.io/otel/trace from 1.38.0 to 1.39.0 in /pkg/gofr/datasource/kv-store/badger #9991

build(deps): bump go.opentelemetry.io/otel/trace from 1.38.0 to 1.39.0 in /pkg/gofr/datasource/kv-store/badger

build(deps): bump go.opentelemetry.io/otel/trace from 1.38.0 to 1.39.0 in /pkg/gofr/datasource/kv-store/badger #9991

Workflow file for this run

---
name: Workflow-Pipeline
permissions:
contents: read
# Define when this workflow should run
on:
# Run on push events to main or development branches
push:
branches:
- main
- development
paths-ignore:
- 'docs/**' # Ignore changes to docs folder
- '**/*.md'
# Run on pull requests to main or development branches
pull_request:
branches:
- main
- development
paths-ignore:
- 'docs/**' # Ignore changes to docs folder
- '**/*.md'
# Define the jobs that this workflow will run
jobs:
# Job for testing the examples directory
Example-Unit-Testing:
name: Example Unit Testing (v${{ matrix.go-version }})🛠
runs-on: ubuntu-latest
# Define a matrix strategy to test against multiple Go versions
strategy:
matrix:
go-version: ['1.25','1.24', '1.23']
# Continue with other jobs if one version fails
fail-fast: false
# Define service containers that tests depend on
services:
# Kafka service
kafka:
image: bitnamilegacy/kafka:3.4.1
ports:
- "9092:9092"
env:
KAFKA_ENABLE_KRAFT: yes
KAFKA_CFG_PROCESS_ROLES: broker,controller
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9092
KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: true
KAFKA_BROKER_ID: 1
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: [email protected]:9093
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_CFG_NODE_ID: 1
# Redis service
redis:
image: redis:7.0.5
ports:
- "2002:6379"
options: "--entrypoint redis-server"
# MySQL service
mysql:
image: mysql:8.2.0
ports:
- "2001:3306"
env:
MYSQL_ROOT_PASSWORD: "password"
MYSQL_DATABASE: "test"
# Steps to execute for this job
steps:
- name: Checkout code into go module directory
uses: actions/checkout@v6
with:
fetch-depth: 0 # Full git history for accurate testing
# Set up the Go environment with the specified version
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
id: Go
- name: Get dependencies
run: |
go mod download
- name: Start Zipkin
run: docker run -d -p 2005:9411 openzipkin/zipkin:latest
# Run tests with automatic retry on failures
- name: Test with Retry Logic
id: test
uses: nick-fields/retry@v3
with:
timeout_minutes: 5 # Maximum time for the tests to run
max_attempts: 2 # Retry up to 2 times if tests fail
command: |
export APP_ENV=test
# Run tests for the examples directory with coverage
go test ./examples/... -v -short -covermode=atomic -coverprofile packageWithpbgo.cov -coverpkg=./examples/...
# Filter out auto-generated files by protobuf and gofr framework from coverage report
grep -vE '(/client/|grpc-.+-client/main\.go|_client\.go|_gofr\.go|_grpc\.pb\.go|\.pb\.go|\.proto|health_.*\.go)' packageWithpbgo.cov > profile.cov
# Display coverage statistics
go tool cover -func profile.cov
# Upload coverage report for the 1.24 Go version only
- name: Upload Test Coverage
if: ${{ matrix.go-version == '1.24'}}
uses: actions/upload-artifact@v5
with:
name: Example-Test-Report
path: profile.cov
# Job for testing the pkg directory
PKG-Unit-Testing:
name: PKG Unit Testing (v${{ matrix.go-version }})🛠
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.25','1.24', '1.23']
fail-fast: false
steps:
- name: Checkout code into go module directory
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
id: Go
- name: Get dependencies
run: |
go mod download
# Run pkg tests with automatic retry logic
- name: Test with Retry Logic
id: test
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 2
retry_on: error
command: |
export APP_ENV=test
# Run tests for root gofr package
go test -v -short -covermode=atomic \
-coverpkg=./pkg/gofr -coverprofile=gofr_only.cov ./pkg/gofr
exit_code=$?
if [ $exit_code -eq 2 ]; then
echo "::error::Panic detected in root gofr package tests"
exit 2
elif [ $exit_code -ne 0 ]; then
echo "::error::Root gofr package tests failed"
exit $exit_code
fi
# Run tests for sub-packages
go test -v -covermode=atomic \
-coverpkg=./pkg/gofr -coverprofile=submodules.cov ./pkg/gofr/...
exit_code=$?
if [ $exit_code -eq 2 ]; then
echo "::error::Panic detected in gofr sub-packages tests"
exit 2
elif [ $exit_code -ne 0 ]; then
echo "::error::Gofr sub-packages tests failed"
exit $exit_code
fi
# Combine coverage profiles
echo "mode: atomic" > profile.cov
grep -h -v "mode:" gofr_only.cov submodules.cov | grep -v '/mock_' >> profile.cov
# Show coverage summary
go tool cover -func profile.cov
# Upload coverage report for the 1.24 Go version only
- name: Upload Test Coverage
if: ${{ matrix.go-version == '1.24'}}
uses: actions/upload-artifact@v5
with:
name: PKG-Coverage-Report
path: profile.cov
# Job for analyzing and reporting code coverage
parse_coverage:
name: Code Coverage
runs-on: ubuntu-latest
# This job runs after both Example and PKG testing are complete
needs: [ Example-Unit-Testing,PKG-Unit-Testing ]
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v6
# Download coverage reports from previous jobs
- name: Download Coverage Report
uses: actions/download-artifact@v6
with:
path: artifacts
# Merge the coverage reports from Example and PKG tests
- name: Merge Coverage Files
working-directory: artifacts
run: |
echo "mode: atomic" > merged_profile.cov
grep -h -v "mode:" ./Example-Test-Report/profile.cov ./PKG-Coverage-Report/profile.cov >> merged_profile.cov
# Calculate and output the total code coverage percentage
- name: Parse code-coverage value
working-directory: artifacts
run: |
codeCoverage=$(go tool cover -func=merged_profile.cov | grep total | awk '{print $3}')
codeCoverage=${codeCoverage%?}
echo "CODE_COVERAGE=$codeCoverage" >> $GITHUB_ENV
echo "✅ Total Code Coverage: $codeCoverage%"
# - name: Check if code-coverage is greater than threshold
# run: |
# codeCoverage=${{ env.CODE_COVERAGE }}
# codeCoverage=${codeCoverage%??}
# if [[ $codeCoverage -lt 92 ]]; then echo "code coverage cannot be less than 92%, currently its ${{ env.CODE_COVERAGE }}%" && exit 1; fi;
# Job for testing submodules inside the pkg directory
Submodule-Unit-Testing:
name: Submodule Unit Testing (v${{ matrix.go-version }})🛠
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.25','1.24', '1.23']
fail-fast: false
steps:
- name: Checkout code into go module directory
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
id: Go
# Find all submodules (directories with go.mod files) in the pkg directory
- name: Detect Submodules
id: detect_submodules
run: |
# Find all directories containing a go.mod file within 'pkg'
SUBMODULES=$(find pkg -name "go.mod" -exec dirname {} \; | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "submodules=$SUBMODULES" >> $GITHUB_OUTPUT
# Test all submodules in parallel with retry logic
- name: Test Submodules with Retry and Parallelism
id: test_submodules
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 2
command: |
export APP_ENV=test
# Create a directory for coverage reports
mkdir -p coverage_reports
# Get the list of submodules
SUBMODULES='${{ steps.detect_submodules.outputs.submodules }}'
# Process each submodule in parallel with a maximum of 4 parallel jobs
echo $SUBMODULES | jq -c '.[]' | xargs -I{} -P 4 bash -c '
module={}
echo "Testing module: $module"
cd $module
# Extract module name (replace / with _)
module_name=$(echo $module | tr "/" "_")
# Download dependencies for the submodule
go mod download
go mod tidy
# Run tests with a focus on failed tests first
go test ./... -v -short -coverprofile=${module_name}.cov -coverpkg=./...
# Copy coverage file to the coverage_reports directory
cp ${module_name}.cov ../../../coverage_reports/
cd -
'
# Upload submodule coverage reports as an artifact
- name: Upload Coverage Reports
uses: actions/upload-artifact@v5
with:
name: submodule-coverage-reports
path: coverage_reports/*.cov
# Job for uploading coverage to external services (qlty.sh)
upload_coverage:
name: Upload Coverage📊
runs-on: ubuntu-latest
env:
QLTY_TOKEN: ${{ secrets.QLTY_TOKEN }}
QLTY_COVERAGE_TOKEN: ${{ secrets.QLTY_TOKEN }}
# This job only needs example and pkg test results, not submodules
needs: [Example-Unit-Testing, PKG-Unit-Testing]
# Only run this job on pushes to the development branch
if: ${{ github.repository == 'gofr-dev/gofr' && github.event_name == 'push' && github.ref == 'refs/heads/development'}}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v6
- name: Install qlty CLI
run: |
curl https://qlty.sh | sh
echo "$HOME/.qlty/bin" >> $GITHUB_PATH
# Download coverage artifacts
- name: Download Coverage Report
uses: actions/download-artifact@v6
with:
path: artifacts
# Merge coverage from example and pkg tests only
- name: Merge Coverage Files
working-directory: artifacts
run: |
echo "mode: atomic" > merged_profile.cov
grep -h -v "mode:" ./Example-Test-Report/profile.cov ./PKG-Coverage-Report/profile.cov >> merged_profile.cov
# Generate and print total coverage percentage
echo "Total Coverage:"
go tool cover -func=merged_profile.cov | tail -n 1
shell: bash
# Upload merged coverage to CodeClimate for analysis
- name: Upload
working-directory: artifacts
run: qlty coverage publish merged_profile.cov --format=coverprofile --strip-prefix="gofr.dev/" --add-prefix="${GITHUB_WORKSPACE}/"
env:
QLTY_TOKEN: ${{ secrets.QLTY_TOKEN }}
# Job for code quality checks
code_quality:
name: Code Quality🎖️
runs-on: ubuntu-latest
outputs:
modules: ${{ steps.changed-submodules.outputs.modules }}
has_modules: ${{ steps.changed-submodules.outputs.has_modules }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v6
with:
fetch-depth: 0 # Full history needed for proper diff analysis
- name: Set up Go environment
uses: actions/setup-go@v5
with:
go-version: '1.25'
cache: false
- name: Get dependencies
run: go mod download
# Use the official golangci-lint action for the root module
# This action automatically detects changed files and only reports new issues
- name: Lint Root Module
uses: golangci/golangci-lint-action@v9
with:
version: v2.4.0
only-new-issues: true
args: --timeout=5m
# Detect changed files to determine which submodules need linting
# This implements a changed-files based approach as suggested by the maintainer
- name: Get Changed Files
id: changed-files
uses: tj-actions/changed-files@v47
with:
files: |
pkg/**/*.go
pkg/**/go.mod
pkg/**/go.sum
# Find all submodules that have changes
- name: Find Changed Submodules
id: changed-submodules
run: |
# Check if any files changed
if [ "${{ steps.changed-files.outputs.any_changed }}" != "true" ]; then
echo "✅ No changes in pkg/ directory"
echo "modules=[]" >> $GITHUB_OUTPUT
echo "has_modules=false" >> $GITHUB_OUTPUT
exit 0
fi
changed_files="${{ steps.changed-files.outputs.all_changed_files }}"
changed_modules=""
echo "📝 Changed files detected:"
echo "$changed_files" | tr ' ' '\n'
echo ""
# Extract unique submodule directories from changed files
for file in $changed_files; do
# Find the nearest parent directory containing go.mod
dir=$(dirname "$file")
while [ "$dir" != "." ] && [ "$dir" != "/" ]; do
if [ -f "$dir/go.mod" ] && [[ "$dir" == pkg/* ]]; then
# Check if this module is not already in the list
if [[ ! "$changed_modules" =~ (^|[[:space:]])"$dir"($|[[:space:]]) ]]; then
changed_modules="$changed_modules$dir "
fi
break
fi
dir=$(dirname "$dir")
done
done
changed_modules=$(echo "$changed_modules" | xargs -n1 | sort -u)
if [ -n "$changed_modules" ]; then
echo "📦 Submodules with changes:"
echo "$changed_modules"
# Convert to JSON array for matrix usage
modules_json=$(echo "$changed_modules" | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "modules=$modules_json" >> $GITHUB_OUTPUT
echo "has_modules=true" >> $GITHUB_OUTPUT
else
echo "✅ No submodule changes detected"
echo "modules=[]" >> $GITHUB_OUTPUT
echo "has_modules=false" >> $GITHUB_OUTPUT
fi
# Separate job to lint changed submodules using matrix strategy
# This allows us to use the official golangci-lint action for each submodule
lint_changed_submodules:
name: Lint Submodules🔍
runs-on: ubuntu-latest
needs: code_quality
if: needs.code_quality.outputs.has_modules == 'true'
strategy:
matrix:
module: ${{ fromJson(needs.code_quality.outputs.modules) }}
fail-fast: false
steps:
- name: Check out code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go environment
uses: actions/setup-go@v5
with:
go-version: '1.25'
cache: false
- name: Download dependencies for ${{ matrix.module }}
working-directory: ${{ matrix.module }}
run: go mod download
# Use the official golangci-lint action for this submodule
- name: Lint ${{ matrix.module }}
uses: golangci/golangci-lint-action@v9
with:
version: v2.4.0
working-directory: ${{ matrix.module }}
only-new-issues: true
args: --timeout=9m
# Job for checking filename conventions
linting_party:
name: Linting Party🥳
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Set up Go environment
uses: actions/setup-go@v5
with:
go-version: 1.25
# Check file naming conventions using ls-lint
- name: Check for file names errors
uses: ls-lint/[email protected]
with:
config: .ls-lint.yml