Skip to content

Commit c41cdd0

Browse files
committed
WIP: TVOS Build
Change-Id: Ibc15083c110f10095c17a757532253e9d878ce9b
1 parent 28d6cd1 commit c41cdd0

6 files changed

Lines changed: 134 additions & 6 deletions

File tree

.github/actions/build/action.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,26 @@ runs:
2020
- name: GN gen
2121
run: |
2222
cd cobalt/src
23-
cobalt/build/gn.py -p ${{ matrix.platform }} -C ${{ matrix.config }}
23+
if [[ "${{ matrix.platform }}" == "tvos" ]]; then
24+
cobalt/build/gn.py -p ${{ matrix.platform }} -C ${{ matrix.config }} --no-rbe --cc_wrapper=ccache
25+
else
26+
cobalt/build/gn.py -p ${{ matrix.platform }} -C ${{ matrix.config }}
27+
fi
28+
shell: bash
29+
- name: Install sccache
30+
if: ${{ matrix.platform == 'tvos' }}
31+
run: brew install sccache
32+
- name: Configure sccache
33+
if: ${{ matrix.platform == 'tvos' }}
2434
shell: bash
35+
run: |
36+
set -x
37+
echo "${{ secrets.SCCACHE_GCS_KEY_MAC }}" | base64 --decode > "${HOME}/gcloud.json"
38+
echo "SCCACHE_GCS_KEY_PATH=${HOME}/gcloud.json" >> $GITHUB_ENV
39+
echo "SCCACHE=1" >> $GITHUB_ENV
40+
echo "SCCACHE_GCS_BUCKET=cobalt-kokoro-sccache-mac" >> $GITHUB_ENV
41+
echo "SCCACHE_GCS_RW_MODE=READ_WRITE" >> $GITHUB_ENV
42+
echo "SCCACHE_IDLE_TIMEOUT=0" >> $GITHUB_ENV
2543
- name: List GN args
2644
run: |
2745
cd cobalt/src

.github/actions/depot_tools/action.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ runs:
6464
gclient validate
6565
shell: bash
6666

67+
- name: Set target OS for TvOS
68+
if: contains(matrix.platform, 'tvos')
69+
run: |
70+
cd cobalt
71+
echo "target_os=['ios']" >> .gclient
72+
gclient validate
73+
shell: bash
74+
6775
- name: Run gclient sync
6876
if: inputs.run_sync == 'true'
6977
run: |

.github/config/tvos.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"docker_service": "",
3+
"docker_required": false,
4+
"build_runners": [
5+
"macos-latest"
6+
],
7+
"platforms": [
8+
"chromium_mac-arm64"
9+
],
10+
"build_configs": [
11+
"devel"
12+
],
13+
"targets": [
14+
"content_shell"
15+
],
16+
"includes": [
17+
{
18+
"name": "mac",
19+
"platform": "chromium_mac-arm64"
20+
}
21+
]
22+
}

.github/workflows/main.yaml

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ on:
2121
secrets:
2222
datadog_api_key:
2323
required: false
24+
SCCACHE_GCS_KEY_MAC:
25+
required: false
2426

2527
concurrency:
2628
# Cancel existing jobs on the same workflow, platform, and branch (or sha if merged).
@@ -83,6 +85,13 @@ jobs:
8385
set -x
8486
platforms=$(cat ${GITHUB_WORKSPACE}/.github/config/${{ inputs.platform }}.json | jq -c '.platforms')
8587
echo "platforms=${platforms}" >> $GITHUB_OUTPUT
88+
- name: Select build runners
89+
id: set-build-runners
90+
shell: bash
91+
run: |
92+
set -x
93+
build_runners=$(cat ${GITHUB_WORKSPACE}/.github/config/${{ inputs.platform }}.json | jq -c '.build_runners // ["self-hosted", "chrobalt-linux-runner"]' )
94+
echo "build_runners=${build_runners}" >> $GITHUB_OUTPUT
8695
- name: Set build targets
8796
id: set-targets
8897
shell: bash
@@ -211,6 +220,13 @@ jobs:
211220
# Create a zero-indexed list of shards for use by matrix, e.g. [0,1,2,3,4,5].
212221
gtest_shards="[$(seq -s, 0 1 $((${num_gtest_shards} - 1)))]"
213222
echo "gtest_shards=${gtest_shards}" >> $GITHUB_OUTPUT
223+
- name: Set number Docker Requirement
224+
id: set-docker-required
225+
shell: bash
226+
run: |
227+
set -x
228+
docker_required=$(cat ${GITHUB_WORKSPACE}/.github/config/${{ inputs.platform }}.json | jq -rc '.docker_required')
229+
echo "docker_required=${docker_required}" >> $GITHUB_OUTPUT
214230
- name: Set Docker files checksum
215231
id: set-docker-hash
216232
shell: bash
@@ -220,6 +236,7 @@ jobs:
220236
echo "docker_content_sha=${docker_content_sha}" >> $GITHUB_OUTPUT
221237
outputs:
222238
platforms: ${{ steps.set-platforms.outputs.platforms }}
239+
build_runners: ${{ steps.set-build-runners.outputs.build_runners }}
223240
targets: ${{ steps.set-targets.outputs.targets }}
224241
build_configs: ${{ steps.set-build-configs.outputs.build_configs }}
225242
includes: ${{ steps.set-includes.outputs.includes }}
@@ -239,10 +256,12 @@ jobs:
239256
test_dimensions: ${{ steps.set-test-dimensions.outputs.test_dimensions }}
240257
test_attempts: ${{ steps.set-test-attempts.outputs.test_attempts }}
241258
num_gtest_shards: ${{ steps.set-gtest-shards.outputs.num_gtest_shards }}
259+
docker_required: ${{ steps.set-docker-required.outputs.docker_required }}
242260

243261
# Builds, tags, and pushes Cobalt docker build images to ghr.
244262
docker-build-image:
245263
needs: [initialize]
264+
if: needs.initialize.outputs.docker_required == 'true'
246265
runs-on: [self-hosted, chrobalt-linux-runner]
247266
steps:
248267
- name: Restore CI Essentials
@@ -262,7 +281,7 @@ jobs:
262281

263282
# Builds, tags, and pushes Cobalt unit test image to ghr.
264283
docker-unittest-image:
265-
if: needs.initialize.outputs.test_on_host == 'true'
284+
if: needs.initialize.outputs.test_on_host == 'true' && needs.initialize.outputs.docker_required == 'true'
266285
needs: [initialize]
267286
runs-on: [self-hosted, chrobalt-linux-runner]
268287
steps:
@@ -283,7 +302,7 @@ jobs:
283302

284303
# Builds, tags, and pushes Cobalt web test image to ghr.
285304
docker-webtest-image:
286-
if: needs.initialize.outputs.web_tests == 'true'
305+
if: needs.initialize.outputs.web_tests == 'true' && needs.initialize.outputs.docker_required == 'true'
287306
needs: [initialize]
288307
runs-on: [self-hosted, chrobalt-linux-runner]
289308
steps:
@@ -302,10 +321,37 @@ jobs:
302321
outputs:
303322
docker_tag: ${{ steps.build-docker-image.outputs.docker_tag }}
304323

305-
build:
324+
build-ready:
306325
needs: [initialize, docker-build-image]
307-
permissions: {}
308326
runs-on: [self-hosted, chrobalt-linux-runner]
327+
if: always()
328+
steps:
329+
- name: Build ready check
330+
id: build-ready
331+
env:
332+
DOCKER_BUILD_IMAGE_RESULT: ${{ needs.docker-build-image.result }}
333+
INITIALIZE_RESULT: ${{ needs.initialize.result }}
334+
DOCKER_REQUIRED: ${{ needs.initialize.outputs.docker_required }}
335+
run: |
336+
# Skip entirely if initialize failed
337+
if [ $INITIALIZE_RESULT != "success" ]; then
338+
echo "success=false" >> $GITHUB_OUTPUT
339+
exit 0
340+
fi
341+
# Skip if requires docker by docker-build-image failed
342+
if [ $DOCKER_REQUIRED == "true" && $DOCKER_BUILD_IMAGE_RESULT != "success" ]; then
343+
echo "success=false" >> $GITHUB_OUTPUT
344+
exit 0
345+
fi
346+
echo "success=true" >> $GITHUB_OUTPUT
347+
outputs:
348+
success: ${{ steps.build-ready.outputs.success }}
349+
350+
build:
351+
needs: [initialize, docker-build-image, build-ready]
352+
if: always() && needs.build-ready.outputs.success == 'true'
353+
permissions: {}
354+
runs-on: ${{ fromJSON(needs.initialize.outputs.build_runners) }}
309355
name: ${{ matrix.name }}_${{ matrix.config }}
310356
strategy:
311357
fail-fast: false

.github/workflows/tvos.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: tvos
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
nightly:
7+
description: 'Nightly workflow.'
8+
required: true
9+
type: boolean
10+
default: false
11+
12+
jobs:
13+
# This is default Chromium build config
14+
tvos-x64:
15+
uses: ./.github/workflows/main.yaml
16+
permissions:
17+
packages: write
18+
pull-requests: write
19+
with:
20+
platform: tvos
21+
nightly: ${{ github.event.inputs.nightly }}
22+
secrets:
23+
datadog_api_key: ${{ secrets.DD_API_KEY }}
24+
SCCACHE_GCS_KEY_MAC: ${{ secrets.SCCACHE_GCS_KEY_MAC }}

cobalt/build/gn.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
]
8080

8181

82-
def write_build_args(build_args_path, platform_args_path, build_type, use_rbe,
82+
def write_build_args(build_args_path, platform_args_path, build_type, use_rbe,
8383
use_coverage):
8484
""" Write args file, modifying settings for config"""
8585
gen_comment = '# Set by gn.py'
@@ -89,6 +89,7 @@ def write_build_args(build_args_path, platform_args_path, build_type, use_rbe,
8989
f.write(f'use_remoteexec = true {gen_comment}\n')
9090
f.write(
9191
f'rbe_cfg_dir = rebase_path("//cobalt/reclient_cfgs") {gen_comment}\n')
92+
# f.write('cc_wrapper = "sccache"')
9293
f.write(f'build_type = "{build_type}" {gen_comment}\n')
9394
for key, value in _BUILD_TYPES[build_type].items():
9495
f.write(f'{key} = {value} {gen_comment}\n')
@@ -162,6 +163,12 @@ def parse_args():
162163
default=False,
163164
action='store_true',
164165
help='Pass this flag to enable code coverage instrumentation.')
166+
# parser.add_argument(
167+
# '--cc_wrapper',
168+
# type=str,
169+
# default='',
170+
# action='store_true',
171+
# help='Compiler wrapper to use (e.g., sccache).')
165172

166173
# Consume --args to avoid passing to gn gen, overriding args.gn file.
167174
parser.add_argument('--args', help=argparse.SUPPRESS)
@@ -174,6 +181,9 @@ def parse_args():
174181
if not script_args.no_check:
175182
gen_args.append('--check')
176183

184+
# if script_args.cc_wrapper:
185+
# gen_args.append(script_args.cc_wrapper)
186+
177187
if script_args.args:
178188
print('WARNING: \'--args\' was ignored to avoid overriding args.gn file.')
179189

0 commit comments

Comments
 (0)