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

Add emscripten gha workflow #23

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
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
157 changes: 157 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
version: 2.1

defaults: &defaults
working_directory: ~/repo
docker:
# Built from:
# https://github.com/pyodide/pyodide/blob/2ab4b0ab6aefe99fd994bb4f9ab086e5c0aebb7b/Dockerfile
- image: pyodide/pyodide-env:20230126-chrome109-firefox109-py311

jobs:
install-emsdk:
<<: *defaults
steps:
- checkout
- run:
name: install emsdk
command: |
git clone https://github.com/emscripten-core/emsdk.git --depth=1
cd emsdk
./emsdk install 3.1.30
./emsdk activate 3.1.30

- persist_to_workspace:
root: .
paths:
- emsdk

build:
parameters:
wasm-bigint:
description: Should we build with wasm-bigint?
type: string
default: ""
environment:
WASM_BIGINT: << parameters.wasm-bigint >>
<<: *defaults
steps:
- checkout
- attach_workspace:
at: .

- run:
name: build
command: |
source ./emsdk/emsdk_env.sh
./testsuite/emscripten/build.sh

- run:
name: build tests
command: |
source ./emsdk/emsdk_env.sh
cp -r testsuite/libffi.call testsuite/libffi.call.test
cp -r testsuite/libffi.closures testsuite/libffi.closures.test
./testsuite/emscripten/build-tests.sh testsuite/libffi.call.test
./testsuite/emscripten/build-tests.sh testsuite/libffi.closures.test

- persist_to_workspace:
root: .
paths:
- target
- testsuite

test:
parameters:
test-params:
description: The tests to run.
type: string
<<: *defaults
steps:
- checkout

- attach_workspace:
at: .

- run:
name: run tests
command: |
git reset --hard
cd testsuite/emscripten/
mkdir test-results
pytest \
--junitxml=test-results/junit.xml \
test_libffi.py \
<< parameters.test-params >>
- store_test_results:
path: testsuite/emscripten/test-results

test-dejagnu:
parameters:
params:
description: Parameters to node-tests
type: string
default: ""

<<: *defaults
steps:
- checkout

- attach_workspace:
at: .

- run:
name: run tests
command: |
source ./emsdk/emsdk_env.sh
python3 testsuite/emscripten/quiet_emcc_info.py
testsuite/emscripten/node-tests.sh << parameters.params >>

workflows:
version: 2
build-and-test:
jobs:
- install-emsdk

- build:
name: build
requires:
- install-emsdk

- build:
name: build-bigint
wasm-bigint: "true"
requires:
- install-emsdk

- test:
name: test-firefox
test-params: -k firefox
requires:
- build
- test:
name: test-chrome
test-params: -k chrome
requires:
- build

- test:
name: test-firefox-bigint
test-params: -k firefox
requires:
- build-bigint

- test:
name: test-chrome-bigint
test-params: -k chrome
requires:
- build-bigint

- test-dejagnu:
name: test-dejagnu
requires:
- install-emsdk
- test-dejagnu:
name: test-dejagnu-bigint
params: --wasm-bigint
requires:
- install-emsdk
177 changes: 177 additions & 0 deletions .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
name: CI emscripten

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:


env:
PYODIDE_VERSION: 0.22.1
# PYTHON_VERSION and EMSCRIPTEN_VERSION are determined by PYODIDE_VERSION.
# The appropriate versions can be found in the Pyodide repodata.json
# "info" field, or in Makefile.envs:
# https://github.com/pyodide/pyodide/blob/main/Makefile.envs#L2
PYTHON_VERSION: 3.10.7
EMSCRIPTEN_VERSION: 3.1.27
EM_CACHE_FOLDER: emsdk-cache

jobs:
setup-emsdk-cache:
runs-on: ubuntu-22.04
steps:
- name: Setup cache
id: cache-system-libraries
uses: actions/cache@v3
with:
path: ${{env.EM_CACHE_FOLDER}}
key: ${{env.EMSCRIPTEN_VERSION}}

- uses: mymindstorm/setup-emsdk@v12
with:
version: ${{ env.EMSCRIPTEN_VERSION }}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}

test-dejagnu:
strategy:
matrix:
bigint: ["--wasm-bigint", ""]
runs-on: ubuntu-22.04
needs: [setup-emsdk-cache]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: set up python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Setup cache
id: cache-system-libraries
uses: actions/cache@v3
with:
path: ${{env.EM_CACHE_FOLDER}}
key: ${{env.EMSCRIPTEN_VERSION}}

- uses: mymindstorm/setup-emsdk@v12
with:
version: ${{ env.EMSCRIPTEN_VERSION }}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}

- name: Install dejagnu
shell: bash -l {0}
run: |
sudo apt install -y dejagnu

- name: run tests
run: |
testsuite/emscripten/node-tests.sh ${{ matrix.bigint }}

