Skip to content

Commit

Permalink
Merge branch 'youtube:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
johnxwork authored Jul 19, 2023
2 parents fb383f0 + 88dc475 commit 0503cac
Show file tree
Hide file tree
Showing 1,221 changed files with 29,662 additions and 137,260 deletions.
20 changes: 20 additions & 0 deletions .github/actions/on_host_test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,16 @@ runs:
run: |
echo "PYTHONPATH=$GITHUB_WORKSPACE" >> $GITHUB_ENV
echo "TEST_RESULTS_DIR=${GITHUB_WORKSPACE}/unit-test-results" >> $GITHUB_ENV
echo "COVERAGE_DIR=${GITHUB_WORKSPACE}/coverage" >> $GITHUB_ENV
echo "TEST_REPORT_FILE=${GITHUB_WORKSPACE}/${{matrix.platform}}-${{matrix.shard}}" >> $GITHUB_ENV
- name: Run Tests
shell: bash
run: |
set -x
# Starboard toolchains are downloaded to a different dir on github. Create a symlink to reassure our tooling that everything is fine.
if [ -d /root/starboard-toolchains ]; then
ln -s /root/starboard-toolchains /github/home/starboard-toolchains
fi
loader_args=''
if [ "${COBALT_BOOTLOADER}" != "null" ]; then
loader_args="--loader_platform ${COBALT_BOOTLOADER} --loader_config ${{matrix.config}}"
Expand All @@ -77,6 +82,10 @@ runs:
xvfb-run -a --server-args="-screen 0 1920x1080x24i +render +extension GLX -noreset" python3 $GITHUB_WORKSPACE/cobalt/black_box_tests/black_box_tests.py --platform ${{matrix.target_platform}} --config ${{matrix.config}} ${loader_args} --test_set wpt
elif [[ "${{matrix.shard}}" == 'evergreen' ]]; then
xvfb-run -a --server-args="-screen 0 1920x1080x24i +render +extension GLX -noreset" python3 $GITHUB_WORKSPACE/cobalt/evergreen_tests/evergreen_tests.py --platform ${{matrix.target_platform}} --config ${{matrix.config}} ${loader_args} --no-can_mount_tmpfs
elif [[ "${{matrix.shard}}" == 'evergreen-as-blackbox' ]]; then
xvfb-run -a --server-args="-screen 0 1920x1080x24i +render +extension GLX -noreset" python3 $GITHUB_WORKSPACE/cobalt/black_box_tests/black_box_tests.py --platform ${{matrix.target_platform}} --config ${{matrix.config}} ${loader_args} --test_set evergreen
elif [[ "${{matrix.shard}}" == 'coverage' ]]; then
xvfb-run -a --server-args="-screen 0 1920x1080x24i +render +extension GLX -noreset" python3 ${GITHUB_WORKSPACE}/starboard/tools/testing/test_runner.py --platform ${{matrix.target_platform}} --config ${{matrix.config}} -r ${loader_args} --xml_output_dir=${TEST_RESULTS_DIR} --coverage_dir=${COVERAGE_DIR} --coverage_report
else
if [[ "${{inputs.os}}" == 'windows' ]]; then
python3 ${GITHUB_WORKSPACE}/starboard/tools/testing/test_runner.py --platform ${{matrix.target_platform}} --config ${{matrix.config}} -s ${{matrix.shard}} -r
Expand All @@ -97,3 +106,14 @@ runs:
with:
name: unit-test-reports
path: ${{env.TEST_REPORT_FILE}}
- name: Upload coverage html report
if: success() && matrix.shard == 'coverage'
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: ${{env.COVERAGE_DIR}}/html
- name: Upload to Codecov
if: success() && matrix.shard == 'coverage'
uses: codecov/codecov-action@v3
with:
files: ${{env.COVERAGE_DIR}}/report.txt
11 changes: 10 additions & 1 deletion .github/config/evergreen-x64.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
"docker_service": "build-linux-evergreen",
"on_host_test": true,
"bootloader": "linux-x64x11",
"on_host_test_shards": ["0", "1", "2", "3", "blackbox", "wpt", "evergreen"],
"on_host_test_shards": [
"0",
"1",
"2",
"3",
"blackbox",
"wpt",
"evergreen",
"evergreen-as-blackbox"
],
"platforms": [
"evergreen-x64",
"evergreen-x64-sbversion-15",
Expand Down
16 changes: 16 additions & 0 deletions .github/config/linux-coverage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"docker_service": "build-linux",
"on_host_test": true,
"on_host_test_shards": ["coverage"],
"platforms": [
"linux-coverage"
],
"includes": [
{
"name":"linux",
"platform":"linux-coverage",
"target_platform":"linux-x64x11",
"extra_gn_arguments":"use_clang_coverage=true"
}
]
}
2 changes: 1 addition & 1 deletion .github/config/win32.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"name":"win32",
"platform":"win32",
"target_platform":"win-win32",
"extra_gn_arguments":"is_clang=false visual_studio_path=\\\"C:/BuildTools/VC/Tools/MSVC/14.15.26726\\\" msvc_path=\\\"C:/BuildTools/VC/Tools/MSVC/14.15.26726\\\""
"extra_gn_arguments":"is_clang=false"
}
]
}
14 changes: 14 additions & 0 deletions .github/workflows/linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,17 @@ jobs:
platform: linux-modular
nightly: ${{ github.event.inputs.nightly }}
modular: true
linux-coverage:
# Run on main branch for pushes, PRs and manual invocations.
if: |
${{ github.ref == 'refs/heads/main' &&
(github.event_name == 'push' ||
github.event_name == 'pull_request' ||
(github.event_name == 'workflow_dispatch' && inputs.nightly == 'false')) }}
uses: ./.github/workflows/main.yaml
permissions:
packages: write
pull-requests: write
with:
platform: linux-coverage
nightly: ${{ github.event.inputs.nightly }}
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ jobs:
type: ondevice
os: linux

