Skip to content

Commit

Permalink
Merge pull request #35 from IsabelParedes/template
Browse files Browse the repository at this point in the history
Update template
  • Loading branch information
JohanMabille authored Jan 3, 2024
2 parents 0b5619f + 39ce267 commit f0b3eac
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 52 deletions.
109 changes: 66 additions & 43 deletions {{cookiecutter.github_project_name}}/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,41 @@ 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
{% raw %}
run: make -j${{ steps.cpu-cores.outputs.count }}
{% endraw %}
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 %}
Expand All @@ -63,7 +66,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ windows-latest]
os: [windows-latest]

steps:
- uses: actions/checkout@v4
Expand All @@ -75,70 +78,80 @@ 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:
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}}
{% endraw %}
steps:
- uses: actions/checkout@v4

- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v2

- name: Verify emscripten
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
cd /opt/xtl/src
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
{% endraw %}

- name: Install nlohmann-json
{% raw %}
run: |
mkdir -p /opt/nlohmannjson/build
git clone https://github.com/nlohmann/json.git /opt/nlohmannjson/src
cd /opt/nlohmannjson/src
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
{% endraw %}

- name: Install xeus
{% raw %}
run: |
mkdir -p /opt/xeus/build
git clone https://github.com/jupyter-xeus/xeus.git /opt/xeus/src
Expand All @@ -152,10 +165,12 @@ 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
{% 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
Expand All @@ -166,33 +181,36 @@ 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
{% endraw %}

- 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 \
-Dnlohmann_json_DIR=/custom_sysroot/lib/cmake/nlohmann_json \
-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
{% raw %}
run: emmake make -j${{ steps.cpu-cores.outputs.count }}
{% endraw %}
working-directory: build

- name: Install rendered project
shell: bash -l {0}
run: |
cd bld
make install
run: make install
working-directory: build

emscripten_wasm:

Expand All @@ -201,11 +219,14 @@ jobs:
strategy:
fail-fast: false
matrix:
emsdk_ver: ["2.0.34", "3.1.3"]
emsdk_ver: ["3.1.46"]

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:
Expand All @@ -226,7 +247,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
Expand All @@ -243,6 +264,8 @@ jobs:
-D{{cookiecutter.cmake_var_prefix}}_EMSCRIPTEN_WASM_BUILD=ON \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
..
make -j5
{% raw %}
make -j${{ steps.cpu-cores.outputs.count }}
{% endraw %}
{% endif %}
Original file line number Diff line number Diff line change
@@ -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.46
- empack >=3.2.0
9 changes: 5 additions & 4 deletions {{cookiecutter.github_project_name}}/environment.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f0b3eac

Please sign in to comment.