Skip to content

Commit 733589a

Browse files
delanLoirooriol
authored andcommitted
Servo initial downstream commit
Any ancestors of this commit are from upstream mozilla-central, with some filtering and renaming. Our patches and sync tooling start here. The sync tooling has all been squashed into this commit, based on: https://github.com/servo/stylo/commits/64731e10dc8ef87ef52aa2fb9f988c3b2530f3a7
1 parent ec21cec commit 733589a

File tree

11 files changed

+286
-0
lines changed

11 files changed

+286
-0
lines changed

.github/workflows/main.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
workflow_dispatch:
8+
merge_group:
9+
types: [checks_requested]
10+
11+
12+
jobs:
13+
linux-debug:
14+
name: Linux (Debug)
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Install Rust
19+
uses: dtolnay/rust-toolchain@stable
20+
- name: Run Tests
21+
run: cargo build --features servo
22+
env:
23+
RUST_BACKTRACE: 1
24+
25+
linux-release:
26+
name: Linux (Release)
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- name: Install Rust
31+
uses: dtolnay/rust-toolchain@stable
32+
- name: Run Tests
33+
run: cargo build --release --features servo
34+
env:
35+
RUST_BACKTRACE: 1
36+
37+
build-result:
38+
name: Result
39+
runs-on: ubuntu-latest
40+
if: ${{ always() }}
41+
needs:
42+
- linux-debug
43+
- linux-release
44+
steps:
45+
- name: Success
46+
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
47+
run: exit 0
48+
- name: Failure
49+
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
50+
run: exit 1
51+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: 🪞 Mirror `main`
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
mirror:
9+
name: Mirror
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
- name: Get branch name
16+
id: branch-name
17+
run: |
18+
first_commit=$(git log --pretty=\%H --grep='Servo initial downstream commit')
19+
upstream_base="$first_commit~"
20+
echo BRANCH_NAME=$(git log -n1 --pretty='%as' $upstream_base) >> $GITHUB_OUTPUT
21+
- uses: google/[email protected]
22+
name: Mirror to ${{ steps.branch-name.outputs.BRANCH_NAME }}
23+
with:
24+
github-token: ${{ secrets.GITHUB_TOKEN }}
25+
source: main
26+
dest: ${{ steps.branch-name.outputs.BRANCH_NAME }}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Sync upstream with mozilla-central
2+
3+
on:
4+
schedule:
5+
- cron: '0 13 * * *'
6+
workflow_dispatch:
7+
8+
jobs:
9+
sync:
10+
name: Sync
11+
runs-on: ubuntu-22.04
12+
steps:
13+
- uses: actions/checkout@v3
14+
with:
15+
fetch-depth: 1
16+
- uses: actions/cache@v3
17+
with:
18+
path: _cache/upstream
19+
key: upstream
20+
- run: |
21+
./sync.sh _filtered
22+
git fetch -f --progress ./_filtered master:upstream
23+
git push -fu --progress origin upstream

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/_cache/
2+
/_filtered/
3+
/target/
4+
/style/properties/__pycache__/
5+
Cargo.lock