# Runs on-host integration and unit tests.
# Runs on-device integration and unit tests.
on-device-test:
needs: [initialize, build]
# Run ODT when on_device label is applied on PR.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main_win.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ jobs:
build:
needs: [initialize]
permissions: {}
runs-on: [self-hosted, X64, Windows]
runs-on: [self-hosted, win32]
name: ${{matrix.name}}_${{matrix.config}}
strategy:
fail-fast: false
Expand Down Expand Up @@ -164,7 +164,7 @@ jobs:
needs: [initialize, build]
permissions: {}
if: needs.initialize.outputs.on_host_test == 'true'
runs-on: [self-hosted, Windows, X64]
runs-on: [self-hosted, win32]
name: ${{matrix.name}}_${{matrix.shard}}_test
strategy:
fail-fast: false
Expand Down
17 changes: 2 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ repos:
cobalt/fetch/embedded_scripts|
cobalt/loader/cors_preflight.cc|
internal/cobalt/browser/splash_screen/youtube_splash_screen.html|
internal/starboard/shared/playstation/storage_internal.cc
internal/starboard/shared/playstation/storage_internal.cc|
starboard/shared/win32/media_transform.cc
)
- repo: local
Expand Down Expand Up @@ -166,20 +167,6 @@ repos:
stages: [push]
always_run: true
pass_filenames: false
- id: osslint
name: osslint
entry: python precommit_hooks/osslint_wrapper.py
language: python
types: [text]
stages: [manual]
- id: internal-file-check
name: Internal File Check
entry: python precommit_hooks/internal_file_check_wrapper.py
language: python
types: [text]
# TODO: Remove docker-compose-windows.yml after internal check evaluates
# properly on it.
exclude: '(^docker-compose-windows(-internal)?.yml|EXCLUDE\.FILES(\.RECURSIVE)?|codereview\.settings)$'
- id: gn-format
name: GN format
entry: gn format
Expand Down
127 changes: 79 additions & 48 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,95 @@
# Contributing to Cobalt
# Contributing guidelines

We'd love to hear about how you would like to contribute to Cobalt! It's worth
reading through this modest document first, to understand the process and to
make sure you know what to expect.
## Pull Request Checklist

Before sending your pull requests, make sure you do the following:

