Skip to content
Open
Changes from 12 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9fab87b
Updated workflow to show error on failing test
HarK-github Oct 17, 2025
19be303
Merge branch 'development' into development
Umang01-hash Oct 23, 2025
b881dc1
Merge branch 'gofr-dev:development' into development
HarK-github Oct 26, 2025
f9667c3
reworked failing tests
HarK-github Oct 27, 2025
7487123
Merge branch 'development' of https://github.com/HarK-github/gofr int…
HarK-github Oct 27, 2025
69a9fc2
Added retries
HarK-github Oct 27, 2025
8a2f6ba
Changes
HarK-github Oct 27, 2025
5f564cf
Added wait for services
HarK-github Oct 27, 2025
2db1241
Added ignore password error
HarK-github Oct 27, 2025
f0c5e5e
Added alternative to get services reade
HarK-github Oct 27, 2025
f66be96
Merge branch 'development' into development
Umang01-hash Oct 28, 2025
b268754
Merge branch 'development' into development
Umang01-hash Oct 28, 2025
a0136f8
Merge branch 'development' into development
HarK-github Oct 28, 2025
b52759d
Resolved issues
HarK-github Oct 29, 2025
b49c060
Reverted whitespaces and added healthchecks
HarK-github Oct 29, 2025
b9b7c10
Resolved remaining whitespace issues
HarK-github Oct 29, 2025
0772f3b
Pruning whitespaces
HarK-github Oct 29, 2025
8c4bb12
Resolved health checkup
HarK-github Oct 29, 2025
cf691bf
Changed to ping
HarK-github Oct 29, 2025
b5b886a
Added kafka checks
HarK-github Oct 29, 2025
b77170e
Changes
HarK-github Oct 29, 2025
043b7c8
Removed health check for kafka
HarK-github Oct 29, 2025
6199300
Changed continue on error
HarK-github Oct 29, 2025
85b50f6
repair
HarK-github Oct 29, 2025
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
75 changes: 50 additions & 25 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,36 +37,37 @@ jobs:

# Define service containers that tests depend on
services:
# Kafka service
# Kafka service — expose host port 1092 so tests using localhost:1092 connect to Kafka
kafka:
image: bitnamilegacy/kafka:3.4.1
ports:
- "9092:9092"
- "1092: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
# advertise the host port that tests use
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:1092
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 service — tests expect Redis at localhost:2001, so expose 2001
redis:
image: redis:7.0.5
ports:
- "2002:6379"
- "2001:6379"
options: "--entrypoint redis-server"

# MySQL service
# MySQL service — move MySQL to a different host port to avoid conflict with Redis
mysql:
image: mysql:8.2.0
ports:
- "2001:3306"
- "2002:3306"
env:
MYSQL_ROOT_PASSWORD: "password"
MYSQL_DATABASE: "test"
Expand All @@ -88,10 +89,51 @@ jobs:
- name: Get dependencies
run: |
go mod download

- name: Start Zipkin
run: docker run -d -p 2005:9411 openzipkin/zipkin:latest

# Wait for service ports to be ready before running tests (prevents race conditions)

- name: Wait for services to be ready
run: |
set +e # Don't exit on individual command failures

echo "Waiting for MySQL on 127.0.0.1:2002..."
for i in {1..60}; do
if timeout 2 bash -c 'echo > /dev/tcp/127.0.0.1/2002' 2>/dev/null; then
echo "✓ MySQL port is open"
sleep 2 # Give MySQL time to fully initialize
break
fi
echo " Attempt $i/60..."
sleep 1
done

echo "Waiting for Redis on 127.0.0.1:2001..."
for i in {1..60}; do
if timeout 2 bash -c 'echo > /dev/tcp/127.0.0.1/2001' 2>/dev/null; then
echo "✓ Redis port is open"
break
fi
echo " Attempt $i/60..."
sleep 1
done

echo "Waiting for Kafka on 127.0.0.1:1092..."
for i in {1..60}; do
if timeout 2 bash -c 'echo > /dev/tcp/127.0.0.1/1092' 2>/dev/null; then
echo "✓ Kafka port is open"
break
fi
echo " Attempt $i/60..."
sleep 1
done

echo "All services should be ready!"
sleep 3 # Final buffer
shell: bash


# Run tests with automatic retry on failures
- name: Test with Retry Logic
id: test
Expand All @@ -107,7 +149,6 @@ jobs:
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'}}
Expand Down Expand Up @@ -140,7 +181,6 @@ jobs:
- name: Get dependencies
run: |
go mod download

# Run pkg tests with automatic retry logic
- name: Test with Retry Logic
id: test
Expand All @@ -151,7 +191,6 @@ jobs:
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
Expand All @@ -163,7 +202,6 @@ jobs:
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/...
Expand All @@ -175,14 +213,11 @@ jobs:
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'}}
Expand Down Expand Up @@ -213,7 +248,6 @@ jobs:
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
Expand All @@ -222,7 +256,6 @@ jobs:
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 }}
Expand Down Expand Up @@ -257,7 +290,6 @@ jobs:
# 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
Expand Down Expand Up @@ -294,7 +326,6 @@ jobs:

cd -
'

# Upload submodule coverage reports as an artifact
- name: Upload Coverage Reports
uses: actions/upload-artifact@v5
Expand Down Expand Up @@ -322,7 +353,6 @@ jobs:
run: |
curl https://qlty.sh | sh
echo "$HOME/.qlty/bin" >> $GITHUB_PATH

# Download coverage artifacts
- name: Download Coverage Report
uses: actions/download-artifact@v6
Expand All @@ -335,7 +365,6 @@ jobs:
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
Expand Down Expand Up @@ -366,16 +395,13 @@ jobs:
- name: Install golangci-lint
run: |
go install github.com/golangci/golangci-lint/v2/cmd/[email protected]

- name: Get dependencies
run: |
go mod tidy

# Run linter on the root module
- name: Lint Root Module
run: |
golangci-lint run --output.text.print-issued-lines --output.text.colors=true --show-stats=false --timeout=5m

# Run linter on each submodule
- name: Lint Submodules
run: |
Expand All @@ -394,7 +420,6 @@ jobs:
echo "Linting failed for $total_errors submodule(s)."
exit 1 # Fail the job if there are linting errors in submodules
fi

# Job for checking filename conventions
linting_party:
name: Linting Party🥳
Expand Down
Loading