Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@ jobs:
- name: Build and test
run: python3 Apple ci iOS --fast-ci --simulator 'iPhone SE (3rd generation),OS=17.5'

build-emscripten:
name: 'Emscripten'
needs: build-context
if: needs.build-context.outputs.run-emscripten == 'true'
uses: ./.github/workflows/reusable-emscripten.yml

build-wasi:
name: 'WASI'
needs: build-context
Expand Down Expand Up @@ -650,6 +656,7 @@ jobs:
- build-ubuntu
- build-ubuntu-ssltests
- build-ios
- build-emscripten
- build-wasi
- test-hypothesis
- build-asan
Expand Down Expand Up @@ -706,5 +713,6 @@ jobs:
}}
${{ !fromJSON(needs.build-context.outputs.run-android) && 'build-android,' || '' }}
${{ !fromJSON(needs.build-context.outputs.run-ios) && 'build-ios,' || '' }}
${{ !fromJSON(needs.build-context.outputs.run-emscripten) && 'build-emscripten,' || '' }}
${{ !fromJSON(needs.build-context.outputs.run-wasi) && 'build-wasi,' || '' }}
jobs: ${{ toJSON(needs) }}
4 changes: 4 additions & 0 deletions .github/workflows/reusable-context.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ on: # yamllint disable-line rule:truthy
run-ubuntu:
description: Whether to run the Ubuntu tests
value: ${{ jobs.compute-changes.outputs.run-ubuntu }} # bool
run-emscripten:
description: Whether to run the Emscripten tests
value: ${{ jobs.compute-changes.outputs.run-emscripten }} # bool
run-wasi:
description: Whether to run the WASI tests
value: ${{ jobs.compute-changes.outputs.run-wasi }} # bool
Expand All @@ -65,6 +68,7 @@ jobs:
run-macos: ${{ steps.changes.outputs.run-macos }}
run-tests: ${{ steps.changes.outputs.run-tests }}
run-ubuntu: ${{ steps.changes.outputs.run-ubuntu }}
run-emscripten: ${{ steps.changes.outputs.run-emscripten }}
run-wasi: ${{ steps.changes.outputs.run-wasi }}
run-windows-msi: ${{ steps.changes.outputs.run-windows-msi }}
run-windows-tests: ${{ steps.changes.outputs.run-windows-tests }}
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/reusable-emscripten.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Reusable Emscripten

on:
workflow_call:

env:
FORCE_COLOR: 1

jobs:
build-emscripten-reusable:
name: 'build and test'
runs-on: ubuntu-24.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: "Read Emscripten config"
id: emscripten-config
shell: python
run: |
import hashlib
import json
import os
import tomllib
from pathlib import Path

config = tomllib.loads(Path("Platforms/emscripten/config.toml").read_text())
h = hashlib.sha256()
h.update(json.dumps(config["libffi"], sort_keys=True).encode())
h.update(json.dumps(config["mpdec"], sort_keys=True).encode())
h.update(Path("Platforms/emscripten/make_libffi.sh").read_bytes())
emsdk_cache = Path(os.environ["RUNNER_TEMP"]) / "emsdk-cache"
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write(f"emscripten-version={config['emscripten-version']}\n")
f.write(f"node-version={config['node-version']}\n")
f.write(f"deps-hash={h.hexdigest()}\n")
with open(os.environ["GITHUB_ENV"], "a") as f:
f.write(f"EMSDK_CACHE={emsdk_cache}\n")
- name: "Install Node.js"
uses: actions/setup-node@v6
with:
node-version: ${{ steps.emscripten-config.outputs.node-version }}
- name: "Cache Emscripten SDK"
uses: actions/cache@v5
with:
path: ${{ env.EMSDK_CACHE }}
key: emsdk-${{ steps.emscripten-config.outputs.emscripten-version }}-${{ steps.emscripten-config.outputs.deps-hash }}
- name: "Install Python"
uses: actions/setup-python@v6
with:
python-version: '3.x'
- name: "Runner image version"
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
- name: "Install Emscripten"
run: python3 Platforms/emscripten install-emscripten
- name: "Configure build Python"
run: python3 Platforms/emscripten configure-build-python -- --config-cache --with-pydebug
- name: "Make build Python"
run: python3 Platforms/emscripten make-build-python
- name: "Make dependencies"
run: python3 Platforms/emscripten make-dependencies
- name: "Configure host Python"
run: python3 Platforms/emscripten configure-host --host-runner node -- --config-cache
- name: "Make host Python"
run: python3 Platforms/emscripten make-host
- name: "Test"
run: python3 Platforms/emscripten run --test
13 changes: 13 additions & 0 deletions Tools/build/compute-changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
ANDROID_DIRS = frozenset({"Android"})
IOS_DIRS = frozenset({"Apple", "iOS"})
MACOS_DIRS = frozenset({"Mac"})
EMSCRIPTEN_DIRS = frozenset({Path("Platforms", "emscripten")})
WASI_DIRS = frozenset({Path("Platforms", "WASI")})

LIBRARY_FUZZER_PATHS = frozenset({
Expand Down Expand Up @@ -107,6 +108,7 @@ class Outputs:
run_ci_fuzz: bool = False
run_ci_fuzz_stdlib: bool = False
run_docs: bool = False
run_emscripten: bool = False
run_ios: bool = False
run_macos: bool = False
run_tests: bool = False
Expand All @@ -126,6 +128,7 @@ def compute_changes() -> None:
# Otherwise, just run the tests
outputs = Outputs(
run_android=True,
run_emscripten=True,
run_ios=True,
run_macos=True,
run_tests=True,
Expand Down Expand Up @@ -196,6 +199,8 @@ def get_file_platform(file: Path) -> str | None:
return "ios"
if first_part in ANDROID_DIRS:
return "android"
if len(file.parts) >= 2 and Path(*file.parts[:2]) in EMSCRIPTEN_DIRS:
return "emscripten"
if len(file.parts) >= 2 and Path(*file.parts[:2]) in WASI_DIRS:
return "wasi"
return None
Expand Down Expand Up @@ -244,6 +249,10 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs:
run_tests = True
platforms_changed.add("macos")
continue
if file.name == "reusable-emscripten.yml":
run_tests = True
platforms_changed.add("emscripten")
continue
if file.name == "reusable-wasi.yml":
run_tests = True
platforms_changed.add("wasi")
Expand Down Expand Up @@ -284,18 +293,21 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs:
if run_tests:
if not has_platform_specific_change or not platforms_changed:
run_android = True
run_emscripten = True
run_ios = True
run_macos = True
run_ubuntu = True
run_wasi = True
else:
run_android = "android" in platforms_changed
run_emscripten = "emscripten" in platforms_changed
run_ios = "ios" in platforms_changed
run_macos = "macos" in platforms_changed
run_ubuntu = False
run_wasi = "wasi" in platforms_changed
else:
run_android = False
run_emscripten = False
run_ios = False
run_macos = False
run_ubuntu = False
Expand All @@ -306,6 +318,7 @@ def process_changed_files(changed_files: Set[Path]) -> Outputs:
run_ci_fuzz=run_ci_fuzz,
run_ci_fuzz_stdlib=run_ci_fuzz_stdlib,
run_docs=run_docs,
run_emscripten=run_emscripten,
run_ios=run_ios,
run_macos=run_macos,
run_tests=run_tests,
Expand Down
Loading