From 0a9f3ae9e62809cef4fae72ec2d17c4fb6ad0782 Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Sun, 30 Apr 2023 12:38:00 -0400 Subject: [PATCH 1/6] Add a build matrix for Qt 6.5 Signed-off-by: Geoff Hutchison --- .github/workflows/build_qt6.yml | 282 ++++++++++++++++++++++++++++++++ 1 file changed, 282 insertions(+) create mode 100644 .github/workflows/build_qt6.yml diff --git a/.github/workflows/build_qt6.yml b/.github/workflows/build_qt6.yml new file mode 100644 index 0000000000..9241668e12 --- /dev/null +++ b/.github/workflows/build_qt6.yml @@ -0,0 +1,282 @@ +name: Qt6 Build Matrix +# Many thanks to Cristian Adam for examples +# e.g. https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml +# https://cristianadam.eu/20191222/using-github-actions-with-c-plus-plus-and-cmake/ + + +on: [push, pull_request, workflow_dispatch] + +env: + QT_VERSION: 6.5.0 + # this is different from MACOSX_DEPLOYMENT_TARGET to prevent build problems + # we set MACOSX_DEPLOYMENT_TARGET later + MACOS_TARGET: 10.12 + FEATURES: -DBUILD_GPL_PLUGINS=ON -DWITH_COORDGEN=OFF -DUSE_VTK=ON + +jobs: + build: + name: ${{ matrix.config.name }} + runs-on: ${{ matrix.config.os }} + strategy: + fail-fast: false + matrix: + config: + - { + name: "Ubuntu Qt6", artifact: "Ubuntu-Latest.tar.gz", + os: ubuntu-latest, + cc: "gcc", cxx: "g++", + build_type: "Release", + cmake_flags: "-G Ninja -DENABLE_TESTING=ON -DTEST_QTGL=OFF -DCMAKE_BUILD_TYPE=Release", + cpack: "", + } + - { + name: "Ubuntu Qt6 AppImage", artifact: "Avogadro2.AppImage", + os: ubuntu-20.04, + cc: "gcc", cxx: "g++", + build_type: "Release", + cmake_flags: "-G Ninja -DINSTALL_BUNDLE_FILES=ON -DCMAKE_BUILD_TYPE=Release", + cpack: "", + } + - { + name: "macOS Qt6", artifact: "macOS.dmg", + os: macos-latest, + cc: "clang", cxx: "clang++", + build_type: "Release", + cmake_flags: "-G Ninja", + cpack_flags: "-G DragNDrop", + } + - { + name: "Windows Qt6", artifact: "Win64.exe", + os: windows-latest, + cc: "cl", cxx: "cl", + build_type: "Release", + cmake_flags: "", + build_flags: "-j 2", + cpack_flags: "-G NSIS", + } + + steps: + + - name: Install Dependencies (Linux) + if: runner.os == 'Linux' + run: | + sudo apt-get -qq update + sudo apt-get -qq install ninja-build libeigen3-dev libboost-all-dev libglew-dev libxml2-dev + sudo apt-get -qq install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5x11extras5-dev libqt5svg5-dev + - name: Install Dependencies (macOS) + if: runner.os == 'macOS' + run: | + if uname -p | grep -q "arm" ; then + export PATH=/opt/homebrew/bin:$PATH + else # not self-hosted runner + brew install ninja eigen glew + fi + - name: Install Dependencies (Windows) + if: runner.os == 'Windows' + run: choco install ninja + + - name: Checkout openchemistry + uses: actions/checkout@v3 + with: + repository: openchemistry/openchemistry + submodules: recursive + + - name: Checkout avogadroapp + uses: actions/checkout@v3 + with: + repository: openchemistry/avogadroapp + path: avogadroapp + + - name: Checkout avogadrolibs + uses: actions/checkout@v3 + with: + path: avogadrolibs + + - name: Cache Qt + id: cache-qt + uses: actions/cache@v3 + with: + path: ../Qt + key: ${{ runner.os }}-QtCache + + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + cached: ${{ steps.cache-qt.outputs.cache-hit }} + version: ${{ env.QT_VERSION }} + + - name: Configure MSVC Command Prompt + if: runner.os == 'Windows' + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x64 + + - name: Grab cache files + uses: actions/cache@v3 + if: runner.os != 'Windows' + with: + path: | + ${{ runner.workspace }}/build/thirdparty + ${{ runner.workspace }}/build/Downloads + key: ${{ matrix.config.name }}-thirdparty + + - name: Configure + run: | + if [ ! -d "${{ runner.workspace }}/build" ]; then mkdir "${{ runner.workspace }}/build"; fi + cd "${{ runner.workspace }}/build" + # won't have any effect except on Mac + echo "MACOSX_DEPLOYMENT_TARGET=${{ env.MACOS_TARGET }}" >> $GITHUB_ENV + CC=${{matrix.config.cc}} CXX=${{matrix.config.cxx}} cmake $GITHUB_WORKSPACE ${{env.FEATURES}} -DCMAKE_BUILD_TYPE=${{matrix.config.build_type}} ${{matrix.config.cmake_flags}} + shell: bash + + - name: Build + run: | + CC=${{matrix.config.cc}} CXX=${{matrix.config.cxx}} cmake --build . --config ${{matrix.config.build_type}} ${{matrix.config.build_flags}} + shell: bash + working-directory: ${{ runner.workspace }}/build + + - name: Fix Mac plugins + if: runner.os == 'macOS' + working-directory: ${{ runner.workspace }}/build/prefix/lib/openbabel + run: | + for plugin in *.so; do + for libpath in `otool -L ${plugin} | grep '/Users/runner/work' | awk '{print $1}'`; do + export lib=`echo $libpath | cut -d '/' -f 9`; + echo "Fixing $plugin $lib $libpath" + install_name_tool -change $libpath @executable_path/../Frameworks/$lib $plugin + done + done + cd .. # build/prefix/lib + for plugin in libinchi.?.?.?.dylib; do + for libpath in `otool -L ${plugin} | grep '/Users/runner/work' | awk '{print $1}'`; do + export lib=`echo $libpath | cut -d '/' -f 9`; + echo "Fixing $plugin $lib $libpath" + install_name_tool -change $libpath @executable_path/../Frameworks/$lib $plugin + done + done + otool -L libinchi.?.?.?.dylib + cp -p libinchi* ../Avogadro2.app/Contents/Frameworks/ + + - name: Run tests + if: matrix.config.os == 'ubuntu-20.04' + shell: cmake -P {0} + run: | + include(ProcessorCount) + ProcessorCount(N) + set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON") + set(ENV{ASAN_OPTIONS} "new_delete_type_mismatch=0") + execute_process( + COMMAND ctest -j ${N} + WORKING_DIRECTORY ${{ runner.workspace }}/build/avogadrolibs + RESULT_VARIABLE result + ) + if (NOT result EQUAL 0) + message(FATAL_ERROR "Running tests failed!") + endif() + + - name: Install the Apple certificate + # From GitHub docs: https://docs.github.com/en/actions/guides/installing-an-apple-certificate-on-macos-runners-for-xcode-development + if: runner.os == 'macOS' + working-directory: ${{ runner.workspace }}/build + env: + BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} + P12_PASSWORD: ${{ secrets.P12_PASSWORD }} + KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} + NOTARIZE_USERNAME: ${{ secrets.AC_USERNAME }} + NOTARIZE_PASSWORD: ${{ secrets.AC_PASSWORD }} + CODESIGN_IDENTITY: ${{ secrets.CODESIGN_ID }} + PRODUCT_BUNDLE_IDENTIFIER: cc.avogadro + run: | + # create variables + if [ -n "${P12_PASSWORD}" ]; then + CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 + KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db + + # import certificate and provisioning profile from secrets + echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output $CERTIFICATE_PATH + + # create temporary keychain if the cert is non-zero + if [ -s $CERTIFICATE_PATH ]; then + security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH + security set-keychain-settings -lut 21600 $KEYCHAIN_PATH + security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH + + # import certificate to keychain + security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH + security list-keychain -d user -s $KEYCHAIN_PATH + + # signing occurs via avogadroapp cpack instructions + fi # certificate exists + fi # password exists + + - name: Pack + if: matrix.config.artifact != 0 + shell: bash + run: | + if [ -z "${P12_PASSWORD}" ]; then + unset CODESIGN_IDENTITY # to prevent cpack failing when trying to sign + fi + cpack ${{ matrix.config.cpack_flags }} + env: + P12_PASSWORD: ${{ secrets.P12_PASSWORD }} + CODESIGN_IDENTITY: ${{ secrets.CODESIGN_ID }} + working-directory: ${{ runner.workspace }}/build/avogadroapp + + - name: AppImage + if: matrix.config.os == 'ubuntu-18.04' + shell: bash + run: | + mkdir appdir + mv prefix appdir/usr + wget -c -nv "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage" + wget -c -nv "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage" + chmod a+x *.AppImage + ./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/share/applications/*.desktop -bundle-non-qt-libs -extra-plugins=iconengines + # add the custom AppRun + rm appdir/AppRun + cp ../avogadrolibs/avogadrolibs/scripts/AppImage.sh appdir/AppRun + chmod a+x appdir/AppRun + ./appimagetool-x86_64.AppImage appdir + mv Avogadro2*.AppImage avogadroapp # for upload + # remove the cpack files + rm avogadroapp/Avogadro2*Linux.* + working-directory: ${{ runner.workspace }}/build + + - name: Notarize Mac DMG + if: runner.os == 'macOS' + run: | + # check current directory (failing signing) + echo `pwd` + ls -ld + # check if we have the password and the username + if [ -n "${NOTARIZE_PASSWORD}" ] && [ -n "${NOTARIZE_USERNAME}" ]; then + codesign -s "$CODESIGN_IDENTITY" --timestamp Avogadro2*.dmg + npx notarize-cli --file Avogadro2*.dmg + fi + working-directory: ${{ runner.workspace }}/build/avogadroapp + env: + NOTARIZE_USERNAME: ${{ secrets.AC_USERNAME }} + NOTARIZE_PASSWORD: ${{ secrets.AC_PASSWORD }} + CODESIGN_IDENTITY: ${{ secrets.CODESIGN_ID }} + PRODUCT_BUNDLE_IDENTIFIER: cc.avogadro + + - name: Setup tmate session + if: ${{ failure() }} + uses: mxschmitt/action-tmate@v3 + + - name: Upload + if: matrix.config.artifact != 0 + uses: actions/upload-artifact@v3 + with: + path: ${{ runner.workspace }}/build/avogadroapp/Avogadro2*.* + name: ${{ matrix.config.artifact }} + + - name: Cleanup + if: ${{ always() }} # To ensure this step runs even when earlier steps fail + shell: bash + run: | + ls -la ./ + rm -rf ./* || true + rm -rf ./.??* || true + ls -la ./ + From fea3702c7da585a12485ac47f96d4193699a2901 Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Wed, 3 May 2023 15:52:31 -0400 Subject: [PATCH 2/6] Use newer aqt version to access 6.5.0 Signed-off-by: Geoff Hutchison --- .github/workflows/build_qt6.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_qt6.yml b/.github/workflows/build_qt6.yml index 9241668e12..d37f421462 100644 --- a/.github/workflows/build_qt6.yml +++ b/.github/workflows/build_qt6.yml @@ -92,18 +92,13 @@ jobs: with: path: avogadrolibs - - name: Cache Qt - id: cache-qt - uses: actions/cache@v3 - with: - path: ../Qt - key: ${{ runner.os }}-QtCache - - name: Install Qt uses: jurplel/install-qt-action@v3 with: - cached: ${{ steps.cache-qt.outputs.cache-hit }} + cache: true version: ${{ env.QT_VERSION }} + aqtversion: '==3.1.*' + modules: 'qt5compat' - name: Configure MSVC Command Prompt if: runner.os == 'Windows' From dd556528596cf98c48450d62078db93c3689e010 Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Wed, 3 May 2023 16:01:01 -0400 Subject: [PATCH 3/6] Tweak build settings to enable testing Signed-off-by: Geoff Hutchison --- .github/workflows/build_cmake.yml | 14 +++++++------- .github/workflows/build_qt6.yml | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 68b0ed28f6..1f7be66e4d 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -26,7 +26,7 @@ jobs: os: ubuntu-latest, cc: "gcc", cxx: "g++", build_type: "Release", - cmake_flags: "-G Ninja -DENABLE_TESTING=ON -DTEST_QTGL=OFF -DCMAKE_BUILD_TYPE=Release", + cmake_flags: "-G Ninja -DENABLE_TESTING=ON -DTEST_QTGL=OFF", cpack: "", } - { @@ -34,7 +34,7 @@ jobs: os: ubuntu-20.04, cc: "gcc", cxx: "g++", build_type: "Release", - cmake_flags: "-G Ninja -DINSTALL_BUNDLE_FILES=ON -DCMAKE_BUILD_TYPE=Release", + cmake_flags: "-G Ninja -DINSTALL_BUNDLE_FILES=ON", cpack: "", } - { @@ -56,7 +56,7 @@ jobs: } - { name: "Ubuntu Address Sanitizer", artifact: "", - os: ubuntu-20.04, + os: ubuntu-latest, cc: "gcc", cxx: "g++", build_type: "asan", cmake_flags: "-G Ninja -DENABLE_TESTING=ON -DTEST_QTGL=OFF", @@ -64,7 +64,7 @@ jobs: } - { name: "Ubuntu Leak Sanitizer", artifact: "", - os: ubuntu-20.04, + os: ubuntu-latest, cc: "gcc", cxx: "g++", build_type: "lsan", cmake_flags: "-G Ninja -DENABLE_TESTING=ON -DTEST_QTGL=OFF", @@ -72,7 +72,7 @@ jobs: } - { name: "Ubuntu Thread Sanitizer", artifact: "", - os: ubuntu-20.04, + os: ubuntu-latest, cc: "gcc", cxx: "g++", build_type: "tsan", cmake_flags: "-G Ninja -DENABLE_TESTING=ON -DTEST_QTGL=OFF", @@ -80,7 +80,7 @@ jobs: } - { name: "Ubuntu Undefined Behavior Sanitizer", artifact: "", - os: ubuntu-20.04, + os: ubuntu-latest, cc: "gcc", cxx: "g++", build_type: "ubsan", cmake_flags: "-G Ninja -DENABLE_TESTING=ON -DTEST_QTGL=OFF", @@ -190,7 +190,7 @@ jobs: cp -p libinchi* ../Avogadro2.app/Contents/Frameworks/ - name: Run tests - if: matrix.config.os == 'ubuntu-20.04' + if: matrix.config.os == 'ubuntu-latest' shell: cmake -P {0} run: | include(ProcessorCount) diff --git a/.github/workflows/build_qt6.yml b/.github/workflows/build_qt6.yml index d37f421462..8568429600 100644 --- a/.github/workflows/build_qt6.yml +++ b/.github/workflows/build_qt6.yml @@ -26,7 +26,7 @@ jobs: os: ubuntu-latest, cc: "gcc", cxx: "g++", build_type: "Release", - cmake_flags: "-G Ninja -DENABLE_TESTING=ON -DTEST_QTGL=OFF -DCMAKE_BUILD_TYPE=Release", + cmake_flags: "-G Ninja -DENABLE_TESTING=ON -DTEST_QTGL=OFF", cpack: "", } - { @@ -34,7 +34,7 @@ jobs: os: ubuntu-20.04, cc: "gcc", cxx: "g++", build_type: "Release", - cmake_flags: "-G Ninja -DINSTALL_BUNDLE_FILES=ON -DCMAKE_BUILD_TYPE=Release", + cmake_flags: "-G Ninja -DINSTALL_BUNDLE_FILES=ON", cpack: "", } - { @@ -153,7 +153,7 @@ jobs: cp -p libinchi* ../Avogadro2.app/Contents/Frameworks/ - name: Run tests - if: matrix.config.os == 'ubuntu-20.04' + if: matrix.config.os == 'ubuntu-latest' shell: cmake -P {0} run: | include(ProcessorCount) From 9718fa802e6b1183a67f81b0ccfb1d5474c7d24a Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Wed, 3 May 2023 16:30:42 -0400 Subject: [PATCH 4/6] Update Qt cache and use -DQT_VERSION=6 for Qt6 build Signed-off-by: Geoff Hutchison --- .github/workflows/build_cmake.yml | 9 +-------- .github/workflows/build_qt6.yml | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 1f7be66e4d..ba48c22eaf 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -124,17 +124,10 @@ jobs: with: path: avogadrolibs - - name: Cache Qt - id: cache-qt - uses: actions/cache@v3 - with: - path: ../Qt - key: ${{ runner.os }}-QtCache - - name: Install Qt uses: jurplel/install-qt-action@v3 with: - cached: ${{ steps.cache-qt.outputs.cache-hit }} + cache: true version: ${{ env.QT_VERSION }} - name: Configure MSVC Command Prompt diff --git a/.github/workflows/build_qt6.yml b/.github/workflows/build_qt6.yml index 8568429600..580498cae2 100644 --- a/.github/workflows/build_qt6.yml +++ b/.github/workflows/build_qt6.yml @@ -11,7 +11,7 @@ env: # this is different from MACOSX_DEPLOYMENT_TARGET to prevent build problems # we set MACOSX_DEPLOYMENT_TARGET later MACOS_TARGET: 10.12 - FEATURES: -DBUILD_GPL_PLUGINS=ON -DWITH_COORDGEN=OFF -DUSE_VTK=ON + FEATURES: -DBUILD_GPL_PLUGINS=ON -DWITH_COORDGEN=OFF -DUSE_VTK=ON -DQT_VERSION=6 jobs: build: From ebf180a7140ba1597ae4ff376e81e67942f2e078 Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Wed, 3 May 2023 19:16:39 -0400 Subject: [PATCH 5/6] Disable testing with Qt6 and block QTAIM build with Qt6 Signed-off-by: Geoff Hutchison --- .github/workflows/build_qt6.yml | 2 +- avogadro/qtplugins/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_qt6.yml b/.github/workflows/build_qt6.yml index 580498cae2..ca60416b9b 100644 --- a/.github/workflows/build_qt6.yml +++ b/.github/workflows/build_qt6.yml @@ -26,7 +26,7 @@ jobs: os: ubuntu-latest, cc: "gcc", cxx: "g++", build_type: "Release", - cmake_flags: "-G Ninja -DENABLE_TESTING=ON -DTEST_QTGL=OFF", + cmake_flags: "-G Ninja", cpack: "", } - { diff --git a/avogadro/qtplugins/CMakeLists.txt b/avogadro/qtplugins/CMakeLists.txt index ef9401f3c9..4d3c9d5901 100644 --- a/avogadro/qtplugins/CMakeLists.txt +++ b/avogadro/qtplugins/CMakeLists.txt @@ -188,7 +188,7 @@ if (USE_OPENGL) endif() # other optional plugins -if(BUILD_GPL_PLUGINS) +if(BUILD_GPL_PLUGINS AND QT_VERSION EQUAL 5) # qtaimcurvature.h/cpp contains GPL licensed code: add_subdirectory(qtaim) endif() From 95c174bcbfcb4a59063d18487cd3b84ffedcdbba Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Thu, 4 May 2023 15:33:25 -0400 Subject: [PATCH 6/6] Bump Mac deployment to 10.15 and later Signed-off-by: Geoff Hutchison --- .github/workflows/build_qt6.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_qt6.yml b/.github/workflows/build_qt6.yml index ca60416b9b..906bfcd80a 100644 --- a/.github/workflows/build_qt6.yml +++ b/.github/workflows/build_qt6.yml @@ -10,7 +10,7 @@ env: QT_VERSION: 6.5.0 # this is different from MACOSX_DEPLOYMENT_TARGET to prevent build problems # we set MACOSX_DEPLOYMENT_TARGET later - MACOS_TARGET: 10.12 + MACOS_TARGET: 10.15 FEATURES: -DBUILD_GPL_PLUGINS=ON -DWITH_COORDGEN=OFF -DUSE_VTK=ON -DQT_VERSION=6 jobs: