-
Notifications
You must be signed in to change notification settings - Fork 56
174 lines (158 loc) · 6.23 KB
/
Copy pathbindings.yml
File metadata and controls
174 lines (158 loc) · 6.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: Language Bindings
# Cross-language binding smoke: build the shared C ABI once, then run each
# language's benchmark runner against the 5-case subset
# (bindings/cases/smoke.json) and assert all present languages agree
# (identical captures + screenshot byte length). Language packages land in
# stacked PRs, so every job skips cleanly when its package directory is not
# present on the ref under test. The full 100-case suite runs in
# bindings-benchmark.yml, not here.
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
jobs:
build-capi:
name: Build shared C ABI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Build librustwright_capi (release)
run: cargo build -p rustwright-capi --release --locked
- name: Upload native library
uses: actions/upload-artifact@v4
with:
name: librustwright_capi-linux
path: target/release/librustwright_capi.so
if-no-files-found: error
bindings:
name: ${{ matrix.lang }} runner (subset)
needs: build-capi
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
lang: [rust, go, java, csharp, ruby, php]
env:
RW_MANIFEST: bindings/cases/smoke.json
RW_LIB: target/release/librustwright_capi.so
RW_OUT: results/${{ matrix.lang }}.json
steps:
- uses: actions/checkout@v7.0.1
- name: Detect binding package
id: has
run: |
dir="${{ matrix.lang }}"
[ "$dir" = rust ] && dir=rust-native
if [ -d "$dir" ]; then
echo "ok=true" >> "$GITHUB_OUTPUT"
else
echo "ok=false" >> "$GITHUB_OUTPUT"
echo "::notice::${dir}/ not present on this ref; skipping ${{ matrix.lang }}"
fi
- name: Download native library
if: steps.has.outputs.ok == 'true'
uses: actions/download-artifact@v4
with:
name: librustwright_capi-linux
path: target/release
# The Rust core auto-discovers Chromium; point it at a real Chrome.
- name: Install Chrome
if: steps.has.outputs.ok == 'true'
id: chrome
uses: browser-actions/setup-chrome@v1
with:
chrome-version: stable
- name: Point engine at Chrome
if: steps.has.outputs.ok == 'true'
run: |
for v in RUSTWRIGHT_CHROMIUM CHROME CHROMIUM; do
echo "$v=${{ steps.chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
done
- name: Prepare output dir
if: steps.has.outputs.ok == 'true'
run: mkdir -p results
- name: Set up Rust
if: steps.has.outputs.ok == 'true' && matrix.lang == 'rust'
uses: dtolnay/rust-toolchain@stable
- name: Run Rust runner
if: steps.has.outputs.ok == 'true' && matrix.lang == 'rust'
run: cargo run -p rustwright --bin runner --release --locked -- --manifest "$RW_MANIFEST" --lib "$RW_LIB" --out "$RW_OUT"
- name: Set up Go
if: steps.has.outputs.ok == 'true' && matrix.lang == 'go'
uses: actions/setup-go@v5
with: { go-version: '1.23' }
- name: Run Go runner
if: steps.has.outputs.ok == 'true' && matrix.lang == 'go'
working-directory: go
run: go run ./cmd/runner --manifest "../$RW_MANIFEST" --lib "../$RW_LIB" --out "../$RW_OUT"
- name: Set up JDK
if: steps.has.outputs.ok == 'true' && matrix.lang == 'java'
uses: actions/setup-java@v4
with: { distribution: temurin, java-version: '23' }
- name: Run Java runner
if: steps.has.outputs.ok == 'true' && matrix.lang == 'java'
working-directory: java
run: bash run.sh runner --manifest "../$RW_MANIFEST" --lib "../$RW_LIB" --out "../$RW_OUT"
- name: Set up .NET
if: steps.has.outputs.ok == 'true' && matrix.lang == 'csharp'
uses: actions/setup-dotnet@v6
with: { dotnet-version: '8.0.x' }
- name: Run C# runner
if: steps.has.outputs.ok == 'true' && matrix.lang == 'csharp'
run: dotnet run --project csharp/Runner -c Release -- --manifest "$RW_MANIFEST" --lib "$RW_LIB" --out "$RW_OUT"
- name: Set up Ruby
if: steps.has.outputs.ok == 'true' && matrix.lang == 'ruby'
uses: ruby/setup-ruby@v1
with: { ruby-version: '3.2' }
- name: Run Ruby runner
if: steps.has.outputs.ok == 'true' && matrix.lang == 'ruby'
run: ruby ruby/runner.rb --manifest "$RW_MANIFEST" --lib "$RW_LIB" --out "$RW_OUT"
- name: Set up PHP
if: steps.has.outputs.ok == 'true' && matrix.lang == 'php'
uses: shivammathur/setup-php@v2
with: { php-version: '8.3', extensions: ffi }
- name: Run PHP runner
if: steps.has.outputs.ok == 'true' && matrix.lang == 'php'
run: php -d ffi.enable=1 php/runner.php --manifest "$RW_MANIFEST" --lib "$RW_LIB" --out "$RW_OUT"
- name: Show + assert results
if: steps.has.outputs.ok == 'true'
run: |
cat "$RW_OUT"
python3 - "$RW_OUT" <<'PY'
import json, sys
d = json.load(open(sys.argv[1]))
bad = [r["id"] for r in d["results"] if not r["ok"]]
assert not bad, f"{d['lang']}: failing cases {bad}"
print(f"{d['lang']}: {len(d['results'])} cases OK")
PY
- name: Upload results
if: steps.has.outputs.ok == 'true'
uses: actions/upload-artifact@v4
with:
name: results-${{ matrix.lang }}
path: ${{ env.RW_OUT }}
if-no-files-found: error
equivalence:
name: Cross-language equivalence
needs: bindings
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
- name: Download all language results
uses: actions/download-artifact@v4
with:
pattern: results-*
path: results
merge-multiple: true
- name: Assert every language agrees (captures + screenshot bytes)
run: |
n=$(ls results/*.json 2>/dev/null | wc -l)
if [ "$n" -lt 2 ]; then
echo "::notice::only $n language result(s) on this ref; skipping equivalence"
exit 0
fi
python3 tools/compare_binding_results.py results