From a8f1e5922c6df12dc053b5be1e4e2a7878954e03 Mon Sep 17 00:00:00 2001 From: Ryan Mast <3969255+nightlark@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:11:09 -0700 Subject: [PATCH] Rewrite update-swig-interfaces action to be a composite action (#44) Fixes #43 Rewrite the `update-swig-interfaces` action to be a composite action. * Update `update-swig-interfaces/action.yml` to use a composite action instead of a Docker-based action. * Install `swig` using `pip` in the composite action. * Remove the MATLAB-related code from the action. * Set common CMake options in a single place for reuse. * Add steps to generate Java, Python, C#, and Octave interface files based on inputs. * Remove `update-swig-interfaces/Dockerfile` and `update-swig-interfaces/entrypoint.sh`. * Update `.github/dependabot.yml` to remove the `docker` package-ecosystem entry for `update-swig-interfaces/`. --- .github/dependabot.yml | 5 --- update-swig-interfaces/Dockerfile | 3 -- update-swig-interfaces/action.yml | 53 ++++++++++++++++++++++++--- update-swig-interfaces/entrypoint.sh | 54 ---------------------------- 4 files changed, 48 insertions(+), 67 deletions(-) delete mode 100644 update-swig-interfaces/Dockerfile delete mode 100755 update-swig-interfaces/entrypoint.sh diff --git a/.github/dependabot.yml b/.github/dependabot.yml index cbf1bc0..1230149 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,8 +4,3 @@ updates: directory: "/" schedule: interval: "daily" - - - package-ecosystem: "docker" - directory: "update-swig-interfaces/" - schedule: - interval: "daily" diff --git a/update-swig-interfaces/Dockerfile b/update-swig-interfaces/Dockerfile deleted file mode 100644 index c044df1..0000000 --- a/update-swig-interfaces/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM helics/buildenv:interface-gen -COPY entrypoint.sh /entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] diff --git a/update-swig-interfaces/action.yml b/update-swig-interfaces/action.yml index 5a5718a..da191c5 100644 --- a/update-swig-interfaces/action.yml +++ b/update-swig-interfaces/action.yml @@ -1,9 +1,6 @@ name: "Update SWIG Interface Files" description: "Runs swig to generate updated interface files for the HELICS language bindings" inputs: - matlab: - description: "Generate Matlab interface files" - default: false java: description: "Generate Java interface files" default: true @@ -17,5 +14,51 @@ inputs: description: "Generate Octave interface files (NOT SUPPORTED - DOES NOTHING)" default: false runs: - using: "docker" - image: "Dockerfile" + using: "composite" + steps: + - name: Install swig + run: pip install swig + + - name: Set common CMake options + id: set-common-options + run: echo "COMMON_CMAKE_OPTIONS=-DHELICS_SWIG_GENERATE_INTERFACE_FILES_ONLY=ON -DHELICS_OVERWRITE_INTERFACE_FILES=ON -DHELICS_BUILD_EXAMPLES=OFF -DHELICS_ENABLE_ZMQ_CORE=OFF -DHELICS_BUILD_TESTS=OFF -DHELICS_BUILD_APP_EXECUTABLES=OFF -DHELICS_DISABLE_BOOST=ON -DHELICS_ENABLE_SWIG=ON" >> $GITHUB_ENV + + - name: Generate Java interface files + if: inputs.java == 'true' + run: | + rm -rf interfaces/java/interface/* + mkdir build_java_interface + pushd build_java_interface || exit + cmake -DHELICS_BUILD_JAVA_INTERFACE=ON ${{ env.COMMON_CMAKE_OPTIONS }} .. + make -j2 javafile_overwrite + popd || exit + + - name: Generate Python interface files + if: inputs.python == 'true' + run: | + rm -rf interfaces/python/interface/* || true + mkdir build_python_interface + pushd build_python_interface || exit + cmake -DHELICS_BUILD_PYTHON_INTERFACE=ON ${{ env.COMMON_CMAKE_OPTIONS }} .. + make -j2 pythonfile_overwrite + popd || exit + + - name: Generate C# interface files + if: inputs.csharp == 'true' + run: | + rm -rf interfaces/csharp/interface/* || true + mkdir build_csharp_interface + pushd build_csharp_interface || exit + cmake -DHELICS_BUILD_CSHARP_INTERFACE=ON ${{ env.COMMON_CMAKE_OPTIONS }} .. + make -j2 csharpfile_overwrite + popd || exit + + - name: Generate Octave interface files + if: inputs.octave == 'true' + run: | + rm -rf interfaces/octave/interface/* || true + mkdir build_octave_interface + pushd build_octave_interface || exit + cmake -DHELICS_BUILD_OCTAVE_INTERFACE=ON ${{ env.COMMON_CMAKE_OPTIONS }} .. + make -j2 octavefile_overwrite + popd || exit diff --git a/update-swig-interfaces/entrypoint.sh b/update-swig-interfaces/entrypoint.sh deleted file mode 100755 index e2fd24c..0000000 --- a/update-swig-interfaces/entrypoint.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -# rm -rf interfaces/*/interface/* -COMMON_CMAKE_OPTIONS="-DHELICS_SWIG_GENERATE_INTERFACE_FILES_ONLY=ON -DHELICS_OVERWRITE_INTERFACE_FILES=ON -DHELICS_BUILD_EXAMPLES=OFF -DHELICS_ENABLE_ZMQ_CORE=OFF -DHELICS_BUILD_TESTS=OFF -DHELICS_BUILD_APP_EXECUTABLES=OFF -DHELICS_DISABLE_BOOST=ON -DHELICS_ENABLE_SWIG=ON" - -if [[ "${INPUT_MATLAB}" == "true" ]]; then - rm -rf interfaces/matlab/interface/* - mkdir build_matlab - pushd build_matlab || exit - # shellcheck disable=SC2086 - cmake -DHELICS_BUILD_MATLAB_INTERFACE=ON -DSWIG_EXECUTABLE=/root/swig-matlab/bin/swig ${COMMON_CMAKE_OPTIONS} .. - make -j2 mfile_overwrite - popd || exit -fi - -if [[ "${INPUT_JAVA}" == "true" ]]; then - rm -rf interfaces/java/interface/* - mkdir build_java_interface - pushd build_java_interface || exit - # shellcheck disable=SC2086 - cmake -DHELICS_BUILD_JAVA_INTERFACE=ON ${COMMON_CMAKE_OPTIONS} .. - make -j2 javafile_overwrite - popd || exit -fi - -if [[ "${INPUT_PYTHON}" == "true" ]]; then - rm -rf interfaces/python/interface/* || true - mkdir build_python_interface - pushd build_python_interface || exit - # shellcheck disable=SC2086 - cmake -DHELICS_BUILD_PYTHON_INTERFACE=ON ${COMMON_CMAKE_OPTIONS} .. - make -j2 pythonfile_overwrite - popd || exit -fi - -if [[ "${INPUT_CSHARP}" == "true" ]]; then - rm -rf interfaces/csharp/interface/* || true - mkdir build_csharp_interface - pushd build_csharp_interface || exit - # shellcheck disable=SC2086 - cmake -DHELICS_BUILD_CSHARP_INTERFACE=ON ${COMMON_CMAKE_OPTIONS} .. - make -j2 csharpfile_overwrite - popd || exit -fi - -if [[ "${INPUT_OCTAVE}" == "true" ]]; then - rm -rf interfaces/octave/interface/* || true - mkdir build_octave_interface - pushd build_octave_interface || exit - # shellcheck disable=SC2086 - cmake -DHELICS_BUILD_OCTAVE_INTERFACE=ON ${COMMON_CMAKE_OPTIONS} .. - make -j2 octavefile_overwrite - popd || exit -fi