Skip to content

refactor: [SDK-5065] remove the otel observability path and OpenTelemetry dependency #2173

refactor: [SDK-5065] remove the otel observability path and OpenTelemetry dependency

refactor: [SDK-5065] remove the otel observability path and OpenTelemetry dependency #2173

Workflow file for this run

name: Build and Test SDK
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
branches: ["**"]
push:
branches:
- main
- "*-main"
workflow_dispatch:
env:
DIFF_COVERAGE_THRESHOLD: "80"
permissions:
contents: read
pull-requests: write
issues: write
jobs:
code-quality:
runs-on: ubuntu-latest
steps:
- name: "[Checkout] Repo"
uses: actions/checkout@v7
with:
submodules: recursive
- name: "[Setup] Project"
uses: ./.github/actions/project-setup
- name: "[Code Formatting] Spotless"
working-directory: OneSignalSDK
run: |
./gradlew spotlessCheck --console=plain
- name: "[Static Code Analysis] Detekt"
working-directory: OneSignalSDK
run: |
./gradlew detekt --console=plain
test:
runs-on: ubuntu-latest
steps:
- name: "[Checkout] Repo"
uses: actions/checkout@v7
with:
fetch-depth: 0
submodules: recursive
- name: "[Setup] Project"
uses: ./.github/actions/project-setup
with:
# Keep untrusted fork PRs read-only; this is the sole cache writer for other runs.
cache-read-only: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}
- name: "[Test] SDK Unit Tests"
id: unit_tests
working-directory: OneSignalSDK
run: |
./gradlew testDebugUnitTest --console=plain --continue
- name: "[Diff Coverage] Check for bypass"
id: coverage_bypass
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
env:
# Evaluate in Actions expressions (not shell) so label names with spaces cannot break quoting.
HAS_SKIP_COVERAGE_LABEL: ${{ github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'Skip Coverage Check') || contains(github.event.pull_request.labels.*.name, 'skip-coverage-check')) }}
run: |
if [ "$HAS_SKIP_COVERAGE_LABEL" = "true" ]; then
echo "bypass=true" >> "$GITHUB_OUTPUT"
echo "reason=PR has Skip Coverage Check label" >> "$GITHUB_OUTPUT"
echo "Coverage check will not fail build (PR has Skip Coverage Check label)"
echo "Coverage will still be checked and reported"
else
echo "bypass=false" >> "$GITHUB_OUTPUT"
fi
- name: "[PR] Coverage on changed lines (min ${{ env.DIFF_COVERAGE_THRESHOLD }}%)"
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
working-directory: OneSignalSDK
env:
# Exact PR diff (vs merge ref / wrong base branch)
DIFF_BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || '' }}
DIFF_HEAD_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || '' }}
run: |
# Use the shared coverage check script for consistency
# Generate markdown report for PR comments
# If bypassed, still run the check but don't fail the build
set +e # Don't exit on error - we want to generate the report even if coverage fails
if [ "${{ steps.coverage_bypass.outputs.bypass }}" = "true" ]; then
SKIP_COVERAGE_CHECK=true GENERATE_MARKDOWN=true DIFF_COVERAGE_THRESHOLD=$DIFF_COVERAGE_THRESHOLD ./coverage/checkCoverage.sh
else
GENERATE_MARKDOWN=true DIFF_COVERAGE_THRESHOLD=$DIFF_COVERAGE_THRESHOLD ./coverage/checkCoverage.sh
fi
COVERAGE_EXIT_CODE=$?
set -e # Re-enable exit on error
# Check if markdown report was generated
if [ -f "diff_coverage.md" ]; then
echo "✅ Coverage report generated"
else
echo "⚠️ Coverage report not generated"
fi
# Only fail the build if coverage is below threshold AND not bypassed
if [ "${{ steps.coverage_bypass.outputs.bypass }}" != "true" ] && [ $COVERAGE_EXIT_CODE -ne 0 ]; then
echo "❌ Coverage check failed - build will fail"
exit $COVERAGE_EXIT_CODE
elif [ "${{ steps.coverage_bypass.outputs.bypass }}" = "true" ]; then
echo "⚠️ Coverage check completed (bypassed - build will not fail)"
exit 0
else
echo "✅ Coverage check passed"
exit 0
fi
- name: Comment PR with coverage summary
if: always() && github.event_name == 'pull_request'
uses: actions/github-script@v9
with:
script: |
const fs = require('fs');
const path = 'OneSignalSDK/diff_coverage.md';
if (fs.existsSync(path)) {
const content = fs.readFileSync(path, 'utf8');
const body = `## 📊 Diff Coverage Report\n\n${content}\n\n📥 [View workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})`;
// Find existing comment
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.data.find(comment =>
comment.user.type === 'Bot' && comment.body.includes('Diff Coverage Report')
);
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body
});
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
}
}
- name: Unit tests results
if: failure() && steps.unit_tests.outcome == 'failure'
uses: actions/upload-artifact@v7
with:
name: unit-tests-results
path: |
OneSignalSDK/**/build/reports/tests/
OneSignalSDK/**/build/test-results/
if-no-files-found: warn
demo-build:
runs-on: ubuntu-latest
steps:
- name: "[Checkout] Repo"
uses: actions/checkout@v7
with:
submodules: recursive
- name: "[Setup] Project"
uses: ./.github/actions/project-setup
- name: "[Build] Demo app (minified GMS + Huawei release)"
working-directory: OneSignalSDK
run: |
./gradlew :app:assembleGmsRelease :app:assembleHuaweiRelease --console=plain
# Keep the existing required check stable while the workloads run independently.
build:
if: always()
needs:
- code-quality
- test
- demo-build
runs-on: ubuntu-latest
steps:
- name: Verify parallel jobs
env:
CODE_QUALITY_RESULT: ${{ needs.code-quality.result }}
TEST_RESULT: ${{ needs.test.result }}
DEMO_BUILD_RESULT: ${{ needs.demo-build.result }}
run: |
if [ "$CODE_QUALITY_RESULT" != "success" ] ||
[ "$TEST_RESULT" != "success" ] ||
[ "$DEMO_BUILD_RESULT" != "success" ]; then
echo "One or more required jobs failed or were cancelled."
exit 1
fi