| 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: 40 |
| 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["dependencies"], sort_keys=True).encode()) |
| h.update(Path("Platforms/emscripten/make_libffi.sh").read_bytes()) |
| h.update(b'1') # Update to explicitly bust cache |
| 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" |
| id: emsdk-cache |
| uses: actions/cache@v5 |
| with: |
| path: ${{ env.EMSDK_CACHE }} |
| key: emsdk-${{ steps.emscripten-config.outputs.emscripten-version }}-${{ steps.emscripten-config.outputs.deps-hash }} |
| restore-keys: emsdk-${{ steps.emscripten-config.outputs.emscripten-version }} |
| - 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 |
| ${{ steps.emsdk-cache.outputs.cache-hit == 'true' && '--check-up-to-date' || '' }} |
| - 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: "Display build info" |
| run: python3 Platforms/emscripten run --pythoninfo |
| - name: "Test" |
| run: python3 Platforms/emscripten run --test |