Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 17 additions & 17 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- name: Gradle cache
uses: gradle/actions/setup-gradle@v3

- name: Configure Gradle memory settings
run: |
echo "org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g -XX:+HeapDumpOnOutOfMemoryError" >> gradle.properties
Expand All @@ -39,7 +39,7 @@ jobs:
run: |
# Build the project
./gradlew assembleDebug --stacktrace

# Run tests with coverage - allow test failures
./gradlew testDebugUnitTest jacocoTestReport --stacktrace
TEST_RESULT=$?
Expand All @@ -48,38 +48,38 @@ jobs:
# Even if tests fail, JaCoCo should generate a report with partial coverage
# from the tests that did pass
fi

- name: Prepare class files for SonarQube analysis
run: |
echo "Searching for compiled class files..."

# Create the target directory
mkdir -p build/intermediates/runtime_library_classes_dir/debug

# Find all directories containing class files with better patterns
CLASS_DIRS=$(find build -name "*.class" -type f -exec dirname {} \; | sort -u | grep -E "(javac|kotlin-classes|runtime_library)" | head -10)

if [ -z "$CLASS_DIRS" ]; then
echo "WARNING: No class files found in the build directory!"
echo "Searching in all build subdirectories..."
find build -name "*.class" -type f | head -20
else
echo "Found class files in the following directories:"
echo "$CLASS_DIRS"

# Copy classes from all relevant directories, not just the first one
for CLASS_DIR in $CLASS_DIRS; do
if [ -d "$CLASS_DIR" ] && [ "$(find "$CLASS_DIR" -name "*.class" | wc -l)" -gt 0 ]; then
echo "Copying classes from $CLASS_DIR"
cp -r "$CLASS_DIR"/* build/intermediates/runtime_library_classes_dir/debug/ 2>/dev/null || echo "Failed to copy from $CLASS_DIR"
fi
done

# Verify the target directory now has class files
CLASS_COUNT=$(find build/intermediates/runtime_library_classes_dir/debug -name "*.class" | wc -l)
echo "Target directory now contains $CLASS_COUNT class files"
fi

# Update sonar-project.properties with all found class directories
echo "" >> sonar-project.properties
echo "# Additional binary paths found during build" >> sonar-project.properties
Expand All @@ -90,14 +90,14 @@ jobs:
else
echo "sonar.java.binaries=build/intermediates/runtime_library_classes_dir/debug" >> sonar-project.properties
fi

echo "Checking for JaCoCo report files..."
find build -name "*.xml" | grep jacoco || echo "No JaCoCo XML files found"
find build -name "*.exec" | grep jacoco || echo "No JaCoCo exec files found"

echo "Contents of JaCoCo report directory:"
ls -la build/reports/jacoco/jacocoTestReport/ || echo "Directory not found"

echo ""
echo "Checking test execution results:"
TEST_RESULT_FILES=$(find build -name "TEST-*.xml" 2>/dev/null)
Expand All @@ -112,7 +112,7 @@ jobs:
else
echo "No test result files found"
fi

echo ""
echo "Checking JaCoCo report content:"
if [ -f build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml ]; then
Expand All @@ -130,22 +130,22 @@ jobs:
else
echo "JaCoCo report file not found"
fi

echo ""
echo "Checking binary directories specified in sonar-project.properties:"
echo "build/intermediates/runtime_library_classes_dir/debug:"
ls -la build/intermediates/runtime_library_classes_dir/debug || echo "Directory not found"

echo ""
echo "Checking all available class directories:"
find build -path "*/build/*" -name "*.class" | head -n 10 || echo "No class files found"

echo ""
echo "Final sonar-project.properties content:"
cat sonar-project.properties

- name: SonarCloud Scan
uses: SonarSource/sonarqube-scan-action@v5
uses: SonarSource/sonarqube-scan-action@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
Expand Down
93 changes: 93 additions & 0 deletions .harness/instrumented.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
pipeline:
name: android-client instrumented tests
identifier: androidclient_instrumented_tests
projectIdentifier: Harness_Split
orgIdentifier: PROD
tags: {}
properties:
ci:
codebase:
connectorRef: fmegithubrunnersci
repoName: android-client
build: <+input>
stages:
- stage:
name: Instrumented tests
identifier: Instrumented_tests
description: ""
type: CI
spec:
cloneCodebase: true
caching:
enabled: true
override: true
platform:
os: Linux
arch: Amd64
runtime:
type: Cloud
spec:
size: large
nestedVirtualization: true
variables:
- name: ANDROID_HOME
type: String
value: /opt/android-sdk
execution:
steps:
- step:
type: Run
name: Install Dependencies
identifier: install_dependencies
spec:
shell: Sh
command: |
chmod +x .harness/scripts/install-deps.sh
.harness/scripts/install-deps.sh
- step:
type: RunTests
name: Start Emulator and Run Tests
identifier: start_emulator_and_run_tests
spec:
language: Java
buildTool: Gradle
args: connectedCheck --continue --stacktrace --info
shell: Sh
preCommand: |
# Set Android SDK environment variables to point to the same location
export ANDROID_SDK_ROOT=$ANDROID_HOME

export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))
export PATH="$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator:$ANDROID_HOME/cmdline-tools/latest/bin"

# Start emulator
chmod +x .harness/scripts/start-emulator.sh
.harness/scripts/start-emulator.sh
testIntelligence:
enabled: true
reports:
type: JUnit
spec:
paths:
- "**/build/outputs/androidTest-results/connected/**/*.xml"
- "**/build/test-results/**/*.xml"
- step:
type: Test
name: Publish Test Results
identifier: publish_test_results
spec:
reports:
type: JUnit
spec:
paths:
- "**/build/outputs/androidTest-results/connected/**/*.xml"
- "**/build/test-results/**/*.xml"
when:
stageStatus: All
timeout: 1h
failureStrategies:
- onFailure:
errors:
- AllErrors
action:
type: MarkAsSuccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
inputSet:
name: " inputset"
identifier: inputset
orgIdentifier: PROD
projectIdentifier: Harness_Split
pipeline:
identifier: androidclient_instrumented_tests
properties:
ci:
codebase:
build:
type: PR
spec:
number: <+trigger.prNumber>
Loading
Loading