From a7e4d60c4679ff39204c201c77047f05a4ebda5a Mon Sep 17 00:00:00 2001 From: Isabel Paredes Date: Wed, 3 Jan 2024 13:06:13 +0100 Subject: [PATCH 1/5] Fix swapped env files --- .../environment-wasm-build.yml | 9 ++++----- {{cookiecutter.github_project_name}}/environment.yml | 9 +++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/{{cookiecutter.github_project_name}}/environment-wasm-build.yml b/{{cookiecutter.github_project_name}}/environment-wasm-build.yml index f8ef576..df6a0cc 100644 --- a/{{cookiecutter.github_project_name}}/environment-wasm-build.yml +++ b/{{cookiecutter.github_project_name}}/environment-wasm-build.yml @@ -1,8 +1,7 @@ -name: {{cookiecutter.conda_package_name}} +name: {{cookiecutter.conda_package_name}}-wasm-build channels: - conda-forge dependencies: - - {{cookiecutter.conda_package_name}}=0.1.0 - - notebook - - ipywidgets>=7.6 - - jupyterlab=3 + - cmake + - emsdk >=3.1.11 + - empack >=2.0.1 diff --git a/{{cookiecutter.github_project_name}}/environment.yml b/{{cookiecutter.github_project_name}}/environment.yml index df6a0cc..473db6c 100644 --- a/{{cookiecutter.github_project_name}}/environment.yml +++ b/{{cookiecutter.github_project_name}}/environment.yml @@ -1,7 +1,8 @@ -name: {{cookiecutter.conda_package_name}}-wasm-build +name: {{cookiecutter.conda_package_name}} channels: - conda-forge dependencies: - - cmake - - emsdk >=3.1.11 - - empack >=2.0.1 + - {{cookiecutter.conda_package_name}}=0.1.0 + - notebook + - ipywidgets>=7.6 + - jupyterlab=3 \ No newline at end of file From f9eb3dc0ec6c7d3857d6cb6b585047b75ee4dbb4 Mon Sep 17 00:00:00 2001 From: Isabel Paredes Date: Wed, 3 Jan 2024 13:11:56 +0100 Subject: [PATCH 2/5] Update platform name --- {{cookiecutter.github_project_name}}/.github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.github_project_name}}/.github/workflows/main.yml b/{{cookiecutter.github_project_name}}/.github/workflows/main.yml index db48be6..c95bbff 100644 --- a/{{cookiecutter.github_project_name}}/.github/workflows/main.yml +++ b/{{cookiecutter.github_project_name}}/.github/workflows/main.yml @@ -226,7 +226,7 @@ jobs: emsdk activate ${{ matrix.emsdk_ver }} {% endraw %} source $CONDA_EMSDK_DIR/emsdk_env.sh - micromamba create -f environment-wasm-host.yml --platform=emscripten-32 + micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32 mkdir build pushd build From f2518f8d07474afaf8cd6670196a84bcb5ca8b66 Mon Sep 17 00:00:00 2001 From: Isabel Paredes Date: Wed, 3 Jan 2024 13:22:03 +0100 Subject: [PATCH 3/5] Update emscripten version --- .../.github/workflows/main.yml | 6 +++--- .../environment-wasm-build.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/{{cookiecutter.github_project_name}}/.github/workflows/main.yml b/{{cookiecutter.github_project_name}}/.github/workflows/main.yml index c95bbff..12a0058 100644 --- a/{{cookiecutter.github_project_name}}/.github/workflows/main.yml +++ b/{{cookiecutter.github_project_name}}/.github/workflows/main.yml @@ -102,12 +102,12 @@ jobs: {% if cookiecutter.with_wasm == "yes" -%} emscripten_wasm_docker: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: fail-fast: false matrix: - container: ["emscripten/emsdk:2.0.34", "emscripten/emsdk:3.1.3", "emscripten/emsdk:latest"] + container: ["emscripten/emsdk:latest"] {% raw %} container: ${{ matrix.container}} @@ -201,7 +201,7 @@ jobs: strategy: fail-fast: false matrix: - emsdk_ver: ["2.0.34", "3.1.3"] + emsdk_ver: ["3.1.46"] steps: - uses: actions/checkout@v4 diff --git a/{{cookiecutter.github_project_name}}/environment-wasm-build.yml b/{{cookiecutter.github_project_name}}/environment-wasm-build.yml index df6a0cc..7cfd685 100644 --- a/{{cookiecutter.github_project_name}}/environment-wasm-build.yml +++ b/{{cookiecutter.github_project_name}}/environment-wasm-build.yml @@ -3,5 +3,5 @@ channels: - conda-forge dependencies: - cmake - - emsdk >=3.1.11 - - empack >=2.0.1 + - emsdk >=3.1.46 + - empack >=3.2.0 From 3b731030abeffebe525175e40f828d6dab49b7a7 Mon Sep 17 00:00:00 2001 From: Isabel Paredes Date: Wed, 3 Jan 2024 13:35:23 +0100 Subject: [PATCH 4/5] Use cores action --- .../.github/workflows/main.yml | 87 ++++++++++--------- 1 file changed, 48 insertions(+), 39 deletions(-) diff --git a/{{cookiecutter.github_project_name}}/.github/workflows/main.yml b/{{cookiecutter.github_project_name}}/.github/workflows/main.yml index 12a0058..ce8fce0 100644 --- a/{{cookiecutter.github_project_name}}/.github/workflows/main.yml +++ b/{{cookiecutter.github_project_name}}/.github/workflows/main.yml @@ -23,38 +23,39 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Get number of CPU cores + uses: SimenB/github-actions-cpu-cores@v2 + - name: Install micromamba uses: mamba-org/setup-micromamba@v1 with: environment-file: environment-dev.yml - environment-name: {{cookiecutter.conda_package_name}} + + - name: Make build directory + run: mkdir build - name: Configure cmake shell: bash -l {0} run: | - mkdir -p bld - cd bld cmake .. \ -DCMAKE_PREFIX_PATH=$CONDA_PREFIX \ -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX + working-directory: build - name: Build shell: bash -l {0} - run: | - cd bld - make -j8 + run: make -j${{ steps.cpu-cores.outputs.count }} + working-directory: build - name: Install shell: bash -l {0} - run: | - cd bld - make install + run: make install + working-directory: build - name: Test shell: bash -l {0} - run: | - cd test - pytest . --reruns 5 + run: pytest . --reruns 5 + working-directory: test win: {% raw %} @@ -63,7 +64,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ windows-latest] + os: [windows-latest] steps: - uses: actions/checkout@v4 @@ -75,30 +76,32 @@ jobs: powershell cmd.exe environment-file: environment-dev.yml - environment-name: {{cookiecutter.conda_package_name}} + + - name: Make build directory + run: mkdir build - name: Configure cmake shell: cmd /C CALL {0} run: | - micromamba activate {{cookiecutter.conda_package_name}} - mkdir -p bld - cd bld - cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DXEUS_BUILD_TESTS=ON -DDEPENDENCY_SEARCH_PREFIX="%CONDA_PREFIX%\Library" -DCMAKE_PREFIX_PATH="%CONDA_PREFIX%\Library" -DCMAKE_INSTALL_PREFIX="%CONDA_PREFIX%" + cmake .. -G "NMake Makefiles" ^ + -DCMAKE_BUILD_TYPE=Release ^ + -DXEUS_BUILD_TESTS=ON ^ + -DDEPENDENCY_SEARCH_PREFIX="%CONDA_PREFIX%\Library" ^ + -DCMAKE_PREFIX_PATH="%CONDA_PREFIX%\Library" ^ + -DCMAKE_INSTALL_PREFIX="%CONDA_PREFIX%" + working-directory: build - name: Build and install shell: cmd /C CALL {0} run: | - micromamba activate {{cookiecutter.conda_package_name}} - cd bld set CL=/MP nmake install + working-directory: build - name: Test shell: cmd /C CALL {0} - run: | - micromamba activate {{cookiecutter.conda_package_name}} - cd test - pytest . --reruns 5 + run: pytest . --reruns 5 + working-directory: test {% if cookiecutter.with_wasm == "yes" -%} emscripten_wasm_docker: @@ -115,6 +118,9 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Get number of CPU cores + uses: SimenB/github-actions-cpu-cores@v2 + - name: Verify emscripten run: emcc -v @@ -126,7 +132,7 @@ jobs: git checkout 0.7.2 cd /opt/xtl/build emcmake cmake ../src/ -DCMAKE_INSTALL_PREFIX=/custom_sysroot - emmake make -j2 install + emmake make -j${{ steps.cpu-cores.outputs.count }} install - name: Install nlohmann-json run: | @@ -136,7 +142,7 @@ jobs: git checkout v3.9.0 cd /opt/nlohmannjson/build emcmake cmake ../src/ -DJSON_BuildTests=OFF -DCMAKE_INSTALL_PREFIX=/custom_sysroot - emmake make -j2 install + emmake make -j${{ steps.cpu-cores.outputs.count }} install - name: Install xeus run: | @@ -152,8 +158,8 @@ jobs: -Dxtl_DIR=/custom_sysroot/share/cmake/xtl \ -Dnlohmann_json_DIR=/custom_sysroot/lib/cmake/nlohmann_json - emmake make -j2 - emmake make -j2 install + emmake make -j${{ steps.cpu-cores.outputs.count }} + emmake make -j${{ steps.cpu-cores.outputs.count }} install - name: Install xeus-lite run: | @@ -166,14 +172,15 @@ jobs: -Dxtl_DIR=custom_sysroot/share/cmake/xtl \ -Dnlohmann_json_DIR=/custom_sysroot/lib/cmake/nlohmann_json \ -Dxeus_DIR=/custom_sysroot/lib/cmake/xeus - emmake make -j2 - emmake make -j2 install + emmake make -j${{ steps.cpu-cores.outputs.count }} + emmake make -j${{ steps.cpu-cores.outputs.count }} install + + - name: Make build directory + run: mkdir build - name: Configure cmake rendered project shell: bash -l {0} run: | - mkdir -p bld - cd bld emcmake cmake .. \ -D{{cookiecutter.cmake_var_prefix}}_EMSCRIPTEN_WASM_BUILD=ON \ -Dxtl_DIR=/custom_sysroot/share/cmake/xtl \ @@ -181,18 +188,17 @@ jobs: -Dxeus_DIR=/custom_sysroot/lib/cmake/xeus \ -Dxeus-lite_DIR=/custom_sysroot/lib/cmake/xeus-lite \ -DCMAKE_INSTALL_PREFIX=/custom_sysroot + working-directory: build - name: Build rendered project shell: bash -l {0} - run: | - cd bld - emmake make -j2 + run: emmake make -j${{ steps.cpu-cores.outputs.count }} + working-directory: build - name: Install rendered project shell: bash -l {0} - run: | - cd bld - make install + run: make install + working-directory: build emscripten_wasm: @@ -206,6 +212,9 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Get number of CPU cores + uses: SimenB/github-actions-cpu-cores@v2 + - name: Install micromamba uses: mamba-org/setup-micromamba@v1 with: @@ -243,6 +252,6 @@ jobs: -D{{cookiecutter.cmake_var_prefix}}_EMSCRIPTEN_WASM_BUILD=ON \ -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \ .. - make -j5 + make -j${{ steps.cpu-cores.outputs.count }} {% endif %} From 39ce2672c294762803b31afdb11d7d08845ba914 Mon Sep 17 00:00:00 2001 From: Isabel Paredes Date: Wed, 3 Jan 2024 13:52:19 +0100 Subject: [PATCH 5/5] Add raw input --- .../.github/workflows/main.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/{{cookiecutter.github_project_name}}/.github/workflows/main.yml b/{{cookiecutter.github_project_name}}/.github/workflows/main.yml index ce8fce0..2d924ea 100644 --- a/{{cookiecutter.github_project_name}}/.github/workflows/main.yml +++ b/{{cookiecutter.github_project_name}}/.github/workflows/main.yml @@ -44,7 +44,9 @@ jobs: - name: Build shell: bash -l {0} + {% raw %} run: make -j${{ steps.cpu-cores.outputs.count }} + {% endraw %} working-directory: build - name: Install @@ -125,6 +127,7 @@ jobs: run: emcc -v - name: Install xtl + {% raw %} run: | mkdir -p /opt/xtl/build git clone https://github.com/xtensor-stack/xtl.git /opt/xtl/src @@ -133,8 +136,10 @@ jobs: cd /opt/xtl/build emcmake cmake ../src/ -DCMAKE_INSTALL_PREFIX=/custom_sysroot emmake make -j${{ steps.cpu-cores.outputs.count }} install + {% endraw %} - name: Install nlohmann-json + {% raw %} run: | mkdir -p /opt/nlohmannjson/build git clone https://github.com/nlohmann/json.git /opt/nlohmannjson/src @@ -143,8 +148,10 @@ jobs: cd /opt/nlohmannjson/build emcmake cmake ../src/ -DJSON_BuildTests=OFF -DCMAKE_INSTALL_PREFIX=/custom_sysroot emmake make -j${{ steps.cpu-cores.outputs.count }} install + {% endraw %} - name: Install xeus + {% raw %} run: | mkdir -p /opt/xeus/build git clone https://github.com/jupyter-xeus/xeus.git /opt/xeus/src @@ -160,8 +167,10 @@ jobs: emmake make -j${{ steps.cpu-cores.outputs.count }} emmake make -j${{ steps.cpu-cores.outputs.count }} install + {% endraw %} - name: Install xeus-lite + {% raw %} run: | mkdir -p /opt/xeus-lite/build git clone https://github.com/jupyter-xeus/xeus-lite.git /opt/xeus-lite/src @@ -174,6 +183,7 @@ jobs: -Dxeus_DIR=/custom_sysroot/lib/cmake/xeus emmake make -j${{ steps.cpu-cores.outputs.count }} emmake make -j${{ steps.cpu-cores.outputs.count }} install + {% endraw %} - name: Make build directory run: mkdir build @@ -192,7 +202,9 @@ jobs: - name: Build rendered project shell: bash -l {0} + {% raw %} run: emmake make -j${{ steps.cpu-cores.outputs.count }} + {% endraw %} working-directory: build - name: Install rendered project @@ -252,6 +264,8 @@ jobs: -D{{cookiecutter.cmake_var_prefix}}_EMSCRIPTEN_WASM_BUILD=ON \ -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \ .. + {% raw %} make -j${{ steps.cpu-cores.outputs.count }} + {% endraw %} {% endif %}