diff --git a/.github/workflows/compile_dll_with_zig.yml b/.github/workflows/compile_dll_with_zig.yml new file mode 100644 index 00000000..5bf26119 --- /dev/null +++ b/.github/workflows/compile_dll_with_zig.yml @@ -0,0 +1,148 @@ +name: "Compile with CMake and Zig for Windows" + +on: + workflow_dispatch: + + push: + branches: [ "Zig"] + + pull_request: + branches: [ "Zig" ] + +env: + CONFIGURATION: Release + PLATFORM: x64 + BOOST_VERSION: '1.8.3' + + +jobs: + build_and_upload_installer: + name: Try to compile on windows with CMake + runs-on: windows-2022 + # outputs: + # installer_file_name: ${{ steps.output_installer_file_name.outputs.name }} + steps: + - uses: actions/checkout@v4 + + + # - name: Deploy Advinst + # uses: caphyon/advinst-github-action@v2.0 + # with: + # # advinst-version: '21.3' + # advinst-version: '21.7.1' + + # # advinst-license: ${{ secrets.ADVINST_LICENSE_KEY }} + # # " advinst-license + # # Advanced Installer license ID. This parameter is optional if you are using a simple project type. + # # " + + - name: Install Ninja + run: pip install ninja + + - name: Install Zig + uses: goto-bus-stop/setup-zig@v2 + with: + version: 0.13.0 + + + + - name: Create Ninja build system from CMake + shell: cmd + # # CMake errors if given c:\vcpkg and /scripts/buildsystems/vcpkg.cmake + run: | + set VCPKG_ROOT=c:/vcpkg + .\configure_for_zig.bat + + + + + - name: Build sDNA + shell: cmd + # # CMake errors if given c:\vcpkg and /scripts/buildsystems/vcpkg.cmake + run: | + set VCPKG_ROOT=c:/vcpkg + set BUILD_DIR=build_output_cmake_zig + .\run_CMake_output_build_system.bat + + + + # - name: Output the name of the .msi installer file + # id: output_installer_file_name + # shell: bash + # run: echo "name=$(ls sDNA_setup_win_v*.msi)" >> "$GITHUB_OUTPUT" + + + + - name: upload_output + id: installer-upload-step + uses: actions/upload-artifact@v4 + with: + name: output + # this file name pattern is defined in installerbits\rename_version.py + # outfilename = os.path.join(outputdir, "sDNA_setup_win_v%s.msi" % filename_friendly_version) + path: output/Release + + + # test_installer: + + # needs: build_and_upload_installer + + # strategy: + # fail-fast: false + # matrix: + # python_version: ['2.7', '3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + + # name: "Download and run sDNA installer, and run diff tests on it. " + + # runs-on: windows-2022 + # # Note: The Windows server 2022 Github runner image already includes + # # Python (currently 6 versions from 3.7 to 3.12) and a couple of + # # VC++ redistributables. Desktop users may need to install these + # # themselves, in addition to sDNA. + # # + # # https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md + # # + + # env: + # installer_file_name: ${{ needs.build_and_upload_installer.outputs.installer_file_name }} + + # steps: + + + # - uses: actions/checkout@v4 + + # - name: Download installer built in previous job + # uses: actions/download-artifact@v4 + # with: + # name: installer_file + + # - shell: cmd + # run: dir . + + + # - name: Allow the .msi to be executed + # run: Set-ItemProperty -Path ${{ env.installer_file_name }} -Name IsReadOnly -Value $false + + + # - name: Run sDNA installer using powershell script. + # # This is based on @Simran-B's powershell script (from Github Community forum), + # # according to GuiFalourd on Stack Overflow + # # https://stackoverflow.com/a/72291019/20785734 + # run: | + # $file = "${{ env.installer_file_name }}" + # $log = "install.log" + # $procMain = Start-Process "msiexec" "/i `"$file`" /qn /l*! `"$log`"" -NoNewWindow -PassThru + # $procLog = Start-Process "powershell" "Get-Content -Path `"$log`" -Wait" -NoNewWindow -PassThru + # $procMain.WaitForExit() + # $procLog.Kill() + # Remove-Item $file + + + # - name: Run regression tests + # uses: ./.github/actions/run_regression_tests + # with: + # python_version: ${{ matrix.python_version }} + # DONT_TEST_N_LINK_SUBSYSTEMS_ORDER: 1 + # ALLOW_NEGATIVE_FORMULA_ERROR_ON_ANY_LINK_PRESENT: 1 + # sdnadll: 'c:\Program Files (x86)\sDNA\x64\sdna_vs2008.dll' + # sdna_debug: "" diff --git a/.github/workflows/compile_so_with_gcc.yml b/.github/workflows/compile_so_with_gcc.yml new file mode 100644 index 00000000..7c8bbf45 --- /dev/null +++ b/.github/workflows/compile_so_with_gcc.yml @@ -0,0 +1,144 @@ +name: "Compile with CMake and GCC for Ubuntu" + +on: + workflow_dispatch: + + push: + branches: [ "GCC_Linux"] + + pull_request: + branches: [ "GCC_Linux" ] + +env: + CONFIGURATION: Release + PLATFORM: x64 + BOOST_VERSION: '1.8.3' + + +jobs: + build_and_upload_installer: + name: Try to compile on Ubuntu with CMake + runs-on: "ubuntu-24.04" + # outputs: + # installer_file_name: ${{ steps.output_installer_file_name.outputs.name }} + steps: + - uses: actions/checkout@v4 + + + # - name: Deploy Advinst + # uses: caphyon/advinst-github-action@v2.0 + # with: + # # advinst-version: '21.3' + # advinst-version: '21.7.1' + + # # advinst-license: ${{ secrets.ADVINST_LICENSE_KEY }} + # # " advinst-license + # # Advanced Installer license ID. This parameter is optional if you are using a simple project type. + # # " + + + - name: Install Git + run: | + sudo apt-get update + sudo apt-get install -y git + + - uses: lukka/get-cmake@latest + + + # Install vcpkg? + + # https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md + - name: Create Ninja build system from CMake + run: | + VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT + cmake -G Ninja -B build_output_cmake_gcc -S . + + + + + - name: Build sDNA + run: | + cmake --build build_output_cmake_gcc + + + # - name: Output the name of the .msi installer file + # id: output_installer_file_name + # shell: bash + # run: echo "name=$(ls sDNA_setup_win_v*.msi)" >> "$GITHUB_OUTPUT" + + # - name: assemble_output + + + - name: upload_output + id: installer-upload-step + uses: actions/upload-artifact@v4 + with: + name: output + # this file name pattern is defined in installerbits\rename_version.py + # outfilename = os.path.join(outputdir, "sDNA_setup_win_v%s.msi" % filename_friendly_version) + path: output + + + # test_installer: + + # needs: build_and_upload_installer + + # strategy: + # fail-fast: false + # matrix: + # python_version: ['2.7', '3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + + # name: "Download and run sDNA installer, and run diff tests on it. " + + # runs-on: windows-2022 + # # Note: The Windows server 2022 Github runner image already includes + # # Python (currently 6 versions from 3.7 to 3.12) and a couple of + # # VC++ redistributables. Desktop users may need to install these + # # themselves, in addition to sDNA. + # # + # # https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md + # # + + # env: + # installer_file_name: ${{ needs.build_and_upload_installer.outputs.installer_file_name }} + + # steps: + + + # - uses: actions/checkout@v4 + + # - name: Download installer built in previous job + # uses: actions/download-artifact@v4 + # with: + # name: installer_file + + # - shell: cmd + # run: dir . + + + # - name: Allow the .msi to be executed + # run: Set-ItemProperty -Path ${{ env.installer_file_name }} -Name IsReadOnly -Value $false + + + # - name: Run sDNA installer using powershell script. + # # This is based on @Simran-B's powershell script (from Github Community forum), + # # according to GuiFalourd on Stack Overflow + # # https://stackoverflow.com/a/72291019/20785734 + # run: | + # $file = "${{ env.installer_file_name }}" + # $log = "install.log" + # $procMain = Start-Process "msiexec" "/i `"$file`" /qn /l*! `"$log`"" -NoNewWindow -PassThru + # $procLog = Start-Process "powershell" "Get-Content -Path `"$log`" -Wait" -NoNewWindow -PassThru + # $procMain.WaitForExit() + # $procLog.Kill() + # Remove-Item $file + + + # - name: Run regression tests + # uses: ./.github/actions/run_regression_tests + # with: + # python_version: ${{ matrix.python_version }} + # DONT_TEST_N_LINK_SUBSYSTEMS_ORDER: 1 + # ALLOW_NEGATIVE_FORMULA_ERROR_ON_ANY_LINK_PRESENT: 1 + # sdnadll: 'c:\Program Files (x86)\sDNA\x64\sdna_vs2008.dll' + # sdna_debug: "" diff --git a/.github/workflows/compile_so_with_zig.yml b/.github/workflows/compile_so_with_zig.yml new file mode 100644 index 00000000..7cf82d91 --- /dev/null +++ b/.github/workflows/compile_so_with_zig.yml @@ -0,0 +1,143 @@ +name: "Compile with CMake and Zig for Ubuntu" + +on: + workflow_dispatch: + + push: + branches: [ "Compile_with_Zig_('Clang')", "Zig_Linux"] + + pull_request: + branches: [ "Compile_with_Zig_('Clang')", "Zig_Linux" ] + +env: + CONFIGURATION: Release + PLATFORM: x64 + BOOST_VERSION: '1.8.3' + + +jobs: + build_and_upload_installer: + name: Try to compile on Ubuntu with CMake + runs-on: "ubuntu-24.04"" + # outputs: + # installer_file_name: ${{ steps.output_installer_file_name.outputs.name }} + steps: + - uses: actions/checkout@v4 + + + # - name: Deploy Advinst + # uses: caphyon/advinst-github-action@v2.0 + # with: + # # advinst-version: '21.3' + # advinst-version: '21.7.1' + + # # advinst-license: ${{ secrets.ADVINST_LICENSE_KEY }} + # # " advinst-license + # # Advanced Installer license ID. This parameter is optional if you are using a simple project type. + # # " + + - name: Install Ninja + run: pip install ninja + + - name: Install Zig + uses: goto-bus-stop/setup-zig@v2 + with: + version: 0.13.0 + + # Install vcpkg? + + # https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md + - name: Create Ninja build system from CMake + run: | + VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT + cmake -G Ninja -B build_output_cmake_zig -S . + + + + + - name: Build sDNA + run: | + cmake --build build_output_cmake_zig + + + # - name: Output the name of the .msi installer file + # id: output_installer_file_name + # shell: bash + # run: echo "name=$(ls sDNA_setup_win_v*.msi)" >> "$GITHUB_OUTPUT" + + # - name: assemble_output + + + - name: upload_output + id: installer-upload-step + uses: actions/upload-artifact@v4 + with: + name: output + # this file name pattern is defined in installerbits\rename_version.py + # outfilename = os.path.join(outputdir, "sDNA_setup_win_v%s.msi" % filename_friendly_version) + path: output + + + # test_installer: + + # needs: build_and_upload_installer + + # strategy: + # fail-fast: false + # matrix: + # python_version: ['2.7', '3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + + # name: "Download and run sDNA installer, and run diff tests on it. " + + # runs-on: windows-2022 + # # Note: The Windows server 2022 Github runner image already includes + # # Python (currently 6 versions from 3.7 to 3.12) and a couple of + # # VC++ redistributables. Desktop users may need to install these + # # themselves, in addition to sDNA. + # # + # # https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md + # # + + # env: + # installer_file_name: ${{ needs.build_and_upload_installer.outputs.installer_file_name }} + + # steps: + + + # - uses: actions/checkout@v4 + + # - name: Download installer built in previous job + # uses: actions/download-artifact@v4 + # with: + # name: installer_file + + # - shell: cmd + # run: dir . + + + # - name: Allow the .msi to be executed + # run: Set-ItemProperty -Path ${{ env.installer_file_name }} -Name IsReadOnly -Value $false + + + # - name: Run sDNA installer using powershell script. + # # This is based on @Simran-B's powershell script (from Github Community forum), + # # according to GuiFalourd on Stack Overflow + # # https://stackoverflow.com/a/72291019/20785734 + # run: | + # $file = "${{ env.installer_file_name }}" + # $log = "install.log" + # $procMain = Start-Process "msiexec" "/i `"$file`" /qn /l*! `"$log`"" -NoNewWindow -PassThru + # $procLog = Start-Process "powershell" "Get-Content -Path `"$log`" -Wait" -NoNewWindow -PassThru + # $procMain.WaitForExit() + # $procLog.Kill() + # Remove-Item $file + + + # - name: Run regression tests + # uses: ./.github/actions/run_regression_tests + # with: + # python_version: ${{ matrix.python_version }} + # DONT_TEST_N_LINK_SUBSYSTEMS_ORDER: 1 + # ALLOW_NEGATIVE_FORMULA_ERROR_ON_ANY_LINK_PRESENT: 1 + # sdnadll: 'c:\Program Files (x86)\sDNA\x64\sdna_vs2008.dll' + # sdna_debug: "" diff --git a/sDNA/sdna_vs2008/tests/pytest/test_gathering_windows_command_line_tests.py b/sDNA/sdna_vs2008/tests/pytest/test_gathering_windows_command_line_tests.py index 58975b0c..b944476a 100644 --- a/sDNA/sdna_vs2008/tests/pytest/test_gathering_windows_command_line_tests.py +++ b/sDNA/sdna_vs2008/tests/pytest/test_gathering_windows_command_line_tests.py @@ -5,6 +5,8 @@ import sys import glob import re +import math +import itertools import subprocess import collections import tempfile @@ -501,6 +503,54 @@ def _run(self): with open(self.input_file, 'rt') as f: return f.read() +NUM_PATTERN = r'([+-]?\d+(\.\d*)?([eE][+-]?\d+)?)' + +def almost_equal(a, b, abs_tol = 2e-15): + # Whereas "0.000001E-17" != "0.0" + # almost_equal("0.000001E-17", "0.0") is True + + last_a = 0 + last_b = 0 + + matches_a = re.finditer(NUM_PATTERN, a) + matches_b = re.finditer(NUM_PATTERN, b) + + while True: + + match_a = next(matches_a, None) + match_b = next(matches_b, None) + + if match_a is None and match_b is None: + return a[last_a:] == b[last_b:] + + if not (match_a and match_b): + print('match_a: %s, match_b: %s' % (match_a, match_b)) + return False + + + start_a = match_a.start(0) + start_b = match_b.start(0) + + if a[last_a:start_a] != b[last_b:start_b]: + + print('a[last_a:start_a]: %s, b[last_b:start_b]: %s' + % (a[last_a:start_a], b[last_b:start_b])) + return False + + + last_a = match_a.end(0) + last_b = match_b.end(0) + + if abs(float(match_a.group(0)) - float(match_b.group(0))) > abs_tol: + print('float(match_a.group(0)): %s, float(match_b.group(0)): %s' + % (float(match_a.group(0)), float(match_b.group(0)))) + return False + + + + + + class DiffCommand(ReadsTextInputFile): @@ -648,7 +698,7 @@ def tuples_of_nontrivial_nonProgress_strings(*iterables): if actual.startswith('Progress:') and actual.endswith('-bit mode'): actual = ''.join(actual.partition('sDNA is running in ')[1:]) - assert actual == expected, 'Error on line num i: %s. This line (and up to the %s previous ones):\nExpected: %s, \n\n Actual: %s' % (i+1, buffer_size - 1,'\n'.join(expected_buffer), '\n'.join(actual_buffer)) + assert almost_equal(actual, expected), 'Error on line num i: %s. This line (and up to the %s previous ones):\nExpected: %s, \n\n Actual: %s' % (i+1, buffer_size - 1,'\n'.join(expected_buffer), '\n'.join(actual_buffer)) # assert actual == expected, 'i: %s, Expected: "%s", Actual: "%s"' % (i, expected, actual) prev_expected = expected m += 1