Skip to content

Conversation

@Awallky
Copy link
Contributor

@Awallky Awallky commented Feb 11, 2026

Enable the browser test runners in CI by building and pushing a specialized Docker image when cobalt_browsertests is a target.

This update:

  1. Authenticates with the us-west1 Artifact Registry.
  2. Colocates the browser test Dockerfile with its dependencies in the artifacts directory.
  3. Builds and pushes the image to: us-west1-docker.pkg.dev/ytlr-image-hosting/integration-test-images/avvall-service-test
  4. Uses a unique tag based on the run ID and platform for traceability.

This ensures that the necessary environment is available for downstream on-device or on-host browser test execution.

Bug: 483488213

Enable the browser test runners in CI by building and pushing a
specialized Docker image when cobalt_browsertests is a target.

This update:
1. Authenticates with the us-west1 Artifact Registry.
2. Colocates the browser test Dockerfile with its dependencies in the
   artifacts directory.
3. Builds and pushes the image to:
   us-west1-docker.pkg.dev/ytlr-image-hosting/integration-test-images/avvall-service-test
4. Uses a unique tag based on the run ID and platform for traceability.

This ensures that the necessary environment is available for downstream
on-device or on-host browser test execution.

Bug: 473909877
@github-actions
Copy link

🤖 Gemini Suggested Commit Message


ci: Build and push browser test Docker images

Modify the upload_test_artifacts action to build and push
a specialized Docker image for browser tests. This image is
created when cobalt_browsertests is a target.

This change authenticates with the Artifact Registry and
pushes the image with a unique tag. It provides a consistent
environment for downstream on-device or on-host browser
test execution in CI.

Bug: 483488213

💡 Pro Tips for a Better Commit Message:

  1. Influence the Result: Want to change the output? You can write custom prompts or instructions directly in the Pull Request description. The model uses that text to generate the message.
  2. Re-run the Generator: Post a comment with: /generate-commit-message

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds functionality to build and push a Docker image for browser tests within the CI/CD pipeline. A critical vulnerability was identified where a service account access token could be exposed in GitHub Actions logs due to set -x tracing combined with printf ${ACCESS_TOKEN}. Additionally, there are areas for improvement regarding shell script safety, robustness of JSON parsing, and maintainability, including an unsafe use of printf, a brittle JSON check, and a hardcoded image name.

- Remove 'set -x' to prevent ACCESS_TOKEN leakage in CI logs.
- Use 'printf %s' for safe token handling to avoid interpretation of
  format specifiers or backslashes.
- Add '-s' to curl for silent execution.
Pipe curl output directly into docker login to avoid using an
intermediate variable for the access token, further improving security
and readability.
Replace grep with a robust jq filter to detect cobalt_browsertests in
the targets JSON. This prevents false positives and handles fully
qualified target names correctly.
Add docker_image_name as an optional input to the action to avoid
hardcoding. This improves reusability for different test suites and
services.
@Awallky
Copy link
Contributor Author

Awallky commented Feb 11, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new capability to the upload_test_artifacts action to build and push a Docker image for browser tests. A high-severity command injection vulnerability has been identified in .github/actions/upload_test_artifacts/action.yaml due to direct interpolation of GitHub Action inputs and matrix variables into a shell script, which can lead to arbitrary command execution. This should be remediated by using environment variables. Additionally, the action contains hardcoded values that reduce reusability and a potential correctness issue in the browser test target detection logic.

Refine the jq filter to check for exact target matches (or exact
suffixes) rather than substrings. This prevents false positives from
similarly named targets while still correctly handling fully qualified
names.
- Use environment variables for inputs and matrix values in shell
  scripts to prevent command injection vulnerabilities.
- Promote registry region, project, and repository to action inputs to
  improve reusability.
- Rename 'Login to us-west1 GAR' to 'Login to GAR' to reflect its
  parameterized nature.
- Update on_device_tests_gateway_client.py to accept --docker_tag and
  include it in test parameters.
- Add docker_tag input to on_device_tests and internal_tests actions.
- Reconstruct and pass the Docker image tag in main.yaml for
  on-device, E2E, and YTS tests.

This allows the test lab to identify and pull the correct Docker image
for each test session.
@Awallky
Copy link
Contributor Author

Awallky commented Feb 11, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request integrates Docker image building and pushing for browser tests into the CI workflow. However, it introduces a high-severity command injection vulnerability in the internal_tests and on_device_tests actions, as the docker_tag input is directly interpolated into shell scripts instead of being handled safely via environment variables. Additionally, there is a high-severity suggestion to improve authentication with Google Artifact Registry and a medium-severity suggestion to parameterize the Dockerfile path for enhanced action flexibility.

Ensure all inputs, including docker_tag, are passed via environment
variables in shell scripts within composite actions. This prevents
arbitrary command execution from maliciously crafted input values.
- Remove Docker build/push from upload_test_artifacts action (runs in container).
- Add docker-browsertests-image job to main.yaml to run on host.
- Download test artifacts from GCS using gsutil in the new job.
- Update downstream test jobs to depend on docker-browsertests-image.
- name: Parse Test Target JSON
id: test-target-json
uses: ./.github/actions/test_targets_json
- name: Build and Push Browser Test Docker Image

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: GitHub-owned GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help
- Add cobalt/testing/browser_tests/tools to CI_ESSENTIALS.
- Update cp command to use the correct relative path for the Dockerfile.
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.

1 participant