Skip to content

Conversation

@Gorlesunilkumar
Copy link

This PR improves the stability, safety, and reliability of the integration
test Bash script used in the Android CI pipeline.

✔ Summary of Improvements

The update focuses on modernizing the script, preventing silent failures, and
ensuring logcat output is reliably collected and uploaded when tests fail.

🔧 Key Changes

  • Enabled strict Bash mode (set -euo pipefail) for safer execution
  • Quoted all variable expansions to avoid word-splitting and globbing issues
  • Replaced hardcoded Codecov token with secure environment variable usage
  • Ensured clean termination of background logcat using:
    • wait "$LOGCAT_PID" to flush output
    • kill "$LOGCAT_PID" 2>/dev/null || true to avoid CI crashes
  • Improved logcat upload logic and error handling
  • Ensured correct exit code propagation to Drone CI
  • General cleanup to follow Bash best practices

💡 Why This Matters

The previous script:

  • could hide failed commands,
  • could produce truncated or inconsistent logs,
  • leaked a sensitive token,
  • and could fail unpredictably in CI.

This update makes integration tests more secure, deterministic, and easier to
debug—benefiting both maintainers and contributors.

🧪 Testing Notes

Only CI-related behavior was modified.
No application logic is affected.


This PR does not change app functionality for users but significantly improves
CI maintainability and reliability.

This PR improves the stability, safety, and maintainability of the integration
test Bash script used in the Android CI pipeline.

### ✔ Summary of Improvements
This update focuses on hardening the script and preventing silent failures,
unexpected behavior, and log corruption during integration test execution.

### 🔧 Key Changes
- Enabled strict Bash mode (`set -euo pipefail`) to ensure the script stops on
  errors, avoids undefined variables, and surfaces pipeline failures.
- Quoted all variable expansions to prevent word-splitting, globbing, and
  incorrect argument parsing during CI execution.
- Replaced the hardcoded Codecov token with a secure environment variable
  (`$CODECOV_TOKEN`) to avoid credential leakage in the repository.
- Added proper cleanup logic for the background `adb logcat` process, using:
  - `wait "$LOGCAT_PID"` to flush any buffered output
  - `kill "$LOGCAT_PID" 2>/dev/null || true` to avoid CI crashes if the process exits early
- Improved the reliability of logcat upload logic and ensured that log files
  are preserved whenever an integration test step fails.
- Ensured correct exit code propagation so that Drone CI reflects accurate
  build/test results.
- General scripting cleanup and modernization to better align with Bash best
  practices and CI reproducibility.

### 💡 Why These Changes Matter
The previous version of the script:
- could continue execution after failed commands,
- could kill unrelated processes or truncate log output,
- exposed a sensitive token in plain text,
- did not properly handle asynchronous processes,
- could cause inconsistent CI behavior depending on the environment.

With these improvements, the integration test pipeline becomes:
- more secure,
- more deterministic,
- easier to debug,
- and safer for automated execution.

### 🧪 Testing Notes
Only CI-related behavior was modified.  
No app logic was touched.  
This PR has been tested across multiple invocations to confirm stable behavior
and proper log handling.

---

This PR does not affect end users but significantly improves CI reliability for
maintainers and contributors.


Signed-off-by: Gorlesunilkumar <g2005.sunil2005@gmail.com>
@Gorlesunilkumar
Copy link
Author

merge it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants