Skip to content

Commit

Permalink
Add NSIS windows packaging
Browse files Browse the repository at this point in the history
- Add and readapt the NSIS scripts
  - All bundled executables are now passed as parameters within the
    makensis call
- Add a workflow that build the NSIS packages in the GH CI
  • Loading branch information
folmos-at-orange committed Oct 2, 2023
1 parent e0c178e commit 9491d5c
Show file tree
Hide file tree
Showing 25 changed files with 1,465 additions and 15 deletions.
21 changes: 13 additions & 8 deletions .github/actions/test-khiops-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,38 @@ runs:
# Put the full path in windows since bash doesn't find ".cmd" files
# in the path even if they are there
modl_path=$(which MODL)
echo "KHIOPS_SCRIPT=$(basedir $modl_path)/khiops.cmd" >> "$GITHUB_ENV"
echo "KHIOPS_CC_SCRIPT=$(basedir $modl_path)/khiops_coclustering.cmd" >> "$GITHUB_ENV"
khiops_bin_dir=$(dirname "$modl_path")
KHIOPS_SCRIPT="$khiops_bin_dir/khiops.cmd"
KHIOPS_CC_SCRIPT="$khiops_bin_dir/khiops_coclustering.cmd"
echo "KHIOPS_SCRIPT='$KHIOPS_SCRIPT'" >> "$GITHUB_ENV"
echo "KHIOPS_CC_SCRIPT='$KHIOPS_CC_SCRIPT'" >> "$GITHUB_ENV"
else
echo "KHIOPS_SCRIPT=khiops" >> "$GITHUB_ENV"
echo "KHIOPS_CC_SCRIPT=khiops-coclustering" >> "$GITHUB_ENV"
fi
# DDD
echo "Github env: $GITHUB_ENV"
cat $GITHUB_ENV
- name: Check Khiops installation
shell: bash
run: |
$KHIOPS_SCRIPT -v
$KHIOPS_CC_SCRIPT -v
"$KHIOPS_SCRIPT" -v
"$KHIOPS_CC_SCRIPT" -v
- name: Run Khiops tests
shell: bash
run: |
cd test/LearningTest/TestKhiops/Standard/Iris/
khiops -b -i test.prm -e results/err.txt
"$KHIOPS_SCRIPT" -b -i test.prm -e results/err.txt
cd -
- name: Run Khiops Coclustering tests
shell: bash
run: |
cd test/LearningTest/TestCoclustering/Standard/Iris/
khiops_coclustering -b -i test.prm -e results/err.txt
"$KHIOPS_CC_SCRIPT" -b -i test.prm -e results/err.txt
cd -
- name: Check the test results
shell: bash
run: |
run: |-
touch test/LearningTest/TestCoclustering/Standard/Iris/results/time.log
touch test/LearningTest/TestKhiops/Standard/Iris/results/time.log
echo "Check test results"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: Build development containers
name: Build Linux containers for packaging
on:
workflow_dispatch:
jobs:
build-container:
build-packaging-container:
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -24,13 +24,11 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build the image and push it to the registry
id: docker-build
uses: docker/build-push-action@v2
with:
# relative path to the place where source code with Dockerfile is located
context: ./packaging/dockerfiles
file: ./packaging/dockerfiles/Dockerfile.${{ matrix.os }}
# Note: tags must be lower-case
file: ./packaging/dockerfiles/linux/Dockerfile.${{ matrix.os }}
tags: ghcr.io/khiopsml/khiops/khiopsdev-${{ matrix.os }}:latest
push: true
- name: Display the image digest
run: echo ${{ steps.docker_build.outputs.digest }}
run: echo ${{ steps.docker-build.outputs.digest }}
47 changes: 47 additions & 0 deletions .github/workflows/build-nsis-reqs-container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: Build NSIS requirements container
on:
workflow_dispatch:
jobs:
build-requirements-container:
name: Build NSIS software requirements container
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to Github Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build the image and push it to the registry
id: docker-build
uses: docker/build-push-action@v2
with:
file: ./packaging/dockerfiles/windows/nsis-requirements/Dockerfile
tags: ghcr.io/khiopsml/khiops/khiops-nsis-requirements:latest
push: true
- name: Display the image digest
run: echo ${{ steps.docker-build.outputs.digest }}
test-requirements-container:
name: Test NSIS software requirements container
runs-on: ubuntu-latest
needs: build-requirements-container
container: ghcr.io/khiopsml/khiops/khiops-nsis-requirements:latest
permissions:
packages: read
steps:
- name: Test installer files existence
shell: bash
run: |-
cd /var/share/nsis-requirements
test -f $JRE_FILENAME
test -f $KHIOPS_VIZ_FILENAME
test -f $KHIOPS_COVIZ_FILENAME
test -f $MSMPI_FILENAME
102 changes: 102 additions & 0 deletions .github/workflows/pack-nsis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
name: Build NSIS Windows installer
on:
workflow_dispatch:
# DDD
push:
jobs:
build-nsis-installer:
outputs:
khiops-package-version: ${{ steps.get-version.outputs.khiops-package-version }}
name: Build NSIS Windows installer
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Put the package version on the environment and output
shell: bash
id: get-version
run: |
KHIOPS_PACKAGE_VERSION="$(scripts/khiops-package-version ${{ github.ref_name }})"
KHIOPS_PACKAGE_REDUCED_VERSION="$( echo $KHIOPS_PACKAGE_VERSION | cut -d'-' -f1)"
echo "KHIOPS_PACKAGE_VERSION=$KHIOPS_PACKAGE_VERSION" >> "$GITHUB_ENV"
echo "KHIOPS_PACKAGE_REDUCED_VERSION=$KHIOPS_PACKAGE_REDUCED_VERSION" >> "$GITHUB_ENV"
echo "khiops-package-version=$KHIOPS_PACKAGE_VERSION" >> "$GITHUB_OUTPUT"
- name: Download Windows install assets
uses: robinraju/[email protected]
with:
repository: khiopsml/khiops-win-install-assets
latest: true
- name: Extract Windows installer assets and load assets-info.env
shell: bash
run: |
assets_tar_gz=$(ls khiops-win-install-assets*.tar.gz)
tar -zxvf "$assets_tar_gz"
cat assets/assets-info.env >> "$GITHUB_ENV"
- name: Build Khiops binaries
uses: ./.github/actions/build-khiops
with:
preset-name: windows-msvc-release
targets: MODL MODL_Coclustering norm_jar khiops_jar
override-flags: -DTESTING=OFF
- name: Build NSIS package
shell: pwsh
run: |-
cd ./packaging/windows/nsis
makensis `
/DKHIOPS_VERSION=${{ env.KHIOPS_PACKAGE_VERSION }} `
/DKHIOPS_REDUCED_VERSION=${{ env.KHIOPS_PACKAGE_REDUCED_VERSION }} `
/DKHIOPS_WINDOWS_BUILD_DIR=..\..\..\build\windows-msvc-release `
/DJRE_INSTALLER_PATH=..\..\..\assets\${{ env.JRE_FILENAME }} `
/DMSMPI_INSTALLER_PATH=..\..\..\assets\${{ env.MSMPI_FILENAME }} `
/DKHIOPS_VIZ_INSTALLER_PATH=..\..\..\assets\${{ env.KHIOPS_VIZ_FILENAME }} `
/DKHIOPS_COVIZ_INSTALLER_PATH=..\..\..\assets\${{ env.KHIOPS_COVIZ_FILENAME }} `
khiops.nsi
- name: Upload installer as an artifact
uses: actions/[email protected]
with:
name: khiops-installer
path: ./packaging/windows/nsis/khiops-${{ env.KHIOPS_PACKAGE_VERSION }}-setup.exe
test-nsis-installer:
name: Test NSIS Windows installer
needs: build-nsis-installer
runs-on: windows-2019
steps:
- name: Download NSIS installer artifact
uses: actions/[email protected]
with:
name: khiops-installer
- name: Install Khiops
shell: pwsh
run: |
# Execute the installer
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
Start-Process `
-FilePath .\khiops-${{ needs.build-nsis-installer.outputs.khiops-package-version }}-setup.exe `
-ArgumentList '/S' `
-Wait
# Add Khiops and MPI to the path
$Env:Path += ";${Env:ProgramFiles}\khiops\bin;${Env:ProgramFiles}\Microsoft MPI\Bin"
echo "PATH=${Env:PATH}" >> ${Env:GITHUB_ENV}
echo ${Env:GITHUB_ENV}
type ${Env:GITHUB_ENV}
- name: DDD
shell: bash
run: |
echo $PATH | sed 's/:/\n/g'
which khiops || true
which khiops.cmd || true
- name: DDD
if: success() || failure()
shell: pwsh
run: |
echo "$Env:PATH"
ls "${Env:ProgramFiles}\khiops\bin"
Get-Command khiops
- name: Checkout the khiops sources
# DDD
if: success() || failure()
uses: actions/checkout@v3
- name: Test the installation
uses: ./.github/actions/test-khiops-install
Binary file added packaging/common/images/khiops.ico
Binary file not shown.
Binary file added packaging/common/images/khiops_coclustering.ico
Binary file not shown.
File renamed without changes.
File renamed without changes.
32 changes: 32 additions & 0 deletions packaging/dockerfiles/windows/nsis-requirements/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM ubuntu:22.04

ENV JRE_FILENAME="jre-8u371-windows-x64.exe"
ENV JRE_VERSION="8u371"
ENV KHIOPS_VIZ_FILENAME="khiops-visualization-Setup-10.2.8.exe"
ENV KHIOPS_VIZ_VERSION="10.2.8"
ENV KHIOPS_COVIZ_FILENAME="khiops-covisualization-Setup-10.2.4.exe"
ENV KHIOPS_COVIZ_VERSION="10.2.4"
ENV MSMPI_FILENAME="msmpisetup.exe"
ENV MSMPI_VERSION="10.1.3"
ENV SAMPLES_FILENAME="samples-v10.1.1.zip"
ENV SAMPLES_VERSION="10.1.1"

RUN true \
&& apt-get update -y \
&& apt-get install -y --no-install-recommends wget ca-certificates \
&& mkdir -p /var/share/nsis-requirements \
&& cd /var/share/nsis-requirements \
&& wget -O ${JRE_FILENAME} \
https://javadl.oracle.com/webapps/download/AutoDL?BundleId=248242_ce59cff5c23f4e2eaf4e778a117d4c5b \
&& wget -O ${KHIOPS_VIZ_FILENAME} \
https://github.com/khiopsrelease/kv-release/releases/download/v10.2.8/khiops-visualization-Setup-10.2.8.exe \
&& wget -O ${KHIOPS_COVIZ_FILENAME} \
https://github.com/khiopsrelease/kc-release/releases/download/v10.2.4/khiops-covisualization-Setup-10.2.4.exe \
&& wget -O ${MSMPI_FILENAME} \
https://download.microsoft.com/download/7/2/7/72731ebb-b63c-4170-ade7-836966263a8f/msmpisetup.exe \
&& wget -O
&& apt-get remove -y wget ca-certificates \
&& apt-get clean autoclean \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& true
119 changes: 119 additions & 0 deletions packaging/windows/nsis/CreateKhiopsCmdFileFunc.nsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
!include "FileFunc.nsh"
!include "x64.nsh"

# Macro to create the khiops.cmd script
# Example:
# ${CreateKhiopsCmdFile} "$INSTDIR\khiops.cmd" "MODL" "" "$INSTDIR" "scenario._kh" "log.txt" "1"
#
!define CreateKhiopsCmdFile "!insertmacro CreateKhiopsCmdFile"
!macro CreateKhiopsCmdFile FileName ToolName BinSuffix KhiopsHome ScenarioFileName LogFileName ParallelMode
Push "${ParallelMode}"
Push "${LogFileName}"
Push "${ScenarioFileName}"
Push "${KhiopsHome}"
Push "${BinSuffix}"
Push "${ToolName}"
Push "${FileName}"
Call CreateKhiopsCmdFile
!macroend


Function CreateKhiopsCmdFile
# Function parameters
Var /GLOBAL _FileName
Var /GLOBAL _ToolName
Var /GLOBAL _BinSuffix
Var /GLOBAL _KhiopsHome
Var /GLOBAL _ScenarioFileName
Var /GLOBAL _LogFileName
Var /GLOBAL _ParallelMode

# Retrieve parameters from stack
Pop $_FileName
Pop $_ToolName
Pop $_BinSuffix
Pop $_KhiopsHome
Pop $_ScenarioFileName
Pop $_LogFileName
Pop $_ParallelMode

# Open file to create
FileOpen $0 "$_FileName" w

# Write file
FileWrite $0 `@echo off$\r$\n`
FileWrite $0 `setlocal$\r$\n`
FileWrite $0 `$\r$\n`
FileWrite $0 `REM ========================================================$\r$\n`
FileWrite $0 `REM See the khiops_env script for full documentation on the$\r$\n`
FileWrite $0 `REM environment variables used by Khiops$\r$\n`
FileWrite $0 `REM ========================================================$\r$\n`
FileWrite $0 `$\r$\n`
FileWrite $0 `$\r$\n`
FileWrite $0 `REM ========================================================$\r$\n`
FileWrite $0 `REM Initialization of the installation directory of Khiops$\r$\n`
FileWrite $0 `$\r$\n`
FileWrite $0 `REM Test is Khiops environment already set up$\r$\n`
FileWrite $0 `if "%KHIOPS_HOME%".=="". set KHIOPS_HOME=$_KhiopsHome$\r$\n`
FileWrite $0 `if not exist "%KHIOPS_HOME%\bin$_BinSuffix\$_ToolName.exe" goto ERR_PATH$\r$\n`
FileWrite $0 `$\r$\n`
FileWrite $0 `REM Test if batch mode from parameters$\r$\n`
FileWrite $0 `set _KHIOPS_BATCH_MODE=$\r$\n`
FileWrite $0 `for %%i in (%*) do if %%i.==-b. set _KHIOPS_BATCH_MODE=true$\r$\n`
FileWrite $0 `$\r$\n`
FileWrite $0 `REM Initialize Khiops env variables$\r$\n`
FileWrite $0 `call "%KHIOPS_HOME%\bin\khiops_env" --env > NUL$\r$\n`
FileWrite $0 `if not %_KHIOPS_BATCH_MODE%.==true. if not exist "%KHIOPS_JAVA_PATH%\jvm.dll" goto ERR_JAVA$\r$\n`
FileWrite $0 `$\r$\n`
FileWrite $0 `REM Set path$\r$\n`
FileWrite $0 `set path=%KHIOPS_PATH%;%KHIOPS_JAVA_PATH%;%path%$\r$\n`
FileWrite $0 `set classpath=%KHIOPS_CLASSPATH%;%classpath%$\r$\n`
FileWrite $0 `$\r$\n`
FileWrite $0 `$\r$\n`
FileWrite $0 `REM ========================================================$\r$\n`
FileWrite $0 `REM Start Khiops (with or without parameteres)$\r$\n`
FileWrite $0 `$\r$\n`
FileWrite $0 `if %1.==. goto NOPARAMS$\r$\n`
FileWrite $0 `if not %1.==. goto PARAMS$\r$\n`
FileWrite $0 `$\r$\n`
FileWrite $0 `REM Start without parameters$\r$\n`
FileWrite $0 `:NOPARAMS$\r$\n`
FileWrite $0 `if not exist "%KHIOPS_LAST_RUN_DIR%" md "%KHIOPS_LAST_RUN_DIR%"$\r$\n`
FileWrite $0 `if not exist "%KHIOPS_LAST_RUN_DIR%" goto PARAMS$\r$\n`
${If} $_ParallelMode == "0"
FileWrite $0 `"%KHIOPS_PATH%$_BinSuffix\$_ToolName" -o "%KHIOPS_LAST_RUN_DIR%\$_ScenarioFileName" -e "%KHIOPS_LAST_RUN_DIR%\$_LogFileName"$\r$\n`
${Else}
FileWrite $0 `%KHIOPS_MPI_COMMAND% "%KHIOPS_PATH%$_BinSuffix\$_ToolName" -o "%KHIOPS_LAST_RUN_DIR%\$_ScenarioFileName" -e "%KHIOPS_LAST_RUN_DIR%\$_LogFileName"$\r$\n`
${EndIf}
FileWrite $0 `goto END$\r$\n`
FileWrite $0 `$\r$\n`
FileWrite $0 `REM Start with parameters$\r$\n`
FileWrite $0 `:PARAMS$\r$\n`
${If} $_ParallelMode == "0"
FileWrite $0 `"%KHIOPS_PATH%$_BinSuffix\$_ToolName" %*$\r$\n`
${Else}
FileWrite $0 `%KHIOPS_MPI_COMMAND% "%KHIOPS_PATH%$_BinSuffix\$_ToolName" %*$\r$\n`
${EndIf}
FileWrite $0 `goto END$\r$\n`
FileWrite $0 `$\r$\n`
FileWrite $0 `$\r$\n`
FileWrite $0 `REM ========================================================$\r$\n`
FileWrite $0 `REM Error messages$\r$\n`
FileWrite $0 `$\r$\n`
FileWrite $0 `:ERR_PATH$\r$\n`
FileWrite $0 `start "KHIOPS CONFIG PROBLEM" echo ERROR Incorrect installation directory for Khiops (File $_ToolName.exe not found in directory %KHIOPS_PATH%$_BinSuffix)$\r$\n`
FileWrite $0 `exit /b 1$\r$\n`
FileWrite $0 `$\r$\n`
FileWrite $0 `:ERR_JAVA$\r$\n`
FileWrite $0 `start "KHIOPS CONFIG PROBLEM" echo ERROR Java not correctly installed, jvm.dll not found under java directory tree %_KHIOPS_JAVA_HOME% (%_KHIOPS_JAVA_HOME_ORIGIN%): see khiops_env.cmd file in %KHIOPS_HOME%\bin, after line 'Set user Java Home'$\r$\n`
FileWrite $0 `exit /b 1$\r$\n`
FileWrite $0 `$\r$\n`
FileWrite $0 `:END$\r$\n`
FileWrite $0 `endlocal$\r$\n`
FileWrite $0 `$\r$\n`
FileWrite $0 `REM Return 1 if fatal error, 2 if error(s), 0 otherwise$\r$\n`
FileWrite $0 `exit /b %errorlevel%$\r$\n`

# Close file
FileClose $0
FunctionEnd
Loading

0 comments on commit 9491d5c

Please sign in to comment.