Skip to content

Fix passing special characters to console-mode launcher on Windows #228

Fix passing special characters to console-mode launcher on Windows

Fix passing special characters to console-mode launcher on Windows #228

Workflow file for this run

name: CI
on:
pull_request:
push:
branches:
- main
tags:
- "v*"
jobs:
changes:
runs-on: ubuntu-latest
outputs:
paths-to-include: ${{ steps.changes.outputs.paths-to-include }}
steps:
- uses: actions/checkout@v6.0.2
# Filter paths to determine whether to proceed with the build
- name: "Filter Paths"
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: changes
with:
filters: |
paths-to-include:
- '**/CMakeLists.txt'
- '**/*.cmake'
- '**/*.cpp'
- '**/*.h'
- '**/*.h.in'
- '**/*.ini'
- '.github/workflows/CI.yml'
win-tests:
needs: changes
if: ${{ needs.changes.outputs.paths-to-include == 'true' }}
runs-on: windows-2022
strategy:
matrix:
include:
- APPLAUNCHER_CMAKE_GENERATOR: "Ninja"
APPLAUNCHER_PACKAGE_TARGET: "package"
# The wrapper is generated by FindVcvars CMake module used in "msvc-static-configure.cmake"
APPLAUNCHER_BUILD_WRAPPER: "CMakeFiles/vcvarsall_wrapper.bat"
- APPLAUNCHER_CMAKE_GENERATOR: "Visual Studio 17 2022"
APPLAUNCHER_PACKAGE_TARGET: "PACKAGE"
APPLAUNCHER_BUILD_WRAPPER: ""
name: windows-2022
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
path: src
- name: Setup CMake
uses: jwlawson/actions-setup-cmake@3a6cbe35ba64df7ca70c51365c4aff65db9a9037 # v2.1.1
with:
cmake-version: 3.22.2
- name: Create directories
run: |
mkdir C:\Qt-static
mkdir build
- name: Download Qt archive
uses: carlosperate/download-file-action@3ec6fcef61e19eaaa0236a95fbaf333f2baf341e # v2.0.2
with:
file-url: "https://github.com/jcfr/qt-static-build/releases/download/applauncher-5.11.2-vs2017/qt-5.11.2-static-ltcg-msvc2017-x86.zip"
sha256: "e2531150a00d68624257d7b40c5b9d7c07feab55fbf98f7cda31f08b74b71c01"
- name: Extract Qt archive
shell: pwsh
run: |
7z x qt-5.11.2-static-ltcg-msvc2017-x86.zip -oC:\Qt-static\
# Since only the latest VC build tools are installed on the wnidows-2022 runner,
# this explicitly installs the component providing v141 toolset matching the one
# used to build "qt-5.11.2-static-ltcg-msvc2017-x86.zip".
# See https://github.com/actions/runner-images/issues/9701
- name: Install Visual Studio components
run: |
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
$InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
$componentsToAdd= @(
"Microsoft.VisualStudio.Component.VC.v141.x86.x64"
)
[string]$workloadArgs = $componentsToAdd | ForEach-Object {" --add " + $_}
$Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
# should be run twice
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
- name: Configure
shell: pwsh
run: |
$Qt5_DIR="C:\Qt-static\qt-5.11.2-static-ltcg-msvc2017-x86\lib\cmake\Qt5"
$CTKAppLauncher_SOURCE_DIR="${{ github.workspace }}\src"
$CTKAppLauncher_BUILD_DIR="${{ github.workspace }}\build"
cmake `
-DQt5_DIR:FILEPATH=$Qt5_DIR `
-DCTKAppLauncher_SOURCE_DIR:PATH=$CTKAppLauncher_SOURCE_DIR `
-DCTKAppLauncher_BUILD_DIR:PATH=$CTKAppLauncher_BUILD_DIR `
-DAPPLAUNCHER_CMAKE_GENERATOR_PLATFORM:STRING=Win32 `
-DAPPLAUNCHER_CMAKE_GENERATOR_TOOLSET:STRING=v141 `
-P src\msvc-static-configure.cmake
env:
APPLAUNCHER_CMAKE_GENERATOR: ${{ matrix.APPLAUNCHER_CMAKE_GENERATOR }}
- name: Build and package
shell: pwsh
run: |
$cmd = "${{ matrix.APPLAUNCHER_BUILD_WRAPPER }} cmake --build build --config Release --target ${{ matrix.APPLAUNCHER_PACKAGE_TARGET }}"
Invoke-Expression $cmd
$host.SetShouldExit($LastExitCode)
- name: Test
shell: pwsh
run: |
$cmd = "${{ matrix.APPLAUNCHER_BUILD_WRAPPER }} ctest -C Release --test-dir build --output-on-failure -j4"
Invoke-Expression $cmd
$host.SetShouldExit($LastExitCode)
- name: Publish packages
if: matrix.APPLAUNCHER_CMAKE_GENERATOR == 'Visual Studio 17 2022'
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: win-packages
path: build/CTKAppLauncher-*.tar.gz
linux-tests:
needs: changes
if: ${{ needs.changes.outputs.paths-to-include == 'true' }}
runs-on: ubuntu-latest
env:
qt_archive_basename: qt-5.15.2-manylinux2.28-static-x86_64
qt_archive_sha256: e5e9a19a18a3e1e896691173dd23a668781d7154238d2e6fdd4996ca30b1f1e3
dockbuild_image: almalinux8-devtoolset14-gcc14
dockbuild_script: ./dockbuild-almalinux8-devtoolset14-gcc14-latest
name: ubuntu-latest [almalinux8-devtoolset14-gcc14]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
path: src
- name: Download Qt archive
uses: carlosperate/download-file-action@3ec6fcef61e19eaaa0236a95fbaf333f2baf341e # v2.0.2
with:
file-url:
"https://github.com/jcfr/qt-static-build/releases/download/${{
env.qt_archive_basename }}/${{ env.qt_archive_basename }}.tar.zst"
sha256: "${{ env.qt_archive_sha256 }}"
- name: Extract Qt archive
run: |
mkdir -p $qt_archive_basename
tar --zstd -xvf ${qt_archive_basename}.tar.zst -C ${qt_archive_basename}
- name: Pull build enviromment
run: |
docker pull dockbuild/${dockbuild_image}:latest
docker run --rm dockbuild/${dockbuild_image}:latest > ${dockbuild_script}
chmod u+x ${dockbuild_script}
- name: Configure
run: |
mkdir -p build
${dockbuild_script} \
src/.github/scripts/dockbuild_with_qt_env.sh "${qt_archive_basename}" \
cmake \
-DQt5_DIR:PATH=/work/${qt_archive_basename}/lib/cmake/Qt5 \
-DCTKAppLauncher_BUILD_DIR:PATH=build \
-P src/linux-static-configure.cmake
- name: Build and Package
run: |
${dockbuild_script} \
src/.github/scripts/dockbuild_with_qt_env.sh "${qt_archive_basename}" \
cmake --build build --target package
- name: Test
run: |
${dockbuild_script} \
src/.github/scripts/dockbuild_with_qt_env.sh "${qt_archive_basename}" \
src/.github/scripts/dockbuild_xvfb_wrapper.sh \
ctest \
--test-dir build \
--build-config Release \
--output-on-failure \
--parallel $(nproc)
- name: Publish packages
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: linux-packages
path: build/CTKAppLauncher-*.tar.gz
macos-tests:
needs: changes
if: ${{ needs.changes.outputs.paths-to-include == 'true' }}
runs-on: macos-14
name: macos-14
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
path: src
- name: Setup CMake
uses: jwlawson/actions-setup-cmake@3a6cbe35ba64df7ca70c51365c4aff65db9a9037 # v2.1.1
with:
cmake-version: 3.22.2
- name: Download Qt archive
uses: carlosperate/download-file-action@3ec6fcef61e19eaaa0236a95fbaf333f2baf341e # v2.0.2
with:
file-url: "https://github.com/jcfr/qt-static-build/releases/download/qt-5.15.2-macosx10.13-static-x86_64/qt-5.15.2-macosx10.13-static-x86_64.tar.bz2"
sha256: "13a1df0c939c22618fb979072c3c16191cb42f7759ea3d8ec344aa229a04bca0"
- name: Extract Qt archive
run: |
tar -xjvf qt-5.15.2-macosx10.13-static-x86_64.tar.bz2
mv qt-5.15.2-macosx10.13-static-x86_64 qt
- name: Configure
run: |
cmake \
-DQt5_DIR:DIR=$(pwd)/qt/lib/cmake/Qt5 \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.13 \
-DCMAKE_OSX_ARCHITECTURES:STRING=x86_64 \
-B build -S src
env:
CC: clang
CXX: clang++
- name: Build and Package
run: |
cmake --build build --target package -- -j4
# Exclude tests requiring X Display
- name: Test
run: |
cd build
ctest -LE XDisplayRequired --output-on-failure
- name: Publish packages
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: macos-packages
path: build/CTKAppLauncher-*.tar.gz
pass: # This job does nothing and is only used for the branch protection
if: always()
needs:
- changes
- linux-tests
- macos-tests
- win-tests
runs-on: ubuntu-latest
steps:
- name: Validate paths-to-include value
run: |
value="${{ needs.changes.outputs.paths-to-include }}"
echo "paths-to-include = '$value'"
if [[ "$value" != "true" && "$value" != "false" ]]; then
echo "::error::Invalid paths-to-include value: '$value'. Expected 'true' or 'false'."
exit 1
fi
- name: Set allowed skips
id: allow
run: |
if [[ "${{ needs.changes.outputs.paths-to-include }}" != "true" ]]; then
echo "value=[\"win-tests\",\"linux-tests\",\"macos-tests\"]" >> $GITHUB_OUTPUT
else
echo "value=[]" >> $GITHUB_OUTPUT
fi
- name: Show job results
run: |
echo "paths-to-include = ${{ needs.changes.outputs.paths-to-include }}"
echo "win-tests result = ${{ needs.win-tests.result }}"
echo "linux-tests result = ${{ needs.linux-tests.result }}"
echo "macos-tests result = ${{ needs.macos-tests.result }}"
echo "allowed-skips value = ${{ steps.allow.outputs.value }}"
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@2765efec08f0fd63e83ad900f5fd75646be69ff6 # v1.2.2
with:
jobs: ${{ toJSON(needs) }}
# Allow test jobs to be skipped when the 'paths-to-include' filter determined
# that no relevant files were modified (e.g., only docs or README changed).
# This ensures the 'pass' job still succeeds and branch protection is satisfied.
allowed-skips: ${{ steps.allow.outputs.value }}