## Before You Contribute
- Read the [contributing guidelines](CONTRIBUTING.md).
- Ensure you have signed the
[Contributor License Agreement (CLA)](https://cla.developers.google.com/).
- Check if your changes are consistent with the:
- [General guidelines](#general-guidelines-and-philosophy-for-contribution).
- [Coding Style](#coding-style).
- Run the [unit tests](#running-unit-tests).

### As an Individual
### Contributor License Agreements

Before Cobalt can use your code, as an unaffiliated individual, you must sign
the [Google Individual Contributor License Agreement](https://cla.developers.google.com/about/google-individual) (CLA), which you can do online.
We'd love to accept your patches! Before we can take them, we have to jump a couple of legal hurdles.

### As a Company
Please fill out either the individual or corporate Contributor License Agreement (CLA).

If you are a company that wishes to have one or more employees contribute to
Cobalt on-the-clock, that is covered by a different agreement, the
[Software Grant and Corporate Contributor License Agreement](https://cla.developers.google.com/about/google-corporate).
* If you are an individual writing original source code and you're sure you own the intellectual property, then you'll need to sign an [individual CLA](https://code.google.com/legal/individual-cla-v1.0.html).
* If you work for a company that wants to allow you to contribute your work, then you'll need to sign a [corporate CLA](https://code.google.com/legal/corporate-cla-v1.0.html).

### What is a CLA?
Follow either of the two links above to access the appropriate CLA and instructions for how to sign and return it. Once we receive it, we'll be able to accept your pull requests.

The Contributor License Agreement is necessary mainly because you own the
copyright to your changes, even after your contribution becomes part of our
codebase, so we need your permission to use and distribute your code. We also
need to be sure of various other things — for instance that you'll tell us if
you know that your code infringes on other people's patents. You don't have to
sign the CLA until after you've submitted your code for review and a member has
approved it, but you must do it before we can put your code into our codebase.
Before you start working on a larger contribution, you should get in touch with
us first with your idea so that we can help out and possibly guide
you. Coordinating up front makes it much easier to avoid frustration later on.
***NOTE***: Only original source code from you and other people that have signed the CLA can be accepted into the main repository.

### Community Guidelines

### Code Reviews
This project follows
[Google's Open Source Community Guidelines](https://opensource.google/conduct/).

All submissions, including submissions by project members, require review. We
currently use [Gerrit Code Review](https://www.gerritcodereview.com/) for this
purpose. Currently, team-member submissions go through private reviews, and
external submissions go through public reviews.
### Contributing code

If you have improvements to Cobalt, send us your pull requests! For those
just getting started, Github has a
[how to](https://help.github.com/articles/using-pull-requests/).

## Submission Process
Cobalt team members will be assigned to review your pull requests. A team
member will need to approve the workflow runs for each pull request. Once the
pull requests are approved and pass *all* presubmit checks, a Cobalt
team member will merge the pull request.

We admit that this submission process is currently not completely optimized to
make contributions easy, and we hope to make improvements to it in the
future. It will always include some form of signing the CLA and submitting the
code for review before merging changes into the Cobalt master tree.
### Contribution guidelines and standards

1. Ensure you or your company have signed the appropriate CLA (see "Before You
Contribute" above).
1. Rebase your changes down into a single git commit.
1. Run `git clang-format HEAD~` to apply default C++ formatting rules,
followed by `git commit -a --amend` to squash any formatting changes
into your commit.
1. Run `git push origin HEAD:refs/for/master` to upload the review to
[Cobalt's Gerrit instance](https://cobalt-review.googlesource.com/).
1. Someone from the maintainers team will review the code, putting up comments
on any things that need to change for submission.
1. If you need to make changes, make them locally, test them, then `git commit
--amend` to add them to the *existing* commit. Then return to step 2.
1. If you do not need to make any more changes, a maintainer will integrate
the change into our private repository, and it will get pushed out to the
public repository after some time.
Before sending your pull request for
[review](https://github.com/tensorflow/tensorflow/pulls),
make sure your changes are consistent with the guidelines and follow the
Cobalt coding style.

#### General guidelines and philosophy for contribution

* Include unit tests when you contribute new features, as they help to:
1. Prove that your code works correctly
1. Guard against future breaking changes to lower the maintenance cost.
* Bug fixes also generally require unit tests, because the presence of bugs
usually indicates insufficient test coverage.
* When you contribute a new feature to Cobalt, the maintenance burden is
(by default) transferred to the Cobalt team. This means that the benefit
of the contribution must be compared against the cost of maintaining the
feature.
* As every PR requires several CPU/GPU hours of CI testing, we discourage
submitting PRs to fix one typo, one warning,etc. We recommend fixing the
same issue at the file level at least (e.g.: fix all typos in a file, fix
all compiler warning in a file, etc.)

#### License

Include a license at the top of new files. Check existing files for license examples.

#### Coding style

Cobalt follows the
[Chromium style guide](https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/styleguide.md).

Cobalt uses pre-commit to ensure good coding style. Create a python 3 virtual
environment for working with Cobalt, then install `pre-commit` with:

```bash
$ pre-commit install -t post-checkout -t pre-commit -t pre-push --allow-missing-config
```

`pre-commit` will mostly run automatically, and can also be invoked manually.
You can find documentation about it at https://pre-commit.com/.

#### Running unit tests

First, ensure Docker and docker-compose are installed on your system. Then,
you can run unit tests for our linux reference implementation using:

```bash
$ docker-compose up --build --no-start linux-x64x11-unittest
$ PLATFORM=linux-x64x11 CONFIG=devel TARGET=all docker-compose run linux-x64x11
$ PLATFORM=linux-x64x11 CONFIG=devel docker-compose run linux-x64x11-unittest
```
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# Cobalt [![Build Status](https://img.shields.io/badge/-Build%20Status-blueviolet)](https://github.com/youtube/cobalt/blob/main/BUILD_STATUS.md)
# Cobalt [![Build Matrix](https://img.shields.io/badge/-Build%20Matrix-blueviolet)](https://github.com/youtube/cobalt/blob/main/BUILD_STATUS.md)

[![codecov](https://codecov.io/github/youtube/cobalt/branch/main/graph/badge.svg?token=RR6MKKNYNV)](https://codecov.io/github/youtube/cobalt)
[![lint](https://github.com/youtube/cobalt/actions/workflows/lint.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/lint.yaml?query=event%3Apush+branch%3Amain)
[![java](https://github.com/youtube/cobalt/actions/workflows/gradle.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/gradle.yaml?query=event%3Apush+branch%3Amain)
[![python](https://github.com/youtube/cobalt/actions/workflows/pytest.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/pytest.yaml?query=event%3Apush+branch%3Amain) \
[![android](https://github.com/youtube/cobalt/actions/workflows/android.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/android.yaml?query=event%3Apush+branch%3Amain)
[![evergreen](https://github.com/youtube/cobalt/actions/workflows/evergreen.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/evergreen.yaml?query=event%3Apush+branch%3Amain)
[![linux](https://github.com/youtube/cobalt/actions/workflows/linux.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/linux.yaml?query=event%3Apush+branch%3Amain)
[![raspi-2](https://github.com/youtube/cobalt/actions/workflows/raspi-2.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/raspi-2.yaml?query=event%3Apush+branch%3Amain)
[![win32](https://github.com/youtube/cobalt/actions/workflows/win32.yaml/badge.svg?branch=main&event=push)](https://github.com/youtube/cobalt/actions/workflows/win32.yaml?query=event%3Apush+branch%3Amain)

## Overview

Expand Down
4 changes: 2 additions & 2 deletions base/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ if (!is_starboard) {
import("//build/config/allocator.gni")
import("//build/config/jumbo.gni")
import("//build/timestamp.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//testing/test.gni")
}
import("//testing/libfuzzer/fuzzer_test.gni")
import("//testing/test.gni")

declare_args() {
# Indicates if the Location object contains the source code information
Expand Down
3 changes: 0 additions & 3 deletions base/message_loop/message_loop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "base/threading/thread_id_name_manager.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "nb/memory_scope.h"

namespace base {

Expand Down Expand Up @@ -405,7 +404,6 @@ void MessageLoop::EnsureWorkScheduled() {
}

void MessageLoop::SetThreadTaskRunnerHandle() {
TRACK_MEMORY_SCOPE("MessageLoop");
DCHECK_CALLED_ON_VALID_THREAD(bound_thread_checker_);
// Clear the previous thread task runner first, because only one can exist at
// a time.
Expand Down Expand Up @@ -531,7 +529,6 @@ bool MessageLoop::DoWork() {
}

bool MessageLoop::DoDelayedWork(TimeTicks* next_delayed_work_time) {
TRACK_MEMORY_SCOPE("MessageLoop");
if (!task_execution_allowed_ ||
!pending_task_queue_.delayed_tasks().HasTasks()) {
*next_delayed_work_time = TimeTicks();
Expand Down
2 changes: 0 additions & 2 deletions base/message_loop/message_pump_io_starboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "base/observer_list.h"
#include "base/posix/eintr_wrapper.h"
#include "base/time/time.h"
#include "nb/memory_scope.h"
#include "starboard/common/socket.h"
#include "starboard/socket_waiter.h"

Expand Down Expand Up @@ -171,7 +170,6 @@ void MessagePumpIOStarboard::RemoveIOObserver(IOObserver* obs) {

// Reentrant!
void MessagePumpIOStarboard::Run(Delegate* delegate) {
TRACK_MEMORY_SCOPE("MessageLoop");
AutoReset<bool> auto_reset_in_run(&in_run_, true);

for (;;) {
Expand Down
Loading

0 comments on commit 0503cac

Please sign in to comment.