Repository navigation
228 lines (204 loc) · 9.81 KB
/
Copy pathci.yml
File metadata and controls
228 lines (204 loc) · 9.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
name: CI
on:
push:
branches:
- master
workflow_dispatch:
# A newer push to the same branch cancels the run, which is still in progress
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
QT_VERSION: '6.11.3'
QT_MODULES: 'qtspeech qtmultimedia'
jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 150
strategy:
fail-fast: false
matrix:
include:
- name: Ubuntu
os: ubuntu-latest
# Release only triplets build the dependencies once, not in the debug and release configuration
triplet: x64-linux-release
bootstrap: bootstrap-vcpkg.sh
# The overlay of libpng avoids the crash of the incompatible libpng on Linux (the general overlays are
# listed in vcpkg-configuration.json)
vcpkg-args: --overlay-ports=pdf4qt/vcpkg/overlays/linux
qt-host: linux
qt-arch: ''
# Directory of the installed Qt under qt/Qt/<version>
qt-arch-dir: gcc_64
aqtsource: ''
cmake-args: -DPDF4QT_INSTALL_QT_DEPENDENCIES=OFF
- name: Windows
os: windows-latest
triplet: x64-windows-release
bootstrap: bootstrap-vcpkg.bat
vcpkg-args: ''
qt-host: windows
qt-arch: win64_msvc2022_64
qt-arch-dir: msvc2022_64
# aqtinstall 3.3 cannot read the Windows repository layout of Qt 6.11+, use a commit of its master
# until a release supports it
aqtsource: 'git+https://github.com/miurahr/aqtinstall.git@076e1659807d0b362a3ed684d54c2e9c775eb9c7'
cmake-args: >-
-DPDF4QT_INSTALL_QT_DEPENDENCIES=ON
-DPDF4QT_INSTALL_DEPENDENCIES=ON
-DPDF4QT_QT_ROOT="$QT_ROOT_DIR"
-DPDF4QT_INSTALL_MSVC_REDISTRIBUTABLE=ON
-DPDF4QT_INSTALL_PREPARE_WIX_INSTALLER=ON
-DPDF4QT_INSTALL_TO_USR=ON
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
path: pdf4qt
- name: Set up paths
run: |
# Paths with forward slashes on all platforms (CMake and vcpkg accept them also on Windows)
workspace="$GITHUB_WORKSPACE"
if [ "$RUNNER_OS" = Windows ]; then workspace="$(cygpath -m "$workspace")"; fi
{
echo "VCPKG_ROOT=$workspace/vcpkg"
echo "VCPKG_INSTALLED_DIR=$workspace/vcpkg_installed"
echo "VCPKG_DEFAULT_BINARY_CACHE=$workspace/vcpkg-binary-cache"
echo "VCPKG_DISABLE_METRICS=1"
} >> "$GITHUB_ENV"
- name: Install system packages
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libcups2 libcups2-dev libfontconfig1-dev
# Requirements of Qt (the list of install-qt-action, which does not install them when Qt is restored
# from the cache)
sudo apt-get install -y build-essential libgl1-mesa-dev libgstreamer-gl1.0-0 libpulse-dev libxcb-glx0 \
libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-render0 \
libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xfixes0 libxcb-xinerama0 libxcb1 \
libxkbcommon-dev libxkbcommon-x11-0 libxcb-xkb-dev libxcb-cursor0
- name: 'VCPKG: Set up VCPKG'
run: |
# vcpkg is checked out exactly at the builtin-baseline of vcpkg.json. The ABI hashes of the binary
# cache depend also on the scripts and tools of vcpkg, a checkout of its master would change them
# with each commit of vcpkg and all dependencies would be built again.
baseline="$(sed -n 's/.*"builtin-baseline": *"\([0-9a-f]*\)".*/\1/p' pdf4qt/vcpkg.json)"
git init -q vcpkg
git -C vcpkg remote add origin https://github.com/microsoft/vcpkg.git
git -C vcpkg fetch -q --depth=1 origin "$baseline"
git -C vcpkg checkout -q --detach FETCH_HEAD
./vcpkg/${{ matrix.bootstrap }} -disableMetrics
- name: 'VCPKG: Restore binary cache'
uses: actions/cache/restore@v6
with:
path: vcpkg-binary-cache
key: vcpkg-bin-v1-${{ matrix.triplet }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
vcpkg-bin-v1-${{ matrix.triplet }}-
- name: 'VCPKG: Install project dependencies'
run: |
mkdir -p vcpkg-binary-cache
find vcpkg-binary-cache -type f -name '*.zip' | sort > vcpkg-cache-before.txt
./vcpkg/vcpkg install --x-manifest-root=pdf4qt --x-install-root="$VCPKG_INSTALLED_DIR" --triplet=${{ matrix.triplet }} --host-triplet=${{ matrix.triplet }} ${{ matrix.vcpkg-args }} --clean-buildtrees-after-build --clean-packages-after-build
- name: 'VCPKG: Prune binary cache'
id: vcpkg-cache
run: |
# The archives of the binary cache are named by the ABI hash of the package. The archives, which were
# not used by this build, are deleted, so the cache does not grow with outdated binaries. The cache is
# saved only when its content has changed.
# The directory updates exists only when the status was not yet compacted into the status file
shopt -s nullglob
{ cat "$VCPKG_INSTALLED_DIR"/vcpkg/status "$VCPKG_INSTALLED_DIR"/vcpkg/updates/* || true; } | tr -d '\r' | sed -n 's/^Abi: *//p' | sort -u > vcpkg-cache-used.txt
if [ -s vcpkg-cache-used.txt ]; then
find vcpkg-binary-cache -type f -name '*.zip' | while read -r archive; do
grep -qxF "$(basename "$archive" .zip)" vcpkg-cache-used.txt || rm -f "$archive"
done
else
echo "::warning::ABI hashes of the installed packages were not found, the binary cache is not pruned"
fi
find vcpkg-binary-cache -type f -name '*.zip' | sort > vcpkg-cache-after.txt
echo "Packages: $(wc -l < vcpkg-cache-after.txt), cache size: $(du -sh vcpkg-binary-cache | cut -f1)"
if cmp -s vcpkg-cache-before.txt vcpkg-cache-after.txt; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
# Saved right after the installation of the dependencies, so a failure of the build does not lose them
- name: 'VCPKG: Save binary cache'
if: steps.vcpkg-cache.outputs.changed == 'true'
uses: actions/cache/save@v6
with:
path: vcpkg-binary-cache
key: vcpkg-bin-v1-${{ matrix.triplet }}-${{ github.run_id }}-${{ github.run_attempt }}
# Qt is cached by own steps, the automatic cache of install-qt-action has a long key containing also the
# kernel version of the runner (an update of the runner image would invalidate the cache)
- name: 'Qt: Cache key'
id: qt-key
run: |
hash="$(printf '%s\n' "$QT_VERSION" "${{ matrix.qt-host }}" "${{ matrix.qt-arch }}" "$QT_MODULES" "${{ matrix.aqtsource }}" | sha256sum | cut -c1-16)"
echo "key=$RUNNER_OS-qt-$QT_VERSION-$hash" >> "$GITHUB_OUTPUT"
- name: 'Qt: Restore cache'
id: qt-cache
uses: actions/cache/restore@v6
with:
path: qt
key: ${{ steps.qt-key.outputs.key }}
- name: 'Qt: Install'
if: steps.qt-cache.outputs.cache-hit != 'true'
uses: jurplel/install-qt-action@v4
with:
version: ${{ env.QT_VERSION }}
host: ${{ matrix.qt-host }}
target: 'desktop'
arch: ${{ matrix.qt-arch }}
dir: '${{ github.workspace }}/qt/'
modules: ${{ env.QT_MODULES }}
aqtsource: ${{ matrix.aqtsource }}
install-deps: 'false'
cache: 'false'
# The environment is set by the step below, the same for an installed and for a restored Qt
set-env: 'false'
- name: 'Qt: Save cache'
if: steps.qt-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v6
with:
path: qt
key: ${{ steps.qt-key.outputs.key }}
- name: 'Qt: Set up environment'
run: |
# The same variables as install-qt-action sets
workspace="$GITHUB_WORKSPACE"
if [ "$RUNNER_OS" = Windows ]; then workspace="$(cygpath -m "$workspace")"; fi
qt_root="$workspace/qt/Qt/$QT_VERSION/${{ matrix.qt-arch-dir }}"
if [ ! -d "$qt_root/bin" ]; then echo "::error::Qt not found in $qt_root"; exit 1; fi
{
echo "QT_ROOT_DIR=$qt_root"
echo "QT_PLUGIN_PATH=$qt_root/plugins"
echo "QML2_IMPORT_PATH=$qt_root/qml"
if [ "$RUNNER_OS" = Linux ]; then
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$qt_root/lib"
echo "PKG_CONFIG_PATH=${PKG_CONFIG_PATH:+$PKG_CONFIG_PATH:}$qt_root/lib/pkgconfig"
fi
} >> "$GITHUB_ENV"
echo "$qt_root/bin" >> "$GITHUB_PATH"
- name: Configure
working-directory: pdf4qt
run: |
# The dependencies are already installed, CMake must not run vcpkg install again into the build tree
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} -DVCPKG_HOST_TRIPLET=${{ matrix.triplet }} -DVCPKG_INSTALLED_DIR="$VCPKG_INSTALLED_DIR" -DVCPKG_MANIFEST_INSTALL=OFF ${{ matrix.cmake-args }}
- name: Build
working-directory: pdf4qt
run: |
cmake --build build --config Release --target release_translations -j6
cmake --build build --config Release -j6
- name: Install
working-directory: pdf4qt
run: |
cmake --install build --config Release