From ad58e536ed4ef6d3c6e401ffc789ef4308621c5a Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Tue, 14 Nov 2023 11:23:16 +0100 Subject: [PATCH 1/8] makefile: remove useless var --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 49162725..d98524be 100644 --- a/Makefile +++ b/Makefile @@ -71,7 +71,6 @@ install: install-submodule install-lexbor install-jsruntime install-netsurf install-dev: install-submodule install-lexbor install-jsruntime-dev install-netsurf BC_NS := $(BC)vendor/netsurf -UNAME_S := $(shell uname -s) ICONV := $(BC)vendor/libiconv # TODO: add Linux iconv path (I guess it depends on the distro) # TODO: this way of linking libiconv is not ideal. We should have a more generic way From c5170db0f6fae12ef14887ce108a07df3c23af60 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Mon, 13 Nov 2023 18:25:47 +0100 Subject: [PATCH 2/8] ci: add CI workflows for tests --- .github/workflows/wpt.yml | 48 ++++++++++++++++++++++++++++++++++ .github/workflows/zig-fmt.yml | 47 +++++++++++++++++++++++++++++++++ .github/workflows/zig-test.yml | 47 +++++++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 .github/workflows/wpt.yml create mode 100644 .github/workflows/zig-fmt.yml create mode 100644 .github/workflows/zig-test.yml diff --git a/.github/workflows/wpt.yml b/.github/workflows/wpt.yml new file mode 100644 index 00000000..1e11e46a --- /dev/null +++ b/.github/workflows/wpt.yml @@ -0,0 +1,48 @@ +name: wpt + +env: + ARCH: x86_64-linux + +on: + push: + branches: + - main + paths: + - "src/**/*.zig" + - "src/*.zig" + pull_request: + branches: + - main + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + wpt: + name: web platform tests + + runs-on: ubuntu-latest + container: + image: ghcr.io/browsercore/zig-v8:0.11.0 + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.GH_CI_PAT }} + submodules: true + + - name: install v8 + run: | + mkdir -p vendor/v8/${{env.ARCH}}/debug + ln -s /usr/local/lib/libc_v8.a vendor/v8/${{env.ARCH}}/debug/libc_v8.a + + mkdir -p vendor/v8/${{env.ARCH}}/release + ln -s /usr/local/lib/libc_v8.a vendor/v8/${{env.ARCH}}/release/libc_v8.a + + - run: make install-lexbor + - run: make install-netsurf + + - run: zig build wpt -Dengine=v8 diff --git a/.github/workflows/zig-fmt.yml b/.github/workflows/zig-fmt.yml new file mode 100644 index 00000000..385ba8d1 --- /dev/null +++ b/.github/workflows/zig-fmt.yml @@ -0,0 +1,47 @@ +name: zig-fmt + +on: + pull_request: + branches: + - main + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + zig-fmt: + name: zig fmt + runs-on: ubuntu-latest + container: + image: ghcr.io/browsercore/zig:0.11.0 + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + outputs: + zig_fmt_errs: ${{ steps.fmt.outputs.zig_fmt_errs }} + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Run zig fmt + id: fmt + run: | + zig fmt --check ./*.zig ./**/*.zig 2> zig-fmt.err > zig-fmt.err2 || echo "Failed" + delimiter="$(openssl rand -hex 8)" + echo "zig_fmt_errs<<${delimiter}" >> "${GITHUB_OUTPUT}" + + if [ -s zig-fmt.err ]; then + echo "// The following errors occurred:" >> "${GITHUB_OUTPUT}" + cat zig-fmt.err >> "${GITHUB_OUTPUT}" + fi + + if [ -s zig-fmt.err2 ]; then + echo "// The following files were not formatted:" >> "${GITHUB_OUTPUT}" + cat zig-fmt.err2 >> "${GITHUB_OUTPUT}" + fi + + echo "${delimiter}" >> "${GITHUB_OUTPUT}" + - name: Fail the job + if: steps.fmt.outputs.zig_fmt_errs != '' + run: exit 1 diff --git a/.github/workflows/zig-test.yml b/.github/workflows/zig-test.yml new file mode 100644 index 00000000..01972d41 --- /dev/null +++ b/.github/workflows/zig-test.yml @@ -0,0 +1,47 @@ +name: zig-test + +env: + ARCH: x86_64-linux + +on: + push: + branches: + - main + paths: + - "src/**/*.zig" + - "src/*.zig" + pull_request: + branches: + - main + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + zig-test: + name: zig test + runs-on: ubuntu-latest + container: + image: ghcr.io/browsercore/zig-v8:0.11.0 + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.GH_CI_PAT }} + submodules: true + + - name: install v8 + run: | + mkdir -p vendor/v8/${{env.ARCH}}/debug + ln -s /usr/local/lib/libc_v8.a vendor/v8/${{env.ARCH}}/debug/libc_v8.a + + mkdir -p vendor/v8/${{env.ARCH}}/release + ln -s /usr/local/lib/libc_v8.a vendor/v8/${{env.ARCH}}/release/libc_v8.a + + - run: make install-lexbor + - run: make install-netsurf + + - run: zig build test -Dengine=v8 From d6996889c2c77c44e69c14d71d4c3bcbca01c848 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Tue, 14 Nov 2023 08:51:51 +0100 Subject: [PATCH 3/8] ci: fetch git submodules recursively --- .github/workflows/wpt.yml | 3 ++- .github/workflows/zig-test.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wpt.yml b/.github/workflows/wpt.yml index 1e11e46a..a5b8ee69 100644 --- a/.github/workflows/wpt.yml +++ b/.github/workflows/wpt.yml @@ -32,7 +32,8 @@ jobs: with: fetch-depth: 0 token: ${{ secrets.GH_CI_PAT }} - submodules: true + # fetch submodules recusively, to get jsruntime-lib submodules also. + submodules: recursive - name: install v8 run: | diff --git a/.github/workflows/zig-test.yml b/.github/workflows/zig-test.yml index 01972d41..4b33e4cd 100644 --- a/.github/workflows/zig-test.yml +++ b/.github/workflows/zig-test.yml @@ -31,7 +31,8 @@ jobs: with: fetch-depth: 0 token: ${{ secrets.GH_CI_PAT }} - submodules: true + # fetch submodules recusively, to get jsruntime-lib submodules also. + submodules: recursive - name: install v8 run: | From 2afbd0752c606ec6189281d0dd7b025bbaf14f93 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Tue, 14 Nov 2023 11:27:41 +0100 Subject: [PATCH 4/8] ci: use browsercore-zig docker image --- .github/workflows/wpt.yml | 21 ++++++++++++++------- .github/workflows/zig-test.yml | 21 ++++++++++++++------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/.github/workflows/wpt.yml b/.github/workflows/wpt.yml index a5b8ee69..a20131f8 100644 --- a/.github/workflows/wpt.yml +++ b/.github/workflows/wpt.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest container: - image: ghcr.io/browsercore/zig-v8:0.11.0 + image: ghcr.io/browsercore/zig-browsercore:0.11.0 credentials: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} @@ -37,13 +37,20 @@ jobs: - name: install v8 run: | - mkdir -p vendor/v8/${{env.ARCH}}/debug - ln -s /usr/local/lib/libc_v8.a vendor/v8/${{env.ARCH}}/debug/libc_v8.a + mkdir -p vendor/jsruntime-lib/vendor/v8/${{env.ARCH}}/debug + ln -s /usr/local/lib/libc_v8.a vendor/jsruntime-lib/vendor/v8/${{env.ARCH}}/debug/libc_v8.a - mkdir -p vendor/v8/${{env.ARCH}}/release - ln -s /usr/local/lib/libc_v8.a vendor/v8/${{env.ARCH}}/release/libc_v8.a + mkdir -p vendor/jsruntime-lib/vendor/v8/${{env.ARCH}}/release + ln -s /usr/local/lib/libc_v8.a vendor/jsruntime-lib/vendor/v8/${{env.ARCH}}/release/libc_v8.a - - run: make install-lexbor - - run: make install-netsurf + - name: install deps + run: | + ln -s /usr/local/lib/lexbor vendor/lexbor + + ln -s /usr/local/lib/libiconv vendor/libiconv + + ln -s /usr/local/lib/netsurf/build vendor/netsurf/build + ln -s /usr/local/lib/netsurf/lib vendor/netsurf/lib + ln -s /usr/local/lib/netsurf/include vendor/netsurf/include - run: zig build wpt -Dengine=v8 diff --git a/.github/workflows/zig-test.yml b/.github/workflows/zig-test.yml index 4b33e4cd..dab219da 100644 --- a/.github/workflows/zig-test.yml +++ b/.github/workflows/zig-test.yml @@ -21,7 +21,7 @@ jobs: name: zig test runs-on: ubuntu-latest container: - image: ghcr.io/browsercore/zig-v8:0.11.0 + image: ghcr.io/browsercore/zig-browsercore:0.11.0 credentials: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} @@ -36,13 +36,20 @@ jobs: - name: install v8 run: | - mkdir -p vendor/v8/${{env.ARCH}}/debug - ln -s /usr/local/lib/libc_v8.a vendor/v8/${{env.ARCH}}/debug/libc_v8.a + mkdir -p vendor/jsruntime-lib/vendor/v8/${{env.ARCH}}/debug + ln -s /usr/local/lib/libc_v8.a vendor/jsruntime-lib/vendor/v8/${{env.ARCH}}/debug/libc_v8.a - mkdir -p vendor/v8/${{env.ARCH}}/release - ln -s /usr/local/lib/libc_v8.a vendor/v8/${{env.ARCH}}/release/libc_v8.a + mkdir -p vendor/jsruntime-lib/vendor/v8/${{env.ARCH}}/release + ln -s /usr/local/lib/libc_v8.a vendor/jsruntime-lib/vendor/v8/${{env.ARCH}}/release/libc_v8.a - - run: make install-lexbor - - run: make install-netsurf + - name: install deps + run: | + ln -s /usr/local/lib/lexbor vendor/lexbor + + ln -s /usr/local/lib/libiconv vendor/libiconv + + ln -s /usr/local/lib/netsurf/build vendor/netsurf/build + ln -s /usr/local/lib/netsurf/lib vendor/netsurf/lib + ln -s /usr/local/lib/netsurf/include vendor/netsurf/include - run: zig build test -Dengine=v8 From 9155024fa58c3bd93f14f56e0a67c69755050bdc Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Wed, 15 Nov 2023 09:02:21 +0100 Subject: [PATCH 5/8] ci: add zig build release --- .github/workflows/zig-test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/zig-test.yml b/.github/workflows/zig-test.yml index dab219da..d9bab4c5 100644 --- a/.github/workflows/zig-test.yml +++ b/.github/workflows/zig-test.yml @@ -52,4 +52,8 @@ jobs: ln -s /usr/local/lib/netsurf/lib vendor/netsurf/lib ln -s /usr/local/lib/netsurf/include vendor/netsurf/include - - run: zig build test -Dengine=v8 + - name: zig build release + run: zig build -Doptimize=ReleaseSafe -Dengine=v8 + + - name: zig build test + run: zig build test -Dengine=v8 From a671f6fd8acd27c231da35c75a844471de5d2322 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Wed, 15 Nov 2023 09:05:06 +0100 Subject: [PATCH 6/8] ci: allow WPT to fail --- .github/workflows/wpt.yml | 6 +++++- .github/workflows/zig-test.yml | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/wpt.yml b/.github/workflows/wpt.yml index a20131f8..2d449404 100644 --- a/.github/workflows/wpt.yml +++ b/.github/workflows/wpt.yml @@ -19,7 +19,6 @@ on: jobs: wpt: name: web platform tests - runs-on: ubuntu-latest container: image: ghcr.io/browsercore/zig-browsercore:0.11.0 @@ -54,3 +53,8 @@ jobs: ln -s /usr/local/lib/netsurf/include vendor/netsurf/include - run: zig build wpt -Dengine=v8 + + # For now WPT tests doesn't pass at all. + # We accept then to continue the job on failure. + # TODO remove the continue-on-error when tests will pass. + continue-on-error: true diff --git a/.github/workflows/zig-test.yml b/.github/workflows/zig-test.yml index d9bab4c5..3e5a6d08 100644 --- a/.github/workflows/zig-test.yml +++ b/.github/workflows/zig-test.yml @@ -52,8 +52,11 @@ jobs: ln -s /usr/local/lib/netsurf/lib vendor/netsurf/lib ln -s /usr/local/lib/netsurf/include vendor/netsurf/include - - name: zig build release - run: zig build -Doptimize=ReleaseSafe -Dengine=v8 + - name: zig build debug + run: zig build -Dengine=v8 - name: zig build test run: zig build test -Dengine=v8 + + - name: zig build release + run: zig build -Doptimize=ReleaseSafe -Dengine=v8 From d06d09ddda4594accb21c362ea963611a72e3fbc Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Wed, 15 Nov 2023 11:58:09 +0100 Subject: [PATCH 7/8] ci: add path contraints for pull requests --- .github/workflows/wpt.yml | 5 +++++ .github/workflows/zig-fmt.yml | 3 +++ .github/workflows/zig-test.yml | 3 +++ 3 files changed, 11 insertions(+) diff --git a/.github/workflows/wpt.yml b/.github/workflows/wpt.yml index 2d449404..2963cadf 100644 --- a/.github/workflows/wpt.yml +++ b/.github/workflows/wpt.yml @@ -10,9 +10,14 @@ on: paths: - "src/**/*.zig" - "src/*.zig" + - "test/wpt/**" pull_request: branches: - main + paths: + - "src/**/*.zig" + - "src/*.zig" + - "test/wpt/**" # Allows you to run this workflow manually from the Actions tab workflow_dispatch: diff --git a/.github/workflows/zig-fmt.yml b/.github/workflows/zig-fmt.yml index 385ba8d1..47261e60 100644 --- a/.github/workflows/zig-fmt.yml +++ b/.github/workflows/zig-fmt.yml @@ -4,6 +4,9 @@ on: pull_request: branches: - main + paths: + - "src/**/*.zig" + - "src/*.zig" # Allows you to run this workflow manually from the Actions tab workflow_dispatch: diff --git a/.github/workflows/zig-test.yml b/.github/workflows/zig-test.yml index 3e5a6d08..594be296 100644 --- a/.github/workflows/zig-test.yml +++ b/.github/workflows/zig-test.yml @@ -13,6 +13,9 @@ on: pull_request: branches: - main + paths: + - "src/**/*.zig" + - "src/*.zig" # Allows you to run this workflow manually from the Actions tab workflow_dispatch: From 9469f157ca1b8ef1bce691f080fa0c5d143f4759 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Wed, 15 Nov 2023 13:53:54 +0100 Subject: [PATCH 8/8] ci: don't run CI for draft PRs --- .github/workflows/wpt.yml | 12 ++++++++++++ .github/workflows/zig-fmt.yml | 12 ++++++++++++ .github/workflows/zig-test.yml | 12 ++++++++++++ 3 files changed, 36 insertions(+) diff --git a/.github/workflows/wpt.yml b/.github/workflows/wpt.yml index 2963cadf..3222477c 100644 --- a/.github/workflows/wpt.yml +++ b/.github/workflows/wpt.yml @@ -12,6 +12,14 @@ on: - "src/*.zig" - "test/wpt/**" pull_request: + + # By default GH trigger on types opened, synchronize and reopened. + # see https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request + # Since we skip the job when the PR is in draft state, we want to force CI + # running when the PR is marked ready_for_review w/o other change. + # see https://github.com/orgs/community/discussions/25722#discussioncomment-3248917 + types: [opened, synchronize, reopened, ready_for_review] + branches: - main paths: @@ -24,6 +32,10 @@ on: jobs: wpt: name: web platform tests + + # Don't run the CI with draft PR. + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest container: image: ghcr.io/browsercore/zig-browsercore:0.11.0 diff --git a/.github/workflows/zig-fmt.yml b/.github/workflows/zig-fmt.yml index 47261e60..189e7c51 100644 --- a/.github/workflows/zig-fmt.yml +++ b/.github/workflows/zig-fmt.yml @@ -2,6 +2,14 @@ name: zig-fmt on: pull_request: + + # By default GH trigger on types opened, synchronize and reopened. + # see https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request + # Since we skip the job when the PR is in draft state, we want to force CI + # running when the PR is marked ready_for_review w/o other change. + # see https://github.com/orgs/community/discussions/25722#discussioncomment-3248917 + types: [opened, synchronize, reopened, ready_for_review] + branches: - main paths: @@ -13,6 +21,10 @@ on: jobs: zig-fmt: name: zig fmt + + # Don't run the CI with draft PR. + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest container: image: ghcr.io/browsercore/zig:0.11.0 diff --git a/.github/workflows/zig-test.yml b/.github/workflows/zig-test.yml index 594be296..87644c36 100644 --- a/.github/workflows/zig-test.yml +++ b/.github/workflows/zig-test.yml @@ -11,6 +11,14 @@ on: - "src/**/*.zig" - "src/*.zig" pull_request: + + # By default GH trigger on types opened, synchronize and reopened. + # see https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request + # Since we skip the job when the PR is in draft state, we want to force CI + # running when the PR is marked ready_for_review w/o other change. + # see https://github.com/orgs/community/discussions/25722#discussioncomment-3248917 + types: [opened, synchronize, reopened, ready_for_review] + branches: - main paths: @@ -22,6 +30,10 @@ on: jobs: zig-test: name: zig test + + # Don't run the CI with draft PR. + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest container: image: ghcr.io/browsercore/zig-browsercore:0.11.0