Skip to content

GitHub Action for OpenRV Windows

yml
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
name: CMake on a single platform

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

env:
  # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
  BUILD_TYPE: Release
  INSTALL_ROOT_DIR: 'C:/'
  MSYS_ROOT_DIR: 'C:/msys64'
  QT5_ROOT_DIR: 'C:/Qt'
  STRAWBERRY_ROOT_DIR: 'C:/Strawberry'
  MSYS: 'winsymlinks:nativestrict'

jobs:
  install_Qt5:
    # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
    # You can convert this to a matrix build if you need cross-platform coverage.
    runs-on: windows-latest
    steps:
    - name: Init cache QT
      id: init_qt_cache
      uses: actions/cache/@v3
      with:
        path: ${{ env.QT5_ROOT_DIR }}
        key: ${{ runner.os }}-qt-5.15.2

    - name: MSVC
      uses: ilammy/msvc-dev-cmd@v1.4.1
    
    - name: Clean cache QT
      if: steps.init_qt_cache.outputs.cache-hit != 'true'
      run: |
        rm -r -Force ${{ env.QT5_ROOT_DIR }} -ErrorAction SilentlyContinue

    - name: Install Qt
      if: steps.init_qt_cache.outputs.cache-hit != 'true'
      uses: jurplel/install-qt-action@v3
      with:
        version: '5.15.2'
        host: 'windows'
        target: 'desktop'
        arch: 'win64_msvc2019_64'
        dir: '${{ env.INSTALL_ROOT_DIR }}'
        install-deps: 'true'
        modules: 'debug_info qtcharts qtdatavis3d qtlottie qtnetworkauth qtpurchasing qtquick3d qtquicktimeline qtscript qtvirtualkeyboard qtwebengine qtwebglplugin'
        archives: 'qtbase qtsvg'
        cache: 'false'
        cache-key-prefix: 'install-qt-action'
        setup-python: 'true'
        set-env: 'true'
        tools-only: 'false'
        aqtversion: '==3.1.*'
        py7zrversion: '==0.20.*'
        extra: '--external 7z'

    - name: Install QT
      if: steps.init_qt_cache.outputs.cache-hit != 'true'
      shell: powershell 
      run: |
        curl -URI https://download.qt.io/official_releases/online_installers/qt-unified-windows-x64-online.exe -OutFile ./qt-unified-windows-x64-online.exe
        ./qt-unified-windows-x64-online.exe  --root "C:/qttemp" --default-answer --confirm-command --ao --al --email tomocot931@mytrumail.com --password FuckYou69 install qt.qt5.5152.win64_msvc2019_64

    - name: Fix missing library from jurplel/install-qt-action
      if: steps.init_qt_cache.outputs.cache-hit != 'true'
      shell: powershell
      run: |
        @("QtQuick", "QtQuickWidgets", "QtQmlModels", "QtQml", "QtUiTools", "QtWebChannel", "QtMultimedia", "QtPositioning") | ForEach-Object {
          cp -r C:\qttemp\5.15.2\msvc2019_64\include\$_\ C:\Qt\5.15.2\msvc2019_64\include\$_ -ErrorAction SilentlyContinue
        }

        @("QtQuick", "QtQuick.2", "QtQml", "QtWebChannel", "QtMultimedia", "QtPositioning") | ForEach-Object {
          cp -r C:\qttemp\5.15.2\msvc2019_64\qml\$_\ C:\Qt\5.15.2\msvc2019_64\qml\$_ -ErrorAction SilentlyContinue
        }

        @("Qt5Quick", "Qt5QuickWidgets", "Qt5QmlModels", "Qt5Qml", "Qt5UiTools", "Qt5WebChannel", "Qt5Multimedia", "Qt5Positioning") | ForEach-Object {
          cp -r C:\qttemp\5.15.2\msvc2019_64\lib\cmake\$_ C:\Qt\5.15.2\msvc2019_64\lib\cmake\$_ -ErrorAction SilentlyContinue
          cp C:\qttemp\5.15.2\msvc2019_64\lib\$_.lib C:\Qt\5.15.2\msvc2019_64\lib -ErrorAction SilentlyContinue
          cp C:\qttemp\5.15.2\msvc2019_64\lib\$_.prl C:\Qt\5.15.2\msvc2019_64\lib -ErrorAction SilentlyContinue
          cp C:\qttemp\5.15.2\msvc2019_64\bin\$_.dll C:\Qt\5.15.2\msvc2019_64\bin -ErrorAction SilentlyContinue
          cp C:\qttemp\5.15.2\msvc2019_64\bin\$_d.dll C:\Qt\5.15.2\msvc2019_64\bin -ErrorAction SilentlyContinue
        }

    - name: Debug qt5 lib
      run : |
        ls C:/Qt/5.15.2/msvc2019_64 -ErrorAction SilentlyContinue
        ls C:/Qt/5.15.2/msvc2019_64/include -ErrorAction SilentlyContinue
        ls C:/Qt/5.15.2/msvc2019_64/lib -ErrorAction SilentlyContinue
        ls C:/Qt/5.15.2/msvc2019_64/lib/cmake -ErrorAction SilentlyContinue
        ls C:/Qt/5.15.2/msvc2019_64/qml -ErrorAction SilentlyContinue
        
  install_strawberry:
    runs-on: windows-latest

    steps:
    - name: Init cache Strawberry
      id: init_strawberry_cache
      uses: actions/cache/@v3
      with:
        path: ${{ env.STRAWBERRY_ROOT_DIR }}
        key: ${{ runner.os }}-strawberry

    - uses: shogo82148/actions-setup-perl@v1
      if: steps.init_strawberry_cache.outputs.cache-hit != 'true'
      with:
        perl-version: '5.38.0'
        distribution: strawberry
  
    - name: Move installation to ${{ env.STRAWBERRY_ROOT_DIR }}
      if: steps.init_strawberry_cache.outputs.cache-hit != 'true'
      run: |
        mv C:/hostedtoolcache/windows/strawberry-perl/5.38.0/x64 ${{ env.STRAWBERRY_ROOT_DIR }}
        ls C:/
        ls ${{ env.STRAWBERRY_ROOT_DIR }}

  # install_MSYS2:
  #   runs-on: windows-latest

  #   steps:
  #   - name: Init msys cache
  #     id: init_msys_cache
  #     uses: actions/cache/@v3
  #     with:
  #       path: ${{ env.MSYS_ROOT_DIR }}
  #       key: ${{ runner.os }}-msys2

  #   - name: MSYS2
  #     if: steps.init_msys_cache.outputs.cache-hit != 'true'
  #     uses: msys2/setup-msys2@v2
  #     with:
  #       location: ${{ env.INSTALL_ROOT_DIR }}
  #       install: mingw-w64-x86_64-toolchain

  #   - shell: C:/msys64/mingw64.exe {0}
  #     if: steps.init_msys_cache.outputs.cache-hit != 'true'
  #     run: |
  #       pacman -S --needed --noconfirm \
  #         mingw-w64-x86_64-autotools \
  #         mingw-w64-x86_64-cmake \
  #         mingw-w64-x86_64-glew \
  #         mingw-w64-x86_64-libarchive \
  #         mingw-w64-x86_64-make \
  #         mingw-w64-x86_64-meson \
  #         mingw-w64-x86_64-python-pip \
  #         mingw-w64-x86_64-python-psutil \
  #         mingw-w64-x86_64-toolchain \
  #         bison \
  #         flex \
  #         git \
  #         nasm \
  #         p7zip \
  #         patch \
  #         unzip \
  #         zip
  #         SETUPTOOLS_USE_DISTUTILS=stdlib pip install py7zr

  build:
    runs-on: windows-latest
    needs: 
      - install_Qt5
      - install_strawberry
      # - install_MSYS2

    defaults:
      run:
        shell: msys2 {0}

    steps:
    - name: MSYS2 setup
      uses: msys2/setup-msys2@v2
      with:
        msystem: MINGW64
        location: ${{ env.INSTALL_ROOT_DIR }}
        install: mingw-w64-x86_64-toolchain

    - name: Init QT cache
      id: init_qt_cache
      uses: actions/cache/@v3
      with:
        path: ${{ env.QT5_ROOT_DIR }}
        key: ${{ runner.os }}-qt-5.15.2

    - name: Init cache Strawberry
      id: init_strawberry_cache
      uses: actions/cache/@v3
      with:
        path: ${{ env.STRAWBERRY_ROOT_DIR }}
        key: ${{ runner.os }}-strawberry

    #    echo "::add-path::${{ env.MSYS_ROOT_DIR }}"
            
    - name: Add MSYS and Strawberry binary to PATH
      run: |
        echo "${{ env.STRAWBERRY_ROOT_DIR }}/bin" >> $GITHUB_PATH
        echo "${{ env.STRAWBERRY_ROOT_DIR }}/perl/bin" >> $GITHUB_PATH
        echo "${{ env.STRAWBERRY_ROOT_DIR }}/c/bin" >> $GITHUB_PATH

    # c:/users/runneradmin/appdata maybe we can cache this folder to speed up the build

    - name: Build
      run: |
        pacman -S --needed --noconfirm \
          mingw-w64-x86_64-autotools \
          mingw-w64-x86_64-cmake \
          mingw-w64-x86_64-glew \
          mingw-w64-x86_64-libarchive \
          mingw-w64-x86_64-make \
          mingw-w64-x86_64-meson \
          mingw-w64-x86_64-python-pip \
          mingw-w64-x86_64-python-psutil \
          mingw-w64-x86_64-toolchain \
          bison \
          flex \
          git \
          nasm \
          p7zip \
          patch \
          unzip \
          zip

        SETUPTOOLS_USE_DISTUTILS=stdlib pip install py7zr
        cd /c/msys64 && ln -sfr . msys64
        cd /c/Qt && ln -sfr . Qt && ln -sfr . Qt5.15.2
        cd /c
        git clone --recursive https://github.com/AcademySoftwareFoundation/OpenRV.git
        cd /c/OpenRV
        shopt -s expand_aliases
        source ./rvcmds.sh
        rvbootstrap Release
        rvinst

    - name: Upload artifact
      uses: actions/upload-pages-artifact@v1
      with: 
        path: 'C:/OpenRV/_install'