Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add CI workflows for tests #68

Merged
merged 8 commits into from
Nov 15, 2023
Merged
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
77 changes: 77 additions & 0 deletions .github/workflows/wpt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: wpt

env:
ARCH: x86_64-linux

on:
push:
branches:
- main
paths:
- "src/**/*.zig"
- "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:
- "src/**/*.zig"
- "src/*.zig"
- "test/wpt/**"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

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
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GH_CI_PAT }}
# fetch submodules recusively, to get jsruntime-lib submodules also.
submodules: recursive

- name: install v8
run: |
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/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

- 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

# 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
62 changes: 62 additions & 0 deletions .github/workflows/zig-fmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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:
- "src/**/*.zig"
- "src/*.zig"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

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
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
77 changes: 77 additions & 0 deletions .github/workflows/zig-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: zig-test

env:
ARCH: x86_64-linux

on:
push:
branches:
- main
paths:
- "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:
- "src/**/*.zig"
- "src/*.zig"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

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
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GH_CI_PAT }}
# fetch submodules recusively, to get jsruntime-lib submodules also.
submodules: recursive

- name: install v8
run: |
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/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

- 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

- name: zig build debug
run: zig build -Dengine=v8
francisbouvier marked this conversation as resolved.
Show resolved Hide resolved

- name: zig build test
run: zig build test -Dengine=v8

- name: zig build release
run: zig build -Doptimize=ReleaseSafe -Dengine=v8
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down