Skip to content

Conversation

@SaintPatrck
Copy link
Contributor

🎟️ Tracking

PM-28504

📔 Objective

Add GitHub Actions workflow for building the testharness module via manual workflow dispatch.

This PR introduces .github/workflows/build-testharness.yml to enable on-demand testharness APK builds through GitHub Actions, following the established patterns from the app and authenticator build workflows.

Key changes:

  • New workflow: build-testharness.yml with workflow_dispatch trigger for manual builds
  • Dynamic versioning: Integrates with _version.yml reusable workflow (codename: "bwth", base version: 0)
  • Fastlane integration: Uses setBuildVersionInfo for version management consistency
  • Build output: Generates com.bitwarden.testharness.dev-debug.apk with SHA256 checksum
  • Version configuration: Updated testharness/build.gradle.kts to read version from libs.versions.toml instead of hardcoded values

The workflow enables teams to build and distribute testharness artifacts for credential provider testing and validation without requiring local development environment setup.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

Logo
Checkmarx One – Scan Summary & Details623b8d27-2f6b-48dc-9e9b-9cb7660f671c

Great job! No new security vulnerabilities introduced in this pull request

@codecov
Copy link

codecov bot commented Nov 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.89%. Comparing base (f02b374) to head (f96ece5).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6181      +/-   ##
==========================================
- Coverage   85.41%   84.89%   -0.52%     
==========================================
  Files         755      981     +226     
  Lines       54105    57476    +3371     
  Branches     7798     7908     +110     
==========================================
+ Hits        46212    48793    +2581     
- Misses       5180     5930     +750     
- Partials     2713     2753      +40     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Base automatically changed from testharness-app to main November 21, 2025 20:01
@SaintPatrck SaintPatrck force-pushed the workflow/build-testharness branch from b1abf12 to 5ee4af1 Compare November 21, 2025 20:08
@SaintPatrck SaintPatrck marked this pull request as ready for review November 21, 2025 20:09
@SaintPatrck SaintPatrck requested a review from a team as a code owner November 21, 2025 20:09
@claude
Copy link
Contributor

claude bot commented Nov 21, 2025

Claude finished @SaintPatrck's task —— View job


PR Review Complete

Tasks

  • Review current state of changed files
  • Check if label-pr.json includes testharness/
  • Review outstanding feedback from vvolkgang
  • Perform comprehensive code review

Quick Answer to SaintPatrck's Question

Q: "We also need to add testharness/ to label-pr.json, right?"

A: ✅ Yes, and it's already been added! The file .github/label-pr.json:27 now includes testharness/ under the app:password-manager path patterns, which is the correct categorization.


Previous Feedback Status

All previously requested changes have been addressed:

  • app_codename changed from "bwth" to "bwpm" (build-testharness.yml:34)
  • ✅ Push trigger with path filtering added (build-testharness.yml:4-6)
  • ✅ Regex pattern updated to match Fastlane's .+ pattern (build-testharness.yml:107)
  • testharness/ added to label-pr.json (line 27)

Comprehensive Review Findings

⚠️ Warnings

1. Outdated Action Version (.github/workflows/build-testharness.yml:118, 130)

uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0

