Skip to content

Commit

Permalink
Changed GitHub Actions to use build scripts of the repository and its…
Browse files Browse the repository at this point in the history
… environment variables
  • Loading branch information
mr-manuel committed Jan 17, 2025
1 parent 0aec77e commit 4e54e01
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 176 deletions.
13 changes: 6 additions & 7 deletions .github/patches/qt-fixes.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#!/bin/bash

BUILD_FILE=".github/workflows/build-wasm.yml"
BUILD_FILE="build-wasm-install-requirements.sh"
if [ ! -f ${BUILD_FILE} ]; then
echo "## Unable to locate ${BUILD_FILE} (pwd: ${PWD})"
exit 1
fi

# Read the QT version info from the build file
QT_VERSION=$(yq '.jobs.build-wasm-file.env.QT_VERSION' ${BUILD_FILE})
# Source only the lines containing 'export'
source <(grep '^export ' ${BUILD_FILE})

# The directory is taken from the sixth step:
DIR=$(yq ".jobs.build-wasm-file.steps[5].with.dir" ${BUILD_FILE})/Qt # eg. DIR=/opt/hostedtoolcache/Qt
DIR=${OUTPUTDIR}/Qt

echo "### Using QT_VERSION: ${QT_VERSION}, dir: ${DIR}"

