diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 90a4ba541..6322dbfa2 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -9,6 +9,7 @@ on: push: branches: - main + - test3 - development paths-ignore: - 'docs/**' # Ignore changes to docs folder @@ -41,14 +42,14 @@ jobs: 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 + 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: 1@127.0.0.1:9093 @@ -59,14 +60,14 @@ jobs: redis: image: redis:7.0.5 ports: - - "2002:6379" + - "2001:6379" options: "--entrypoint redis-server" # MySQL service mysql: image: mysql:8.2.0 ports: - - "2001:3306" + - "2009:3306" env: MYSQL_ROOT_PASSWORD: "password" MYSQL_DATABASE: "test" @@ -88,7 +89,6 @@ jobs: - name: Get dependencies run: | go mod download - - name: Start Zipkin run: docker run -d -p 2005:9411 openzipkin/zipkin:latest @@ -98,8 +98,11 @@ jobs: 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 + max_attempts: 2 # Retry up to 2 times if tests fail + continue_on_error: false + retry_on: error command: | + set -e export APP_ENV=test # Run tests for the examples directory with coverage go test ./examples/... -v -short -covermode=atomic -coverprofile packageWithpbgo.cov -coverpkg=./examples/... @@ -116,7 +119,7 @@ jobs: name: Example-Test-Report path: profile.cov - # Job for testing the pkg directory + # Job for testing the pkg directorypk PKG-Unit-Testing: name: PKG Unit Testing (v${{ matrix.go-version }})🛠 runs-on: ubuntu-latest @@ -140,7 +143,6 @@ jobs: - name: Get dependencies run: | go mod download - # Run pkg tests with automatic retry logic - name: Test with Retry Logic id: test @@ -148,10 +150,11 @@ jobs: with: timeout_minutes: 5 max_attempts: 2 + continue_on_error: false retry_on: error command: | + set -e 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 @@ -163,7 +166,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/... @@ -175,13 +177,10 @@ 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 @@ -213,7 +212,7 @@ 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 @@ -322,7 +321,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 @@ -335,6 +333,7 @@ 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:" @@ -412,4 +411,4 @@ jobs: - name: Check for file names errors uses: ls-lint/action@v2.3.1 with: - config: .ls-lint.yml \ No newline at end of file + config: .ls-lint.yml