2. Regex Pattern Inconsistency (.github/workflows/build-testharness.yml:107)

  • Testharness uses: regex='appVersionName = "(.+)"'
  • Other workflows (build.yml, build-authenticator.yml) use: ([^"]+)
  • The .+ pattern matches Fastlane but differs from other build workflows
  • Note: This was intentionally aligned with Fastlane per commit 70747c3, but creates inconsistency with other workflows
  • Recommendation: Document why this differs, or consider using ([^"]+) like the other workflows for robustness

💭 Suggestions

3. Missing Quality Checks (.github/workflows/build-testharness.yml)

  • Other workflows run bundle exec fastlane check before building
  • Testharness workflow omits this step
  • Clarification from review: Since testharness is a test application, this is intentionally omitted (appropriate decision)

4. Push Trigger on All Branches (.github/workflows/build-testharness.yml:4-6)

  • Currently triggers on any branch when testharness/** files change
  • Other workflows (build.yml, build-authenticator.yml) only trigger on main/release branches
  • Question: Is triggering on all branches intentional for development/testing purposes?
  • Recommendation: Document this decision or consider limiting to main/release branches if appropriate

5. Error Handling for Version Extraction (.github/workflows/build-testharness.yml:107-110)

  • Regex extraction has no error handling if it fails:
regex='appVersionName = "(.+)"'
if [[ "$(cat gradle/libs.versions.toml)" =~ $regex ]]; then
  VERSION_NAME="${BASH_REMATCH[1]}"
fi
# No else clause - VERSION_NAME silently remains empty on failure
  • Recommendation: Add error handling:
if [[ "$(cat gradle/libs.versions.toml)" =~ $regex ]]; then
  VERSION_NAME="${BASH_REMATCH[1]}"
else
  echo "::error::Failed to extract version name from libs.versions.toml"
  exit 1
fi

6. Missing CI Build Info Script (.github/workflows/build-testharness.yml)

  • Other workflows call ./scripts/update_app_ci_build_info.sh to embed CI metadata
  • Testharness omits this
  • Question: Is CI build tracking needed for testharness, or intentionally omitted?

✅ Positive Observations

Excellent Security Practices

  • ✓ Minimal permissions (contents:read, packages:read)
  • ✓ No credential persistence (persist-credentials: false)
  • ✓ All actions pinned to SHA hashes for supply chain security
  • ✓ SHA256 checksums generated for artifacts
  • Security Posture: STRONG 🔒

Proper Version Management Integration

  • ✓ Correctly uses _version.yml reusable workflow
  • ✓ Dynamic versioning via Fastlane's setBuildVersionInfo
  • ✓ Gradle properly reads from version catalog (libs.versions.toml)
  • Architecture alignment: EXCELLENT

Clean Code Quality

  • ✓ Well-structured, readable YAML
  • ✓ Idiomatic Kotlin in build.gradle.kts (safe casts, functional style)
  • ✓ Proper artifact naming and handling
  • ✓ Efficient caching strategy
  • ✓ Logical PR label categorization

Overall Assessment

Status: ✅ APPROVED WITH MINOR RECOMMENDATIONS

This PR demonstrates excellent engineering practices and strong security posture. The implementation is clean, well-structured, and properly integrated with the existing CI/CD infrastructure.

Recommended Actions Before Merge:

  1. Update actions/upload-artifact to v5.0.0 (Warning Android Accessibility Service #1) - Quick win for consistency
  2. Add error handling for version regex extraction (Suggestion Subdomain Only Option for Sites #5) - Improves robustness
  3. Document push trigger strategy (Suggestion i18n #4) - Clarifies intent

Optional Enhancements:

Code Quality Score: 8.5/10 (Very Good)
Security Score: 9.5/10 (Excellent)
Maintainability: 8/10 (Good)

Great work maintaining consistency with the existing codebase! 🚀


SaintPatrck added a commit that referenced this pull request Nov 21, 2025
Corrects regex pattern in build-testharness.yml to match the pattern
used in build-authenticator.yml. The previous regex captured the
closing quote as part of the version name, which would result in
malformed version strings.

Before: regex='appVersionName = "([^"]+")'  → captures "2025.11.1"
After:  regex='appVersionName = "([^"]+)"'  → captures "2025.11.1"

Addresses Finding 2 from code review of PR #6181.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
SaintPatrck added a commit that referenced this pull request Nov 21, 2025
Changes testharness module to read versionCode and versionName from
libs.versions.toml instead of using hardcoded values. This aligns
with the pattern used by app and authenticator modules and ensures
the setBuildVersionInfo Fastlane task in the workflow actually
updates the testharness build version.

Before:
  versionCode = 1
  versionName = "1.0.0"

After:
  versionCode = libs.versions.appVersionCode.get().toInt()
  versionName = libs.versions.appVersionName.get()

Addresses Finding 3 from code review of PR #6181.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
versionCode:"$VERSION_CODE" \
versionName:"$VERSION_NAME_INPUT"

regex='appVersionName = "([^"]+)"'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Regex pattern mismatch with Fastlane implementation

Details

The regex pattern here differs from the Fastlane setBuildVersionInfo implementation:

Workflow (line 104-107):

regex='appVersionName = "([^"]+)"'
if [[ "$(cat gradle/libs.versions.toml)" =~ $regex ]]; then
  VERSION_NAME="${BASH_REMATCH[1]}"
fi

Fastlane (Fastfile:136):

currentVersionName = tomlLibraryText.match(/appVersionName = "(.+)"/).captures[0]

The workflow pattern uses [^"]+ while Fastlane uses .+. While functionally similar for valid version strings, this inconsistency could cause subtle differences in edge cases (e.g., if version contains escaped quotes).

Recommendation: Use the same pattern as Fastlane for consistency:

regex='appVersionName = "(.+)"'

This also resolves the "trailing quote" fix mentioned in commit 98dc73b more elegantly.

SaintPatrck added a commit that referenced this pull request Nov 21, 2025
Updates workflow regex to match the pattern used in Fastlane's
setBuildVersionInfo lane for consistency across the codebase.

Before: regex='appVersionName = "([^"]+)"'
After:  regex='appVersionName = "(.+)"'

Both patterns work correctly for standard version strings, but
using the same pattern as Fastlane improves maintainability and
reduces potential confusion.

Addresses Finding 1 from code review of PR #6181.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
name: Calculate Version Name and Number
uses: bitwarden/android/.github/workflows/_version.yml@main
with:
app_codename: "bwth"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 This will trigger a missing tag warning (code), given the purpose of it having the same version of Password Manager would help also.

Suggested change
app_codename: "bwth"
app_codename: "bwpm"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to add testharness/ to label-pr.json, right?

Copy link
Member

@vvolkgang vvolkgang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, left some comments.

SaintPatrck added a commit that referenced this pull request Dec 1, 2025
Corrects regex pattern in build-testharness.yml to match the pattern
used in build-authenticator.yml. The previous regex captured the
closing quote as part of the version name, which would result in
malformed version strings.

Before: regex='appVersionName = "([^"]+")'  → captures "2025.11.1"
After:  regex='appVersionName = "([^"]+)"'  → captures "2025.11.1"

Addresses Finding 2 from code review of PR #6181.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
SaintPatrck added a commit that referenced this pull request Dec 1, 2025
Changes testharness module to read versionCode and versionName from
libs.versions.toml instead of using hardcoded values. This aligns
with the pattern used by app and authenticator modules and ensures
the setBuildVersionInfo Fastlane task in the workflow actually
updates the testharness build version.

Before:
  versionCode = 1
  versionName = "1.0.0"

After:
  versionCode = libs.versions.appVersionCode.get().toInt()
  versionName = libs.versions.appVersionName.get()

Addresses Finding 3 from code review of PR #6181.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
SaintPatrck added a commit that referenced this pull request Dec 1, 2025
Updates workflow regex to match the pattern used in Fastlane's
setBuildVersionInfo lane for consistency across the codebase.

Before: regex='appVersionName = "([^"]+)"'
After:  regex='appVersionName = "(.+)"'

Both patterns work correctly for standard version strings, but
using the same pattern as Fastlane improves maintainability and
reduces potential confusion.

Addresses Finding 1 from code review of PR #6181.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@SaintPatrck SaintPatrck force-pushed the workflow/build-testharness branch from e708989 to 824dcbb Compare December 1, 2025 22:30
@SaintPatrck SaintPatrck requested a review from vvolkgang December 1, 2025 22:31
SaintPatrck and others added 5 commits December 2, 2025 14:20
- Create .github/workflows/build-testharness.yml for manual workflow dispatch
- Configure testharness module to read version from libs.versions.toml
- Implement Fastlane-based version management for consistency with other build workflows
- Build debug APK (com.bitwarden.testharness.dev-debug.apk) with SHA256 checksum
- Use _version.yml reusable workflow with codename "bwth" and base version 0

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Corrects regex pattern in build-testharness.yml to match the pattern
used in build-authenticator.yml. The previous regex captured the
closing quote as part of the version name, which would result in
malformed version strings.

Before: regex='appVersionName = "([^"]+")'  → captures "2025.11.1"
After:  regex='appVersionName = "([^"]+)"'  → captures "2025.11.1"

Addresses Finding 2 from code review of PR #6181.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Changes testharness module to read versionCode and versionName from
libs.versions.toml instead of using hardcoded values. This aligns
with the pattern used by app and authenticator modules and ensures
the setBuildVersionInfo Fastlane task in the workflow actually
updates the testharness build version.

Before:
  versionCode = 1
  versionName = "1.0.0"

After:
  versionCode = libs.versions.appVersionCode.get().toInt()
  versionName = libs.versions.appVersionName.get()

Addresses Finding 3 from code review of PR #6181.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Updates workflow regex to match the pattern used in Fastlane's
setBuildVersionInfo lane for consistency across the codebase.

Before: regex='appVersionName = "([^"]+)"'
After:  regex='appVersionName = "(.+)"'

Both patterns work correctly for standard version strings, but
using the same pattern as Fastlane improves maintainability and
reduces potential confusion.

Addresses Finding 1 from code review of PR #6181.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Adjust the CI/CD configuration for the `testharness` module to ensure proper build triggering and PR labeling.

- **Update `.github/label-pr.json`**: Associate changes in the `testharness/` directory with the `app:password-manager` label, ensuring pull requests touching this module are categorized correctly.
- **Update `.github/workflows/build-testharness.yml`**:
    - Add a `push` trigger restricted to paths within `testharness/**`, enabling automatic builds when relevant files change.
    - Change the `app_codename` passed to the version calculation workflow from `"bwth"` to `"bwpm"` to align with the Password Manager application context.
Customize the output filename for the test harness APK to match the application ID, ensuring a predictable and consistent naming convention. This change simplifies artifact handling in CI workflows by removing variable build type suffixes from the filename.

Specific changes include:
*   Update `testharness/build.gradle.kts` to iterate through `applicationVariants` and explicitly set the `outputFileName` of each output to `$applicationId.apk`.
*   Import `BaseVariantOutputImpl` to support the casting required for modifying the output filename.
*   Update `.github/workflows/build-testharness.yml` to reflect the new APK filename (`com.bitwarden.testharness.dev.apk` instead of `com.bitwarden.testharness.dev-debug.apk`) in both the artifact upload step and the checksum generation step.
*   Rename the uploaded checksum artifact from `com.bitwarden.testharness.dev-debug.apk-sha256.txt` to `com.bitwarden.testharness.dev.apk-sha256.txt`.
Update the `build-testharness.yml` workflow to use the correct filename when generating the SHA256 checksum for the Test Harness APK.

The previous command outputted the checksum to `com.bitwarden.testharness.dev-debug.apk-sha256.txt`, which included an extraneous `-debug` suffix that did not match the expected artifact naming convention. The output file is now correctly named `com.bitwarden.testharness.dev.apk-sha256.txt`.
@SaintPatrck SaintPatrck force-pushed the workflow/build-testharness branch from f96ece5 to 0f5ae6b Compare December 2, 2025 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants