Skip to content

Commit

Permalink
Initial GitHub Actions (Android and Linux)
Browse files Browse the repository at this point in the history
b/355035766
  • Loading branch information
isarkis authored and dahlstrom-g committed Sep 24, 2024
1 parent 589c9bb commit dcaf48a
Show file tree
Hide file tree
Showing 21 changed files with 1,037 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/actions/build/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build Cobalt
description: Builds Cobalt targets
inputs:
targets:
description: "List of ninja targets for Chrobalt build."
required: true
runs:
using: "composite"
steps:
- name: Get depot tools
run: git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
shell: bash
- name: Add directory to PATH
run: echo "$GITHUB_WORKSPACE/depot_tools" >> $GITHUB_PATH
shell: bash
- name: Generate gclient file
run: gclient config --name=src https://github.com/${{ github.repository }}
shell: bash
- name: Set target OS for Android
if: startsWith(${{matrix.platform}}, 'android')
run: |
echo "target_os=['android']" >> .gclient
gclient validate
shell: bash
- name: Gclient sync
run: gclient sync -v --shallow --no-history -r ${{ github.sha }}
shell: bash
- name: sccache check
run: sccache -s
shell: bash
- name: gn gen
run: |
cd src
chrobalt/build/gn.py -p ${{ matrix.platform }} -C ${{ matrix.config }} --no-check
shell: bash
- name: gn dump args
run: |
cd src
gn args --list --short --overrides-only out/${{ matrix.platform }}_${{ matrix.config }}
shell: bash
- name: ninja build
env:
TARGETS: ${{ inputs.targets }}
run: |
set -x
cd src
ninja -C out/${{ matrix.platform }}_${{ matrix.config }} $(echo "${TARGETS}" | tr -d '"')
shell: bash
- name: sccache check
run: sccache -s
shell: bash
- name: find apks
run: find src/out -name \*.apk -print
shell: bash
- name: Archive Android APKs
if: startsWith(${{matrix.platform}}, 'android')
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }} APKs
path: |
src/out/${{ matrix.platform }}_qa/apks/*.apk
src/out/${{ matrix.platform }}_qa/*_apk/*.apk
71 changes: 71 additions & 0 deletions .github/actions/docker/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Docker Image Build
description: Builds Cobalt build docker images.
inputs:
docker_service:
description: "Docker compose service."
required: true

runs:
using: "composite"
steps:
- name: Checkout files
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
- name: Set env vars
run: |
set -x
tag=${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref_name }}
tag=${tag//\//__}
tag="${tag%.1[+,-]}"
echo "FLOATING_TAG=${tag}" >> $GITHUB_ENV
full_git_sha=${{ github.sha }}
short_git_sha="${full_git_sha::7}"
echo "GIT_SHA=${short_git_sha}" >> $GITHUB_ENV
shell: bash
- name: Set Docker Tag
id: set-docker-tag-github
if: ${{ (github.event_name != 'pull_request') || (github.event.pull_request.head.repo.full_name == github.repository) }}
run: |
set -x
echo "DOCKER_TAG=ghcr.io/${{ github.repository }}/${{ inputs.docker_service }}:${GIT_SHA}" >> $GITHUB_ENV
echo "DOCKER_FLOATING_TAG=ghcr.io/${{ github.repository }}/${{ inputs.docker_service }}:${FLOATING_TAG}" >> $GITHUB_ENV
shell: bash
# Handle Google Artifact Registry used for pull requests off forked repos.
- name: Set up Cloud SDK
if: ${{ (github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name != github.repository) }}
uses: isarkis/setup-gcloud@40dce7857b354839efac498d3632050f568090b6 # v1.1.1
- name: Login to GAR and set tag
if: ${{ (github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name != github.repository) }}
run: |
# Need to login to GAR to be able to push images created by fork based PR workflows.
PROJECT_NAME=$(gcloud config get-value project)
METADATA="http://metadata.google.internal./computeMetadata/v1"
SVC_ACCT="${METADATA}/instance/service-accounts/default"
ACCESS_TOKEN=$(curl -H 'Metadata-Flavor: Google' ${SVC_ACCT}/token | cut -d'"' -f 4)
printf ${ACCESS_TOKEN} | docker login -u oauth2accesstoken --password-stdin https://us-central1-docker.pkg.dev
full_git_sha=${{ github.sha }}
echo "DOCKER_TAG=us-central1-docker.pkg.dev/${PROJECT_NAME}/github/${{ inputs.docker_service }}:${GIT_SHA}" >> $GITHUB_ENV
echo "DOCKER_FLOATING_TAG=us-central1-docker.pkg.dev/${PROJECT_NAME}/github/${{ inputs.docker_service }}:${FLOATING_TAG}" >> $GITHUB_ENV
shell: bash
# Proceed with docker pull, build, tag, and push.
- name: Docker Pull
run: |
docker pull "${DOCKER_TAG}" || true
docker pull "${DOCKER_FLOATING_TAG}" || true
shell: bash
- name: Docker Build
run: docker compose build ${{inputs.docker_service}}
shell: bash
- name: Docker Tag
run: |
docker tag ghcr.io/${{ github.repository }}/${{ inputs.docker_service }}:latest ${DOCKER_TAG}
docker tag ghcr.io/${{ github.repository }}/${{ inputs.docker_service }}:latest ${DOCKER_FLOATING_TAG}
shell: bash
- name: Docker Push
run: |
docker push ${DOCKER_TAG}
docker push ${DOCKER_FLOATING_TAG}
shell: bash
19 changes: 19 additions & 0 deletions .github/actions/pre_commit/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: pre-commit
description: Runs pre-commit
inputs:
base_ref:
description: "Ref to run from"
required: true
runs:
using: "composite"
steps:
- run: python -m pip install pre-commit
shell: bash
- run: python -m pip freeze --local
shell: bash
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- run: pre-commit run --show-diff-on-failure --color=always --all-files
shell: bash
27 changes: 27 additions & 0 deletions .github/config/android-arm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

{
"docker_service": "linux",
"platforms": [
"android-arm"
],
"targets": [
"base_unittests",
"sql_unittests",
"net_unittests",
"url_unittests",
"ipc_tests",
"mojo_unittests",
"gpu_unittests",
"gin_unittests",
"blink_unittests",
"content_shell",
"system_webview_apk",
"system_webview_shell_apk"
],
"includes": [
{
"name":"arm",
"platform":"android-arm"
}
]
}
26 changes: 26 additions & 0 deletions .github/config/android-arm64.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"docker_service": "linux",
"platforms": [
"android-arm64"
],
"targets": [
"base_unittests",
"sql_unittests",
"net_unittests",
"url_unittests",
"ipc_tests",
"mojo_unittests",
"gpu_unittests",
"gin_unittests",
"blink_unittests",
"content_shell",
"system_webview_apk",
"system_webview_shell_apk"
],
"includes": [
{
"name":"arm64",
"platform":"android-arm64"
}
]
}
26 changes: 26 additions & 0 deletions .github/config/android-x86.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"docker_service": "linux",
"platforms": [
"android-x86"
],
"targets": [
"base_unittests",
"sql_unittests",
"net_unittests",
"url_unittests",
"ipc_tests",
"mojo_unittests",
"gpu_unittests",
"gin_unittests",
"blink_unittests",
"content_shell",
"system_webview_apk",
"system_webview_shell_apk"
],
"includes": [
{
"name":"x86",
"platform":"android-x86"
}
]
}
24 changes: 24 additions & 0 deletions .github/config/linux.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"docker_service": "linux",
"platforms": [
"linux-x64x11"
],
"targets": [
"base_unittests",
"sql_unittests",
"net_unittests",
"url_unittests",
"ipc_tests",
"mojo_unittests",
"gpu_unittests",
"gin_unittests",
"blink_unittests",
"content_shell"
],
"includes": [
{
"name":"x64",
"platform":"linux-x64x11"
}
]
}
45 changes: 45 additions & 0 deletions .github/workflows/android.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: android

on:
pull_request:
types: [opened, reopened, synchronize, labeled]
branches:
- main
- experimental/*
push:
branches:
- main
- experimental/*
workflow_dispatch:
inputs:
nightly:
description: 'Nightly workflow.'
required: true
type: boolean
default: false

jobs:
android-arm64:
uses: ./.github/workflows/main.yaml
permissions:
packages: write
pull-requests: write
with:
platform: android-arm64
nightly: ${{ github.event.inputs.nightly }}
android-arm:
uses: ./.github/workflows/main.yaml
permissions:
packages: write
pull-requests: write
with:
platform: android-arm
nightly: ${{ github.event.inputs.nightly }}
android-x86:
uses: ./.github/workflows/main.yaml
permissions:
packages: write
pull-requests: write
with:
platform: android-x86
nightly: ${{ github.event.inputs.nightly }}
29 changes: 29 additions & 0 deletions .github/workflows/linux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: linux

on:
pull_request:
types: [opened, reopened, synchronize, labeled]
branches:
- main
- experimental/*
push:
branches:
- main
- experimental/*
workflow_dispatch:
inputs:
nightly:
description: 'Nightly workflow.'
required: true
type: boolean
default: false

jobs:
linux-x64:
uses: ./.github/workflows/main.yaml
permissions:
packages: write
pull-requests: write
with:
platform: linux
nightly: ${{ github.event.inputs.nightly }}
Loading

0 comments on commit dcaf48a

Please sign in to comment.