[KLC-2116] Add monitoring metrics to bridge relayer API #43
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Code-coverage | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| name: Build | |
| steps: | |
| - name: Check out code into the Go module directory | |
| uses: actions/checkout@v4 | |
| - name: Go Setup | |
| uses: ./.github/actions/go-setup-action | |
| with: | |
| go-version: ${{vars.GO_VERSION }} | |
| go-private: ${{vars.GO_PRIVATE_REPO }} | |
| git-user: ${{ secrets.GIT_USER }} | |
| git-pass: ${{ secrets.GIT_PASS }} | |
| - name: Run unit tests | |
| id: run-tests | |
| run: | | |
| set +e | |
| make test-coverage | |
| echo "test_exit_code=$?" >> "$GITHUB_OUTPUT" | |
| # Always succeed so that the next step can evaluate the results | |
| exit 0 | |
| - name: Process test results | |
| if: always() | |
| id: coverage | |
| run: | | |
| # Generate coverage summary | |
| if [ -f coverage.out ]; then | |
| go tool cover -func=coverage.out > coverage-summary.txt | |
| COVERAGE=$(grep "total:" coverage-summary.txt | awk '{print $3}') | |
| echo "total=$COVERAGE" >> $GITHUB_OUTPUT | |
| else | |
| echo "No coverage data generated" > coverage-summary.txt | |
| echo "total=0.0%" >> $GITHUB_OUTPUT | |
| fi | |
| # Create test summary and check for failures | |
| echo "### Test Results 🧪" >> $GITHUB_STEP_SUMMARY | |
| if [ "${{ steps.run-tests.outputs.test_exit_code }}" == "0" ]; then | |
| echo "✅ All tests passed successfully" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "❌ Some tests failed" >> $GITHUB_STEP_SUMMARY | |
| echo "::error::🔴 Test failures detected!" | |
| if [ -f test-output.json ]; then | |
| echo "#### Failed Tests" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| jq -r 'select(.Action=="fail") | "- \(.Package) - \(.Test)"' test-output.json | tee -a $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| # Output failures as GitHub annotations | |
| jq -r 'select(.Action=="fail") | "::error file=\(.Package)::❌ \(.Test): \(.Action)"' test-output.json | |
| fi | |
| exit 1 | |
| fi | |
| echo "Coverage: $COVERAGE" >> $GITHUB_STEP_SUMMARY |