- name: Install rlgl and run
run: |
wget -qO - https://rl.gl/cli/rlgl-linux-amd64.tgz | \
tar --strip-components=2 -xvzf - ./rlgl/rlgl;
./rlgl l --key=0LIBFFI-0LIBFFI-0LIBFFI-0LIBFFI https://rl.gl
./rlgl e -l project=libffi -l sha=${GITHUB_SHA:0:7} -l CC='emcc' -l host=wasm32-emscripten --policy=https://github.com/libffi/rlgl-policy.git testsuite/libffi.log
exit $?

build:
strategy:
matrix:
bigint: ["--wasm-bigint", ""]
env:
WASM_BIGINT: ${{ matrix.bigint }}
runs-on: ubuntu-22.04
needs: [setup-emsdk-cache]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup cache
id: cache-system-libraries
uses: actions/cache@v3
with:
path: ${{env.EM_CACHE_FOLDER}}
key: ${{env.EMSCRIPTEN_VERSION}}

- uses: mymindstorm/setup-emsdk@v12
with:
version: ${{ env.EMSCRIPTEN_VERSION }}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}

- name: build
run: |
./testsuite/emscripten/build.sh ${{ matrix.bigint }}

- name: build tests
run: |
cp -r testsuite/libffi.call testsuite/libffi.call.test
cp -r testsuite/libffi.closures testsuite/libffi.closures.test
./testsuite/emscripten/build-tests.sh testsuite/libffi.call.test ${{ matrix.bigint }}
./testsuite/emscripten/build-tests.sh testsuite/libffi.closures.test ${{ matrix.bigint }}

- name: Store artifacts
uses: actions/upload-artifact@v3
with:
name: built-tests
path: |
./testsuite/libffi.c*/

test:
strategy:
matrix:
bigint: ["--wasm-bigint", ""]
browser: ["firefox", "chrome"]
runs-on: ubuntu-22.04
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: built-tests
path: ./testsuite/

- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: pyodide-env
python-version: "3.11"
channels: conda-forge
- name: Install test dependencies
run: |
pip install pytest-pyodide==0.23.2

- name:
run: |
cd testsuite/emscripten/
mkdir test-results
pytest \
--junitxml=test-results/junit.xml \
test_libffi.py \
-k ${{ matrix.browser }} \
-s

- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: pytest results ${{ matrix.bigint }} ${{ matrix.browser }}
path: testsuite/emscripten/test-results/junit.xml
reporter: java-junit

- name: Store test results
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: test-results
path: testsuite/emscripten/test-results
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
.deps
*.o
*.lo
*.wasm
*.js
*.test
*.log
.dirstamp
*.la
Makefile
Expand Down Expand Up @@ -35,3 +39,8 @@ build_*/
darwin_*/
src/arm/trampoline.S
**/texinfo.tex
target/
__pycache__
.docker_home
emsdk
test-results
4 changes: 3 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ noinst_HEADERS = src/aarch64/ffitarget.h src/aarch64/internal.h \
src/s390/ffitarget.h src/s390/internal.h src/sh/ffitarget.h \
src/sh64/ffitarget.h src/sparc/ffitarget.h \
src/sparc/internal.h src/tile/ffitarget.h src/vax/ffitarget.h \
src/wasm32/ffitarget.h \
src/x86/ffitarget.h src/x86/internal.h src/x86/internal64.h \
src/x86/asmnames.h src/xtensa/ffitarget.h src/dlmalloc.c \
src/kvx/ffitarget.h src/kvx/asm.h \
Expand All @@ -81,7 +82,7 @@ EXTRA_libffi_la_SOURCES = src/aarch64/ffi.c src/aarch64/sysv.S \
src/mips/n32.S src/moxie/ffi.c src/moxie/eabi.S \
src/nios2/ffi.c src/nios2/sysv.S src/or1k/ffi.c \
src/or1k/sysv.S src/pa/ffi.c src/pa/linux.S src/pa/hpux32.S \
src/powerpc/ffi.c src/powerpc/ffi_sysv.c \
src/pa/hpux64.S src/powerpc/ffi.c src/powerpc/ffi_sysv.c \
src/powerpc/ffi_linux64.c src/powerpc/sysv.S \
src/powerpc/linux64.S src/powerpc/linux64_closure.S \
src/powerpc/ppc_closure.S src/powerpc/aix.S \
Expand All @@ -92,6 +93,7 @@ EXTRA_libffi_la_SOURCES = src/aarch64/ffi.c src/aarch64/sysv.S \
src/sh64/sysv.S src/sparc/ffi.c src/sparc/ffi64.c \
src/sparc/v8.S src/sparc/v9.S src/tile/ffi.c src/tile/tile.S \
src/vax/ffi.c src/vax/elfbsd.S src/x86/ffi.c src/x86/sysv.S \
src/wasm32/ffi.c \
src/x86/ffiw64.c src/x86/win64.S src/x86/ffi64.c \
src/x86/unix64.S src/x86/sysv_intel.S src/x86/win64_intel.S \
src/xtensa/ffi.c src/xtensa/sysv.S src/kvx/ffi.c \
Expand Down
Loading