Expand All @@ -23,13 +22,13 @@ patch ${DIR}/${QT_VERSION}/wasm_singlethread/lib/cmake/Qt6/Qt6Dependencies.cmake
+++ Qt6Dependencies.cmake 2023-08-28 07:29:08.806970500 +0000
@@ -1,8 +1,8 @@
set(Qt6_FOUND FALSE)
set(__qt_platform_requires_host_info_package \"TRUE\")
-set(__qt_platform_initial_qt_host_path \"/Users/qt/work/install\")
-set(__qt_platform_initial_qt_host_path_cmake_dir \"/Users/qt/work/install/lib/cmake\")
+set(__qt_platform_initial_qt_host_path \"${DIR}/${QT_VERSION}/gcc_64\")
+set(__qt_platform_initial_qt_host_path_cmake_dir \"${DIR}/${QT_VERSION}/gcc_64/lib/cmake\")

_qt_internal_setup_qt_host_path(
\"\${__qt_platform_requires_host_info_package}\"
"
Expand Down
180 changes: 63 additions & 117 deletions .github/workflows/build-wasm.yml
Original file line number Diff line number Diff line change
@@ -1,129 +1,75 @@
name: build-wasm
run-name: ${{ github.actor }} is building wasm file

on:
push:
paths-ignore:
- '**/README.md'

jobs:
build-wasm-file:
env:
EMSCRIPTEN: 3.1.37
QT_VERSION: 6.6.3
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
submodules: recursive
- name: Check for a cached version
uses: actions/cache@v4
id: cached_qt_emscripten
with:
path: |
/opt/hostedtoolcache
# Adding version as cache key
key: ${{ runner.os }}-qt-${{ env.QT_VERSION }}-em-${{ env.EMSCRIPTEN }}-libegl1
- name: Install dependencies
if: steps.cached_qt_emscripten.outputs.cache-hit != 'true'
run: |
sudo apt-get update -yq &&
sudo apt-get install -y g++ build-essential mesa-common-dev libssl-dev \
wget libgl1-mesa-dev libxkbcommon-x11-0 libpulse-dev p7zip-full \
ninja-build dos2unix libegl1
sudo snap install yq
- name: Install libraries needed for building the wasm
run: |
sudo apt-get update -yq &&
sudo apt-get install -y libegl1
- name: Set up Python 3.x
if: steps.cached_qt_emscripten.outputs.cache-hit != 'true'
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install Qt ${{env.QT_VERSION}} linux desktop
if: steps.cached_qt_emscripten.outputs.cache-hit != 'true'
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==3.1.*'
version: "${{env.QT_VERSION}}"
host: 'linux'
target: 'desktop'
arch: 'gcc_64'
modules: 'qtwebsockets qtshadertools'
dir: '/opt/hostedtoolcache'
- name: Install QT ${{env.QT_VERSION}} linux wasm and cmake
if: steps.cached_qt_emscripten.outputs.cache-hit != 'true'
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==3.1.*'
version: "${{env.QT_VERSION}}"
host: 'linux'
target: 'desktop'
arch: 'wasm_singlethread'
modules: 'qtwebsockets qtshadertools'
tools: 'tools_cmake'
dir: '/opt/hostedtoolcache'
- name: patch Qt ${{env.QT_VERSION}}
if: steps.cached_qt_emscripten.outputs.cache-hit != 'true'
run: |
echo patch Qt
./.github/patches/qt-fixes.sh
export QTDIR=/opt/hostedtoolcache/Qt/$QT_VERSION/wasm_singlethread
dos2unix ${QTDIR}/plugins/platforms/{qtloader.js,wasm_shell.html}
- name: Install emscripten ${{env.EMSCRIPTEN}}
if: steps.cached_qt_emscripten.outputs.cache-hit != 'true'
run: |
echo installing emscripten ${EMSCRIPTEN}
cd /opt/hostedtoolcache/
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install ${EMSCRIPTEN}
./emsdk activate ${EMSCRIPTEN}
- name: Install QtMQTT
if: steps.cached_qt_emscripten.outputs.cache-hit != 'true'
run: |
echo installing QtMQTT
source "/opt/hostedtoolcache/emsdk/emsdk_env.sh"
git clone https://github.com/qt/qtmqtt.git
cd qtmqtt
git checkout $QT_VERSION
mkdir build-qtmqtt && cd build-qtmqtt
export PATH=$PATH:/opt/hostedtoolcache/Qt/Tools/CMake/bin
export QTDIR=/opt/hostedtoolcache/Qt/$QT_VERSION/wasm_singlethread
${QTDIR}/bin/qt-configure-module ..
cmake --build .
cmake --install . --prefix ${QTDIR} --verbose
- name: Build webassembly GUI
run: |
source "/opt/hostedtoolcache/emsdk/emsdk_env.sh"
export QTDIR=/opt/hostedtoolcache/Qt/$QT_VERSION/wasm_singlethread
export PATH=$PATH:/opt/hostedtoolcache/Qt/Tools/CMake/bin
mkdir build-wasm && cd build-wasm
${QTDIR}/bin/qt-cmake -DCMAKE_BUILD_TYPE=MinSizeRel ..
cmake --build .
cd -
- name: Patch and pack webassembly files
run: |
mkdir -p artifacts/wasm
mv build-wasm/venus-gui-v2.{html,js,wasm} build-wasm/qtloader.js images/victronenergy.svg artifacts/wasm/
mv artifacts/wasm/venus-gui-v2.html artifacts/wasm/index.html
patch artifacts/wasm/index.html < ./.github/patches/index.html.patch
grep -q -E '^var createQtAppInstance' artifacts/wasm/venus-gui-v2.js
sed -i "s%^var \(createQtAppInstance\)%window.\1%" artifacts/wasm/venus-gui-v2.js
cp .github/patches/Makefile artifacts/wasm/
cp LICENSE.txt artifacts/wasm/
cd artifacts
zip -r ../venus-webassembly.zip wasm
- name: Upload wasm files
uses: actions/upload-artifact@v4
with:
name: venus-webassembly
path: artifacts
retention-days: 5
- name: Release tagged wasm files
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: venus-webassembly.zip
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up environment variables from "build-wasm-install-requirements.sh"
run: |
source <(grep '^export ' build-wasm-install-requirements.sh)
echo "EMSCRIPTEN=$EMSCRIPTEN" >> $GITHUB_ENV
echo "QT_VERSION=$QT_VERSION" >> $GITHUB_ENV
echo "OUTPUTDIR=$OUTPUTDIR" >> $GITHUB_ENV
- name: Show fetched environment variables
run: |
echo "Loaded environment variables from \"build-wasm-install-requirements.sh\":"
echo "EMSCRIPTEN: ${{ env.EMSCRIPTEN }}"
echo "QT_VERSION: ${{ env.QT_VERSION }}"
echo "OUTPUTDIR: ${{ env.OUTPUTDIR }}"
- name: Check for a cached version
uses: actions/cache@v4
id: cached_qt_emscripten
with:
path: |
${{ env.OUTPUTDIR }}
# Adding version as cache key
key: ${{ runner.os }}-qt-${{ env.QT_VERSION }}-em-${{ env.EMSCRIPTEN }}-libegl1

- name: Install requirements
if: steps.cached_qt_emscripten.outputs.cache-hit != true
run: |
bash build-wasm-install-requirements.sh
- name: Install libraries needed for building the wasm
if: steps.cached_qt_emscripten.outputs.cache-hit == true
run: |
sudo apt-get update -yq
sudo apt-get install -y libegl1
- name: Build WebAssembly
run: |
bash build-wasm.sh
- name: ZIP wasm files
run: |
cd build-wasm
zip -r ../venus-webassembly.zip wasm
- name: Upload ZIP file
uses: actions/upload-artifact@v4
with:
name: venus-webassembly
path: venus-webassembly.zip
retention-days: 5

- name: Release tagged wasm files
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: venus-webassembly.zip
115 changes: 63 additions & 52 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
QT_VERSION: 6.6.3

jobs:
build:
Expand All @@ -23,60 +22,72 @@ jobs:
contents: write

steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
submodules: recursive
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install dependencies
run: |
sudo apt-get update -yq &&
sudo apt-get install -y g++ build-essential mesa-common-dev libssl-dev \
wget libgl1-mesa-dev libxkbcommon-x11-0 libpulse-dev p7zip-full \
ninja-build dos2unix libegl1 libxcb-cursor0
sudo snap install yq
- name: Set up environment variables from "build-wasm-install-requirements.sh"
run: |
source <(grep '^export ' build-wasm-install-requirements.sh)
echo "QT_VERSION=$QT_VERSION" >> $GITHUB_ENV
echo "OUTPUTDIR=$OUTPUTDIR" >> $GITHUB_ENV
- name: Install Qt ${{env.QT_VERSION}} linux desktop
if: steps.cached_qt_emscripten.outputs.cache-hit != 'true'
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==3.1.*'
version: "${{env.QT_VERSION}}"
host: 'linux'
target: 'desktop'
arch: 'gcc_64'
modules: 'qtwebsockets qt5compat qtshadertools'
dir: '/opt/hostedtoolcache'
- name: Show fetched environment variables
run: |
echo "Loaded environment variables from \"build-wasm-install-requirements.sh\":"
echo "QT_VERSION: ${{ env.QT_VERSION }}"
echo "OUTPUTDIR: ${{ env.OUTPUTDIR }}"
- name: Install QtMQTT
if: steps.cached_qt_emscripten.outputs.cache-hit != 'true'
run: |
echo installing QtMQTT
git clone https://github.com/qt/qtmqtt.git
cd qtmqtt
git checkout $QT_VERSION
mkdir build-qtmqtt && cd build-qtmqtt
export PATH=$PATH:/opt/hostedtoolcache/Qt/Tools/CMake/bin
export QTDIR=/opt/hostedtoolcache/Qt/$QT_VERSION/gcc_64
${QTDIR}/bin/qt-configure-module ..
cmake --build .
cmake --install . --prefix ${QTDIR} --verbose
- name: Install dependencies
run: |
sudo apt-get update -yq &&
sudo apt-get install -y g++ build-essential mesa-common-dev libssl-dev \
wget libgl1-mesa-dev libxkbcommon-x11-0 libpulse-dev p7zip-full \
ninja-build dos2unix libegl1 libxcb-cursor0
sudo snap install yq
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: |
export QTDIR=/opt/hostedtoolcache/Qt/$QT_VERSION/gcc_64
mkdir build && cd build
${QTDIR}/bin/qt-cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ../tests
- name: Install Qt ${{env.QT_VERSION}} linux desktop
if: steps.cached_qt_emscripten.outputs.cache-hit != 'true'
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==3.1.*'
version: "${{env.QT_VERSION}}"
host: 'linux'
target: 'desktop'
arch: 'gcc_64'
modules: 'qtwebsockets qt5compat qtshadertools'
dir: '${{env.OUTPUTDIR}}'

- name: Build unit tests
run: |
cd build
cmake --build . --config ${{env.BUILD_TYPE}}
- name: Install QtMQTT
if: steps.cached_qt_emscripten.outputs.cache-hit != 'true'
run: |
echo installing QtMQTT
git clone https://github.com/qt/qtmqtt.git
cd qtmqtt
git checkout $QT_VERSION
mkdir build-qtmqtt && cd build-qtmqtt
export PATH=$PATH:${{env.OUTPUTDIR}}/Qt/Tools/CMake/bin
export QTDIR=${{env.OUTPUTDIR}}/Qt/$QT_VERSION/gcc_64
${QTDIR}/bin/qt-configure-module ..
cmake --build .
cmake --install . --prefix ${QTDIR} --verbose
- name: Run unit test
run: |
cd build
# The following line needs 'QT_QPA_PLATFORM=offscreen' in order to run on the headless CI server
QT_DEBUG_PLUGINS=1 QT_QPA_PLATFORM=offscreen ctest --rerun-failed --output-on-failure
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: |
export QTDIR=${{env.OUTPUTDIR}}/Qt/$QT_VERSION/gcc_64
mkdir build && cd build
${QTDIR}/bin/qt-cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ../tests
- name: Build unit tests
run: |
cd build
cmake --build . --config ${{env.BUILD_TYPE}}
- name: Run unit test
run: |
cd build
# The following line needs 'QT_QPA_PLATFORM=offscreen' in order to run on the headless CI server
QT_DEBUG_PLUGINS=1 QT_QPA_PLATFORM=offscreen ctest --rerun-failed --output-on-failure

0 comments on commit 4e54e01

Please sign in to comment.