diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c9c3beb15..33630c56f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,6 +37,7 @@ jobs: [ $RUNNER_OS = 'Windows' ] && CONDA_EXE=$CONDA/Scripts/conda.exe [ $RUNNER_OS == macOS ] && export CONDA_PKGS_DIRS=~/.pkgs ${CONDA_EXE:-conda} create -p ../conda conda conda-build conda-verify + - name: Build the package env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} @@ -57,7 +58,7 @@ jobs: # and upload them all to anaconda.org in a single job name: package-${{ github.sha }} path: ${{ runner.temp }}/conda-bld/*/*.tar.bz2 - - name: Run examples and prepare artifacts + - name: Install local constructor run: | source ../conda/etc/profile.d/conda.sh CONDA_BLD_PATH="${{ runner.temp }}/conda-bld" \ @@ -69,6 +70,16 @@ jobs: echo "Installed constructor is not local!" exit 1 fi + - name: Patch NSIS to use logging builds on Windows + if: startsWith(matrix.os, 'windows') + run: | + source ../conda/etc/profile.d/conda.sh + nsis_version=$(conda list nsis --json | jq -r ".[].version") + curl -sL "https://sourceforge.net/projects/nsis/files/NSIS%203/${nsis_version}/nsis-${nsis_version}-log.zip/download" -o "nsis-${nsis_version}-log.zip" + unzip "nsis-${nsis_version}-log.zip" -d "$CONDA_PREFIX/NSIS/" + echo "NSIS_USING_LOG_BUILD=1" >> $GITHUB_ENV + - name: Run examples and prepare artifacts + source ../conda/etc/profile.d/conda.sh mkdir -p examples_artifacts/ python scripts/run_examples.py --keep-artifacts=examples_artifacts/ - name: Upload the example installers as artifacts diff --git a/constructor/nsis/main.nsi.tmpl b/constructor/nsis/main.nsi.tmpl index 83c37db98..c06ddfa5d 100644 --- a/constructor/nsis/main.nsi.tmpl +++ b/constructor/nsis/main.nsi.tmpl @@ -5,6 +5,24 @@ Unicode "true" +#if enable_debugging +!define ENABLE_LOGGING + +!define LogSet "!insertmacro LogSetMacro" +!macro LogSetMacro SETTING + !ifdef ENABLE_LOGGING + LogSet ${SETTING} + !endif +!macroend + +!define LogText "!insertmacro LogTextMacro" +!macro LogTextMacro INPUT_TEXT + !ifdef ENABLE_LOGGING + LogText ${INPUT_TEXT} + !endif +!macroend +#endif + !include "WinMessages.nsh" !include "WordFunc.nsh" !include "LogicLib.nsh" @@ -414,6 +432,7 @@ Function InstModePage_Leave FunctionEnd Function .onInit + ${LogSet} on Push $0 Push $1 Push $2 @@ -835,6 +854,7 @@ Function AbortRetryNSExecWait nsExec::ExecToLog $2 pop $0 ${If} $0 != "0" + DetailPrint "::error:: $1" MessageBox MB_ABORTRETRYIGNORE|MB_ICONEXCLAMATION|MB_DEFBUTTON3 \ $1 /SD IDIGNORE IDABORT abort IDRETRY retry ; IDIGNORE: Continue anyway @@ -906,9 +926,13 @@ Section "Install" call AbortRetryNSExecWait ${EndIf} - push '"$INSTDIR\pythonw.exe" -E -s "$INSTDIR\Lib\_nsis.py" mkdirs' - push 'Failed to initialize Anaconda directories' - call AbortRetryNSExecWait + DetailPrint "Running mkdirs..." + nsExec::ExecToLog '"$INSTDIR\pythonw.exe" "$INSTDIR\Lib\_nsis.py" mkdirs' + Pop $0 + ${If} $0 != "0" + push 'Failed to set directories!' + call AbortRetryNSExecWait + ${EndIf} ${If} $Ana_PostInstall_State = ${BST_CHECKED} DetailPrint "Running post install..." diff --git a/constructor/winexe.py b/constructor/winexe.py index a53fa03ae..cde447ff6 100644 --- a/constructor/winexe.py +++ b/constructor/winexe.py @@ -68,7 +68,7 @@ def setup_envs_commands(info, dir_path): SetDetailsPrint both # List of packages to install SetOutPath "{env_txt_dir}" - File {env_txt_abspath} + File "{env_txt_abspath}" # A conda-meta\history file is required for a valid conda prefix SetOutPath "{conda_meta}" FileOpen $0 "history" w @@ -86,7 +86,7 @@ def setup_envs_commands(info, dir_path): # Restore shipped conda-meta\history for remapped # channels and retain only the first transaction SetOutPath "{conda_meta}" - File {history_abspath} + File "{history_abspath}" """ lines = template.format( # this one block is for the base environment @@ -194,6 +194,7 @@ def make_nsi(info, dir_path, extra_files=()): ppd['keep_pkgs'] = info.get('keep_pkgs') or False ppd['post_install_exists'] = bool(info.get('post_install')) ppd['with_conclusion_text'] = bool(conclusion_text) + ppd["enable_debugging"] = bool(os.environ.get("NSIS_USING_LOG_BUILD")) data = preprocess(data, ppd) data = fill_template(data, replace) if info['_platform'].startswith("win") and sys.platform != 'win32': diff --git a/scripts/run_examples.py b/scripts/run_examples.py index 09eee5143..15e1b0421 100644 --- a/scripts/run_examples.py +++ b/scripts/run_examples.py @@ -102,6 +102,13 @@ def run_examples(keep_artifacts=None): elif ext == 'exe': cmd = ['cmd.exe', '/c', 'start', '/wait', fpath, '/S', '/D=%s' % env_dir] test_errored = _execute(cmd) + if ext == 'exe' and os.environ.get("NSIS_USING_LOG_BUILD"): + test_errored = 0 + with open(os.path.join(env_dir, "install.log")) as f: + for line in f: + if ":error:" in line: + print(line) + test_errored = 1 errored += test_errored if keep_artifacts: shutil.move(fpath, keep_artifacts)