From cda6f89dbaaff797b7f95e4c6886f83c93d61b54 Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Sun, 6 Apr 2025 19:06:19 +0800 Subject: [PATCH] work on fixing github workflows --- .github/actions/install/action.yml | 8 ++++---- .github/workflows/build.yml | 8 ++++---- .github/workflows/e2e-test.yml | 4 ++-- .github/workflows/wpt.yml | 4 ++-- .github/workflows/zig-test.yml | 7 ++----- Makefile | 14 +++++++------- build.zig | 4 ++-- src/browser/html/window.zig | 2 +- src/runtime/js.zig | 2 +- src/testing.zig | 7 +++---- 10 files changed, 28 insertions(+), 32 deletions(-) diff --git a/.github/actions/install/action.yml b/.github/actions/install/action.yml index 2b5fa598..bfe8fa40 100644 --- a/.github/actions/install/action.yml +++ b/.github/actions/install/action.yml @@ -59,11 +59,11 @@ runs: - name: install v8 shell: bash run: | - mkdir -p vendor/zig-js-runtime/vendor/v8/${{inputs.arch}}-${{inputs.os}}/debug - ln -s ${{ inputs.cache-dir }}/v8/libc_v8.a vendor/zig-js-runtime/vendor/v8/${{inputs.arch}}-${{inputs.os}}/debug/libc_v8.a + mkdir -p v8/build/${{inputs.arch}}-${{inputs.os}}/debug/ninja/obj/zig/ + ln -s ${{ inputs.cache-dir }}/v8/libc_v8.a v8/build/${{inputs.arch}}-${{inputs.os}}/debug/ninja/obj/zig/libc_v8.a - mkdir -p vendor/zig-js-runtime/vendor/v8/${{inputs.arch}}-${{inputs.os}}/release - ln -s ${{ inputs.cache-dir }}/v8/libc_v8.a vendor/zig-js-runtime/vendor/v8/${{inputs.arch}}-${{inputs.os}}/release/libc_v8.a + mkdir -p v8/build/${{inputs.arch}}-${{inputs.os}}/release/ninja/obj/zig/ + ln -s ${{ inputs.cache-dir }}/v8/libc_v8.a v8/build/${{inputs.arch}}-${{inputs.os}}/release/ninja/obj/zig/libc_v8.a - name: libiconv shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9010b503..36493448 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,7 +31,7 @@ jobs: arch: ${{env.ARCH}} - name: zig build - run: zig build --release=safe -Doptimize=ReleaseSafe -Dengine=v8 -Dcpu=x86_64 -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) + run: zig build --release=safe -Doptimize=ReleaseSafe -Dcpu=x86_64 -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) - name: Rename binary run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }} @@ -63,7 +63,7 @@ jobs: arch: ${{env.ARCH}} - name: zig build - run: zig build --release=safe -Doptimize=ReleaseSafe -Dengine=v8 -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) + run: zig build --release=safe -Doptimize=ReleaseSafe -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) - name: Rename binary run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }} @@ -95,7 +95,7 @@ jobs: arch: ${{env.ARCH}} - name: zig build - run: zig build --release=safe -Doptimize=ReleaseSafe -Dengine=v8 -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) + run: zig build --release=safe -Doptimize=ReleaseSafe -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) - name: Rename binary run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }} @@ -127,7 +127,7 @@ jobs: arch: ${{env.ARCH}} - name: zig build - run: zig build --release=safe -Doptimize=ReleaseSafe -Dengine=v8 -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) + run: zig build --release=safe -Doptimize=ReleaseSafe -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) - name: Rename binary run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }} diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 53427e09..732c6fa6 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -47,7 +47,7 @@ jobs: - uses: ./.github/actions/install - name: zig build release - run: zig build -Doptimize=ReleaseSafe -Dengine=v8 + run: zig build -Doptimize=ReleaseSafe - name: upload artifact uses: actions/upload-artifact@v4 @@ -86,7 +86,7 @@ jobs: - name: run puppeteer run: | python3 -m http.server 1234 -d ./public & echo $! > PYTHON.pid - ./lightpanda serve & echo $! > LPD.pid + ./lightpanda serve --gc_hints & echo $! > LPD.pid RUNS=100 npm run bench-puppeteer-cdp > puppeteer.out || exit 1 cat /proc/`cat LPD.pid`/status |grep VmHWM|grep -oP '\d+' > LPD.VmHWM kill `cat LPD.pid` `cat PYTHON.pid` diff --git a/.github/workflows/wpt.yml b/.github/workflows/wpt.yml index a3416928..349c94c1 100644 --- a/.github/workflows/wpt.yml +++ b/.github/workflows/wpt.yml @@ -55,7 +55,7 @@ jobs: - uses: ./.github/actions/install - - run: zig build wpt -Dengine=v8 -- --safe --summary + - run: zig build wpt -- --safe --summary # For now WPT tests doesn't pass at all. # We accept then to continue the job on failure. @@ -80,7 +80,7 @@ jobs: - uses: ./.github/actions/install - name: json output - run: zig build wpt -Dengine=v8 -- --safe --json > wpt.json + run: zig build wpt -- --safe --json > wpt.json - name: write commit run: | diff --git a/.github/workflows/zig-test.yml b/.github/workflows/zig-test.yml index c462eb0c..bbe8afae 100644 --- a/.github/workflows/zig-test.yml +++ b/.github/workflows/zig-test.yml @@ -56,7 +56,7 @@ jobs: - uses: ./.github/actions/install - name: zig build debug - run: zig build -Dengine=v8 + run: zig build - name: upload artifact uses: actions/upload-artifact@v4 @@ -102,11 +102,8 @@ jobs: - uses: ./.github/actions/install - - name: zig build unittest - run: zig build unittest -freference-trace --summary all - - name: zig build test - run: zig build test -Dengine=v8 -- --json > bench.json + run: zig build test -- --json > bench.json - name: write commit run: | diff --git a/Makefile b/Makefile index 1c4b3636..c588f82e 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ ZIG := zig BC := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -# option test filter make unittest F="server" +# option test filter make test F="server" F= # OS and ARCH @@ -47,7 +47,7 @@ help: # $(ZIG) commands # ------------ -.PHONY: build build-dev run run-release shell test bench download-zig wpt unittest data +.PHONY: build build-dev run run-release shell test bench download-zig wpt data zig_version = $(shell grep 'recommended_zig_version = "' "vendor/zig-js-runtime/build.zig" | cut -d'"' -f2) @@ -62,13 +62,13 @@ download-zig: ## Build in release-safe mode build: @printf "\e[36mBuilding (release safe)...\e[0m\n" - $(ZIG) build -Doptimize=ReleaseSafe -Dengine=v8 -Dgit_commit=$$(git rev-parse --short HEAD) || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;) + $(ZIG) build -Doptimize=ReleaseSafe -Dgit_commit=$$(git rev-parse --short HEAD) || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;) @printf "\e[33mBuild OK\e[0m\n" ## Build in debug mode build-dev: @printf "\e[36mBuilding (debug)...\e[0m\n" - @$(ZIG) build -Dengine=v8 -Dgit_commit=$$(git rev-parse --short HEAD) || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;) + @$(ZIG) build -Dgit_commit=$$(git rev-parse --short HEAD) || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;) @printf "\e[33mBuild OK\e[0m\n" ## Run the server in debug mode @@ -79,16 +79,16 @@ run: build ## Run a JS shell in debug mode shell: @printf "\e[36mBuilding shell...\e[0m\n" - @$(ZIG) build shell -Dengine=v8 || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;) + @$(ZIG) build shell || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;) ## Run WPT tests wpt: @printf "\e[36mBuilding wpt...\e[0m\n" - @$(ZIG) build wpt -Dengine=v8 -- --safe $(filter-out $@,$(MAKECMDGOALS)) || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;) + @$(ZIG) build wpt -- --safe $(filter-out $@,$(MAKECMDGOALS)) || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;) wpt-summary: @printf "\e[36mBuilding wpt...\e[0m\n" - @$(ZIG) build wpt -Dengine=v8 -- --safe --summary $(filter-out $@,$(MAKECMDGOALS)) || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;) + @$(ZIG) build wpt -- --safe --summary $(filter-out $@,$(MAKECMDGOALS)) || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;) ## Test test: diff --git a/build.zig b/build.zig index d17b3138..160e3c3f 100644 --- a/build.zig +++ b/build.zig @@ -76,7 +76,7 @@ pub fn build(b: *std.Build) !void { { // get v8 // ------- - const v8 = b.dependency("v8", .{.target = target, .optimize = optimize}); + const v8 = b.dependency("v8", .{ .target = target, .optimize = optimize }); const get_v8 = b.addRunArtifact(v8.artifact("get-v8")); const get_step = b.step("get-v8", "Get v8"); get_step.dependOn(&get_v8.step); @@ -85,7 +85,7 @@ pub fn build(b: *std.Build) !void { { // build v8 // ------- - const v8 = b.dependency("v8", .{.target = target, .optimize = optimize}); + const v8 = b.dependency("v8", .{ .target = target, .optimize = optimize }); const build_v8 = b.addRunArtifact(v8.artifact("build-v8")); const build_step = b.step("build-v8", "Build v8"); build_step.dependOn(&build_v8.step); diff --git a/src/browser/html/window.zig b/src/browser/html/window.zig index ff662237..dfa2ded7 100644 --- a/src/browser/html/window.zig +++ b/src/browser/html/window.zig @@ -33,7 +33,6 @@ const storage = @import("../storage/storage.zig"); // https://html.spec.whatwg.org/multipage/nav-history-apis.html#window pub const Window = struct { pub const prototype = *EventTarget; - pub const global_type = true; // Extend libdom event target for pure zig struct. base: parser.EventTargetTBase = parser.EventTargetTBase{}, @@ -58,6 +57,7 @@ pub const Window = struct { }; } + pub fn replaceLocation(self: *Window, loc: Location) !void { self.location = loc; if (self.document) |doc| { diff --git a/src/runtime/js.zig b/src/runtime/js.zig index ca48019b..ec3eca9f 100644 --- a/src/runtime/js.zig +++ b/src/runtime/js.zig @@ -227,6 +227,7 @@ pub fn Env(comptime S: type, comptime types: anytype) type { // Hey, look! This is our first real usage of the TYPE_LOOKUP. // Just like we said above, given a type, we can get its // template index. + const proto_index = @field(TYPE_LOOKUP, proto_name); templates[i].inherit(templates[proto_index]); } @@ -366,7 +367,6 @@ pub fn Env(comptime S: type, comptime types: anytype) type { // FunctionTemplate of the isolate (in startExecutor) fn attachClass(self: *Self, comptime Struct: type, template: v8.FunctionTemplate) void { const template_proto = template.getPrototypeTemplate(); - inline for (@typeInfo(Struct).@"struct".decls) |declaration| { const name = declaration.name; if (comptime name[0] == '_') { diff --git a/src/testing.zig b/src/testing.zig index 6fe94110..395a1998 100644 --- a/src/testing.zig +++ b/src/testing.zig @@ -17,14 +17,15 @@ // along with this program. If not, see . const std = @import("std"); -const parser = @import("browser/netsurf.zig"); +const Allocator = std.mem.Allocator; + pub const allocator = std.testing.allocator; pub const expectError = std.testing.expectError; pub const expectString = std.testing.expectEqualStrings; pub const expectEqualSlices = std.testing.expectEqualSlices; const App = @import("app.zig").App; -const Allocator = std.mem.Allocator; +const parser = @import("browser/netsurf.zig"); // Merged std.testing.expectEqual and std.testing.expectString // can be useful when testing fields of an anytype an you don't know @@ -388,10 +389,8 @@ pub const JsRunner = struct { errdefer runner.env.deinit(); runner.url = try URL.parse("https://lightpanda.io/opensource-browser/", null); - errdefer runner.env.deinit(); runner.renderer = Renderer.init(arena); - runner.cookie_jar = storage.CookieJar.init(arena); runner.loop = try Loop.init(arena); errdefer runner.loop.deinit();