README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
Stylo
2+
=====
3+
4+
This repo contains Servo’s downstream fork of [Stylo](https://searchfox.org/mozilla-central/source/servo).
5+
6+
The branches are as follows:
7+
8+
- [`upstream`](https://github.com/servo/style/tree/upstream) has upstream mozilla-central filtered to the paths we care about ([style.paths](style.paths)), but is otherwise unmodified
9+
- [`main`](https://github.com/servo/style/tree/ci) has our downstream patches, plus the scripts and workflows for syncing with mozilla-central, to be rebased onto `upstream`
10+
11+
## Building Servo against your local Stylo
12+
13+
Assuming your local `servo` and `stylo` directories are siblings, you can build `servo` against `stylo` by adding the following to `servo/Cargo.toml`:
14+
15+
```toml
16+
[patch."https://github.com/servo/stylo"]
17+
selectors = { path = "../stylo/selectors" }
18+
servo_arc = { path = "../stylo/servo_arc" }
19+
stylo_atoms = { path = "../stylo/stylo_atoms" }
20+
style = { path = "../stylo/style" }
21+
stylo_config = { path = "../stylo/stylo_config" }
22+
stylo_dom = { path = "../stylo/stylo_dom" }
23+
style_malloc_size_of = { path = "../stylo/malloc_size_of", package = "malloc_size_of" }
24+
style_traits = { path = "../stylo/style_traits" }
25+
```
26+
27+
## Syncing `upstream` with mozilla-central
28+
29+
Start by generating a filtered copy of mozilla-central. This will cache the raw mozilla-central in `_cache/upstream`, storing the result in `_filtered`:
30+
31+
```sh
32+
$ ./sync.sh _filtered
33+
```
34+
35+
If `_filtered` already exists, you will need to delete it and try again:
36+
37+
```sh
38+
$ rm -Rf _filtered
39+
```
40+
41+
Now overwrite our `upstream` with those commits and push:
42+
43+
```sh
44+
$ git fetch -f --progress ./_filtered master:upstream
45+
$ git push -fu --progress origin upstream
46+
```
47+
48+
## Rebasing `main` onto `upstream`
49+
50+
Start by fetching `upstream` into your local repo:
51+
52+
```sh
53+
$ git fetch -f origin upstream:upstream
54+
```
55+
56+
In general, the filtering process is deterministic, yielding the same commit hashes each time, so we can rebase normally:
57+
58+
```sh
59+
$ git rebase upstream
60+
```
61+
62+
But if the filtering config changes or Mozilla moves to GitHub, the commit hashes on `upstream` may change. In this case, we need to tell git where the old upstream ends and our own commits start (notice the `~`):
63+
64+
```sh
65+
$ git log --pretty=\%H --grep='Servo initial downstream commit'
66+
e62d7f0090941496e392e1dc91df103a38e3f488
67+
68+
$ git rebase --onto upstream e62d7f0090941496e392e1dc91df103a38e3f488~
69+
Successfully rebased and updated refs/heads/main.
70+
```
71+
72+
`start-rebase.sh` takes care of this automatically, but you should still use `git rebase` for subsequent steps like `--continue` and `--abort`:
73+
74+
```sh
75+
$ ./start-rebase.sh upstream
76+
$ ./start-rebase.sh upstream -i # interactive
77+
$ git rebase --continue # not ./start-rebase.sh --continue
78+
$ git rebase --abort # not ./start-rebase.sh --abort
79+
```
80+
81+
Or if we aren’t ready to rebase onto the tip of upstream:
82+
83+
```sh
84+
$ ./start-rebase.sh upstream~10 -i
85+
```

commit-from-merge.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
# Usage: commit-from-merge.sh <path/to/servo/servo> <merge commit> [extra git-commit(1) arguments ...]
3+
# Given a merge commit made by bors, runs git-commit(1) with your local changes
4+
# while borrowing the author name/email from the right-hand parent of the merge,
5+
# and the author date from the committer date of the merge.
6+
set -eu
7+
8+
lookup_repo=$1; shift
9+
merge_commit=$1; shift
10+
author_name_email=$(git -C "$lookup_repo" log -n1 --pretty='%aN <%aE>' "$merge_commit"\^2)
11+
committer_date=$(git -C "$lookup_repo" log -n1 --pretty='%cd' "$merge_commit")
12+
13+
set -- git commit --author="$author_name_email" --date="$committer_date" "$@"
14+
echo "$@"
15+
"$@"

commit-from-squashed.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
# Usage: commit-from-squashed.sh <squashed commit> [extra git-commit(1) arguments ...]
3+
# Given a squashed commit made by the GitHub merge queue, runs git-commit(1) with your local changes
4+
# while borrowing our author name/email from that commit, our author date from its committer date,
5+
# and our commit message from that commit.
6+
set -eu
7+
8+
squashed_commit=$1; shift
9+
committer_date=$(git log -n1 --pretty='%cd' "$squashed_commit")
10+
11+
# -c is equivalent to --author=$(...'%aN <%aE>') -m $(...'%B'), but allows editing
12+
set -- git commit -c "$squashed_commit" --date="$committer_date" "$@"
13+
echo "$@"
14+
"$@"

shell.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
with import (builtins.fetchTarball {
2+
url = "https://github.com/NixOS/nixpkgs/archive/46ae0210ce163b3cba6c7da08840c1d63de9c701.tar.gz";
3+
}) {};
4+
stdenv.mkDerivation rec {
5+
name = "style-sync-shell";
6+
}

start-rebase.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
# Usage: start-rebase.sh <new base> [extra git-rebase(1) arguments ...]
3+
# Equivalent to git rebase --onto <new base> <last old upstream commit>.
4+
set -eu
5+
6+
new_base=$1; shift
7+
first_commit=$(git log --pretty=\%H --grep='Servo initial downstream commit')
8+
old_base=$first_commit~
9+
10+
git rebase --onto "$new_base" "$old_base" "$@"

style.paths

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Filters and renames use git-filter-repo(1) --paths-from-file:
2+
# https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html#_filtering_based_on_many_paths
3+
4+
servo/components/
5+
servo/rustfmt.toml
6+
7+
regex:servo/components/(.+)==>\1
8+
servo/rustfmt.toml==>rustfmt.toml

0 commit comments

Comments
 (0)