Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 167 additions & 0 deletions .github/workflows/benchx_cli_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
name: Benchx CLI Publish

on:
pull_request:
branches:
- develop
push:
tags:
- '*'
workflow_call:
inputs:
skip_release:
description: 'Skip the release job'
required: false
default: false
type: boolean
commit_ref:
description: 'Commit SHA or branch name to build'
required: false
type: string
workflow_dispatch:

permissions:
contents: write

jobs:
build:
name: Build ${{ matrix.os_name }} ${{ matrix.arch_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
os_name: Linux
arch_name: x86_64
- os: macos-latest
os_name: Darwin
arch_name: arm64

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.commit_ref || github.ref }}

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '24'

- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.8

- name: Setup uv
uses: astral-sh/setup-uv@v5

- name: Configure sccache
run: |
# Configure sccache directory before cache step
echo "SCCACHE_DIR=$GITHUB_WORKSPACE/.sccache" >> $GITHUB_ENV
mkdir -p .sccache

- name: Cache sccache
uses: actions/cache@v4
with:
path: .sccache
key: ${{ matrix.os }}-${{ matrix.arch_name }}-sccache-${{ github.sha }}
restore-keys: |
${{ matrix.os }}-${{ matrix.arch_name }}-sccache-

- name: Install Dependencies
run: |
# Show sccache stats before build
sccache -z

uv venv
uv pip install pip

# Ensure tools are executable
chmod +x tools/hab || true

# Source envsetup to set paths for hab and other tools
set +u
source tools/envsetup.sh

echo "Syncing dependencies..."
tools/hab sync .

- name: Build
run: |
set +u
source tools/envsetup.sh

echo "Generating build files for ${{ matrix.os_name }} ${{ matrix.arch_name }}..."

# Base args
ARGS='enable_unittests=true enable_trace="perfetto" jsengine_type="quickjs" enable_frozen_mode=true use_sccache=true'


# Platform specific args
if [[ "${{ matrix.os_name }}" == "Darwin" ]]; then
ARGS="$ARGS use_flutter_cxx=false"
fi

# Note: If cross-compilation is needed for arm64 on Linux, target_cpu arg would be needed
# But here we are running on native runners (macos-latest is arm64, others x64)

echo "GN Args: $ARGS"
gn gen --args="$ARGS" out/Default

echo "Building benchx_cli..."
ninja -C out/Default cli/benchx:benchx_cli

# Show sccache stats after build
sccache -s

- name: Prepare and Package Artifacts
run: |
mkdir -p dist/bin
BINARY_PATH="out/Default/benchx_cli"

if [ ! -f "$BINARY_PATH" ]; then
echo "Error: Binary not found at $BINARY_PATH"
ls -R out/Default
exit 1
fi

echo "Found binary at $BINARY_PATH"
cp "$BINARY_PATH" dist/bin/benchx_cli

# Create archive with specific naming format: benchx_cli_OS_Arch.tar.gz
# e.g., benchx_cli_Darwin_arm64.tar.gz
ARCHIVE_NAME="benchx_cli_${{ matrix.os_name }}_${{ matrix.arch_name }}.tar.gz"

cd dist/bin
tar -czvf "../../$ARCHIVE_NAME" benchx_cli
cd ../..

echo "Created archive: $ARCHIVE_NAME"

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: build-artifact-${{ matrix.os_name }}-${{ matrix.arch_name }}
path: benchx_cli_*.tar.gz

release:
name: Create Release
needs: build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !inputs.skip_release
runs-on: ubuntu-latest
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true # Merge all artifacts into one directory

- name: List Artifacts
run: |
ls -R artifacts

- name: Publish Release
uses: softprops/action-gh-release@v2
with:
files: artifacts/*
86 changes: 86 additions & 0 deletions .github/workflows/rebase_upstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Periodic Rebase

on:
schedule:
- cron: '0 0 * * *' # Daily at 00:00 UTC
workflow_dispatch:

permissions:
contents: write

jobs:
prepare-rebase:
runs-on: ubuntu-latest
outputs:
temp_branch: ${{ steps.create_branch.outputs.branch_name }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: develop
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Rebase Upstream and Push to Temp Branch
id: create_branch
run: |
UPSTREAM_URL="https://github.com/lynx-family/lynx.git"

echo "Setting upstream to $UPSTREAM_URL"
git remote add upstream "$UPSTREAM_URL"
git fetch upstream

echo "Rebasing develop..."
git checkout develop

if git rebase upstream/develop; then
echo "Rebase successful."
# Create a unique temporary branch name
TEMP_BRANCH="rebase-check-${{ github.run_id }}"
git checkout -b "$TEMP_BRANCH"
git push origin "$TEMP_BRANCH" --force

echo "branch_name=$TEMP_BRANCH" >> "$GITHUB_OUTPUT"
else
echo "Rebase failed due to conflicts. Aborting."
git rebase --abort
exit 1
fi

check-build:
needs: prepare-rebase
uses: ./.github/workflows/benchx_cli_publish.yml
with:
skip_release: true
commit_ref: ${{ needs.prepare-rebase.outputs.temp_branch }}

push-to-develop:
needs: [prepare-rebase, check-build]
runs-on: ubuntu-latest
if: success()
steps:
- name: Checkout Temp Branch
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare-rebase.outputs.temp_branch }}
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Push to Develop
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

echo "Pushing verified rebase to develop..."
git checkout develop
# Reset develop to the verified temp branch commit
git reset --hard origin/${{ needs.prepare-rebase.outputs.temp_branch }}
git push origin develop --force-with-lease

# Cleanup
git push origin --delete ${{ needs.prepare-rebase.outputs.temp_branch }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,8 @@ js_libraries/lynx-core/src/common/feature.ts
/tools/api/android
/tools/api/ios
/tools/api/docs/gen

compile_commands.json
.cache/

.codspeed_*/
2 changes: 1 addition & 1 deletion .habitat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
habitat_version = "0.3.146-alpha.2"
habitat_version = "0.3.146-alpha.4"
solutions = [
{
'name': '.',
Expand Down
5 changes: 5 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,8 @@ group("third_party_trace_group") {
deps += [ "base/trace/native:trace_tests" ]
}
}

group("cli") {
deps = ["cli/benchx:benchx_cli"]
testonly = true
}
34 changes: 34 additions & 0 deletions cli/benchx/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2020 The Lynx Authors. All rights reserved.
# Licensed under the Apache License Version 2.0 that can be found in the
# LICENSE file in the root directory of this source tree.

import("//core/Lynx.gni")
import("//testing/test.gni")

executable("benchx_cli") {
testonly = true
sources = [
"benchx_cli.cc",
"painting_context_platform_impl.cc",
"performance_apis.cc",
"resource_loader.cc",
"tasm_platform_invoker_dummy.cc",
]
deps = [
"//base/src:base_group",
"//base/trace/native:trace",
"//core/event",
"//core/renderer:tasm",
"//core/renderer/dom:dom",
"//core/renderer/dom:renderer_dom",
"//core/renderer/dom/selector:element_selector",
"//core/resource",
"//core/services/event_report",
"//core/shared_data",
"//core/shell",
"//js_libraries/lynx-core",
"//third_party/argparse",
"//third_party/codspeed-instrument-hooks",
"//third_party/rapidjson",
]
}
Loading