@@ -45,38 +45,113 @@ jobs:
4545 sudo apt-get update -y
4646 sudo apt-get install -y cmake ninja-build pkg-config qt6-base-dev qt6-base-dev-tools libqt6opengl6-dev libopencv-dev
4747
48+ - if : matrix.platform == 'macos'
49+ name : Prepare Homebrew cache paths
50+ run : |
51+ echo "HOMEBREW_CACHE=$(brew --cache)" >> "$GITHUB_ENV"
52+ echo "HOMEBREW_PREFIX=$(brew --prefix)" >> "$GITHUB_ENV"
53+
54+ - if : matrix.platform == 'macos'
55+ name : Restore Homebrew cache (downloads)
56+ uses : actions/cache/restore@v4
57+ with :
58+ path : ${{ env.HOMEBREW_CACHE }}
59+ key : brew-${{ runner.os }}-${{ matrix.arch }}-downloads-${{ hashFiles('.github/workflows/ci.yml') }}
60+ restore-keys : |
61+ brew-${{ runner.os }}-${{ matrix.arch }}-downloads-
62+
63+ - if : matrix.platform == 'macos'
64+ name : Restore Homebrew cache (cellar)
65+ uses : actions/cache/restore@v4
66+ with :
67+ path : |
68+ /opt/homebrew/Cellar
69+ /usr/local/Cellar
70+ key : brew-${{ runner.os }}-${{ matrix.arch }}-cellar-${{ hashFiles('.github/workflows/ci.yml') }}
71+ restore-keys : |
72+ brew-${{ runner.os }}-${{ matrix.arch }}-cellar-
73+
4874 - if : matrix.platform == 'macos'
4975 name : Install dependencies (macOS)
5076 run : |
5177 brew install qt opencv
5278 echo "CMAKE_PREFIX_PATH=$(brew --prefix qt)" >> "$GITHUB_ENV"
5379 echo "OpenCV_DIR=$(brew --prefix opencv)/lib/cmake/opencv4" >> "$GITHUB_ENV"
5480
81+ - if : matrix.platform == 'macos'
82+ name : Save Homebrew cache (downloads)
83+ uses : actions/cache/save@v4
84+ with :
85+ path : ${{ env.HOMEBREW_CACHE }}
86+ key : brew-${{ runner.os }}-${{ matrix.arch }}-downloads-${{ hashFiles('.github/workflows/ci.yml') }}
87+
88+ - if : matrix.platform == 'macos'
89+ name : Save Homebrew cache (cellar)
90+ uses : actions/cache/save@v4
91+ with :
92+ path : |
93+ /opt/homebrew/Cellar
94+ /usr/local/Cellar
95+ key : brew-${{ runner.os }}-${{ matrix.arch }}-cellar-${{ hashFiles('.github/workflows/ci.yml') }}
96+
5597 - if : matrix.platform == 'win'
5698 name : Prepare vcpkg cache dir
5799 shell : pwsh
58100 run : |
59101 New-Item -ItemType Directory -Force -Path "$env:GITHUB_WORKSPACE\\vcpkg" | Out-Null
60102
61103 - if : matrix.platform == 'win'
62- name : Cache vcpkg (Windows)
63- uses : actions/cache@v4
104+ name : Restore vcpkg cache (Windows installed )
105+ uses : actions/cache/restore @v4
64106 with :
65- path : |
66- vcpkg/installed
67- vcpkg/buildtrees
68- vcpkg/packages
69- vcpkg/downloads
70- vcpkg/registry
71- key : vcpkg-${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('.github/workflows/ci.yml', 'platforms/config.sh') }}
107+ path : vcpkg/installed
108+ key : vcpkg-${{ runner.os }}-${{ matrix.arch }}-installed-static-${{ hashFiles('.github/workflows/ci.yml', 'platforms/config.sh') }}
109+ restore-keys : |
110+ vcpkg-${{ runner.os }}-${{ matrix.arch }}-installed-dynamic-
111+
112+ - if : matrix.platform == 'win'
113+ name : Restore vcpkg cache (Windows downloads)
114+ uses : actions/cache/restore@v4
115+ with :
116+ path : vcpkg/downloads
117+ key : vcpkg-${{ runner.os }}-${{ matrix.arch }}-downloads-static-${{ hashFiles('.github/workflows/ci.yml', 'platforms/config.sh') }}
118+ restore-keys : |
119+ vcpkg-${{ runner.os }}-${{ matrix.arch }}-downloads-dynamic-
120+
121+ - if : matrix.platform == 'win'
122+ name : Restore vcpkg cache (Windows buildtrees)
123+ uses : actions/cache/restore@v4
124+ with :
125+ path : vcpkg/buildtrees
126+ key : vcpkg-${{ runner.os }}-${{ matrix.arch }}-buildtrees-static-${{ hashFiles('.github/workflows/ci.yml', 'platforms/config.sh') }}
127+ restore-keys : |
128+ vcpkg-${{ runner.os }}-${{ matrix.arch }}-buildtrees-dynamic-
129+
130+ - if : matrix.platform == 'win'
131+ name : Restore vcpkg cache (Windows packages)
132+ uses : actions/cache/restore@v4
133+ with :
134+ path : vcpkg/packages
135+ key : vcpkg-${{ runner.os }}-${{ matrix.arch }}-packages-static-${{ hashFiles('.github/workflows/ci.yml', 'platforms/config.sh') }}
72136 restore-keys : |
73- vcpkg-${{ runner.os }}-${{ matrix.arch }}-
137+ vcpkg-${{ runner.os }}-${{ matrix.arch }}-packages-dynamic-
138+
139+ - if : matrix.platform == 'win'
140+ name : Restore vcpkg cache (Windows registry)
141+ uses : actions/cache/restore@v4
142+ with :
143+ path : vcpkg/registry
144+ key : vcpkg-${{ runner.os }}-${{ matrix.arch }}-registry-static-${{ hashFiles('.github/workflows/ci.yml', 'platforms/config.sh') }}
145+ restore-keys : |
146+ vcpkg-${{ runner.os }}-${{ matrix.arch }}-registry-dynamic-
74147
75148 - if : matrix.platform == 'win'
76149 name : Setup vcpkg (Windows)
77150 shell : pwsh
78151 run : |
79152 $root = Join-Path $env:GITHUB_WORKSPACE "vcpkg"
153+ $binaryCache = Join-Path $env:GITHUB_WORKSPACE "vcpkg-binary-cache"
154+ New-Item -ItemType Directory -Force -Path $binaryCache | Out-Null
80155 if (-not (Test-Path "$root\\.git")) {
81156 if (Test-Path $root) {
82157 Remove-Item -Recurse -Force $root
@@ -86,10 +161,120 @@ jobs:
86161 & "$root/bootstrap-vcpkg.bat"
87162 $triplet = if ("${{ matrix.arch }}" -eq "x86") { "x86-windows" } else { "x64-windows" }
88163 $staticTriplet = if ("${{ matrix.arch }}" -eq "x86") { "x86-windows-static" } else { "x64-windows-static" }
89- & "$root/vcpkg.exe" install opencv qtbase --triplet $triplet
90- & "$root/vcpkg.exe" install opencv qtbase --triplet $staticTriplet
91164 "VCPKG_ROOT=$root" | Out-File -FilePath $env:GITHUB_ENV -Append
92165 "VCPKG_DEFAULT_TRIPLET=$triplet" | Out-File -FilePath $env:GITHUB_ENV -Append
166+ "VCPKG_DEFAULT_BINARY_CACHE=$binaryCache" | Out-File -FilePath $env:GITHUB_ENV -Append
167+
168+ - if : matrix.platform == 'win'
169+ name : Restore vcpkg binary cache (Windows)
170+ uses : actions/cache/restore@v4
171+ with :
172+ path : vcpkg-binary-cache
173+ key : vcpkg-bin-${{ runner.os }}-${{ matrix.arch }}-static-${{ hashFiles('.github/workflows/ci.yml', 'platforms/config.sh') }}
174+ restore-keys : |
175+ vcpkg-bin-${{ runner.os }}-${{ matrix.arch }}-dynamic-
176+
177+ - if : matrix.platform == 'win'
178+ name : vcpkg install (Windows dynamic)
179+ shell : pwsh
180+ run : |
181+ $root = Join-Path $env:GITHUB_WORKSPACE "vcpkg"
182+ $env:VCPKG_DEFAULT_BINARY_CACHE = Join-Path $env:GITHUB_WORKSPACE "vcpkg-binary-cache"
183+ $triplet = if ("${{ matrix.arch }}" -eq "x86") { "x86-windows" } else { "x64-windows" }
184+ & "$root/vcpkg.exe" install opencv qtbase --triplet $triplet
185+
186+ - if : matrix.platform == 'win'
187+ name : Save vcpkg cache (Windows installed)
188+ uses : actions/cache/save@v4
189+ with :
190+ path : vcpkg/installed
191+ key : vcpkg-${{ runner.os }}-${{ matrix.arch }}-installed-dynamic-${{ hashFiles('.github/workflows/ci.yml', 'platforms/config.sh') }}
192+
193+ - if : matrix.platform == 'win'
194+ name : Save vcpkg cache (Windows downloads)
195+ uses : actions/cache/save@v4
196+ with :
197+ path : vcpkg/downloads
198+ key : vcpkg-${{ runner.os }}-${{ matrix.arch }}-downloads-dynamic-${{ hashFiles('.github/workflows/ci.yml', 'platforms/config.sh') }}
199+
200+ - if : matrix.platform == 'win'
201+ name : Save vcpkg cache (Windows buildtrees)
202+ uses : actions/cache/save@v4
203+ with :
204+ path : vcpkg/buildtrees
205+ key : vcpkg-${{ runner.os }}-${{ matrix.arch }}-buildtrees-dynamic-${{ hashFiles('.github/workflows/ci.yml', 'platforms/config.sh') }}
206+
207+ - if : matrix.platform == 'win'
208+ name : Save vcpkg cache (Windows packages)
209+ uses : actions/cache/save@v4
210+ with :
211+ path : vcpkg/packages
212+ key : vcpkg-${{ runner.os }}-${{ matrix.arch }}-packages-dynamic-${{ hashFiles('.github/workflows/ci.yml', 'platforms/config.sh') }}
213+
214+ - if : matrix.platform == 'win'
215+ name : Save vcpkg cache (Windows registry)
216+ uses : actions/cache/save@v4
217+ with :
218+ path : vcpkg/registry
219+ key : vcpkg-${{ runner.os }}-${{ matrix.arch }}-registry-dynamic-${{ hashFiles('.github/workflows/ci.yml', 'platforms/config.sh') }}
220+
221+ - if : matrix.platform == 'win'
222+ name : Save vcpkg binary cache (Windows)
223+ uses : actions/cache/save@v4
224+ with :
225+ path : vcpkg-binary-cache
226+ key : vcpkg-bin-${{ runner.os }}-${{ matrix.arch }}-dynamic-${{ hashFiles('.github/workflows/ci.yml', 'platforms/config.sh') }}
227+
228+ - if : matrix.platform == 'win'
229+ name : vcpkg install (Windows static)
230+ shell : pwsh
231+ run : |
232+ $root = Join-Path $env:GITHUB_WORKSPACE "vcpkg"
233+ $env:VCPKG_DEFAULT_BINARY_CACHE = Join-Path $env:GITHUB_WORKSPACE "vcpkg-binary-cache"
234+ $staticTriplet = if ("${{ matrix.arch }}" -eq "x86") { "x86-windows-static" } else { "x64-windows-static" }
235+ & "$root/vcpkg.exe" install opencv qtbase --triplet $staticTriplet
236+
237+ - if : matrix.platform == 'win'
238+ name : Save vcpkg cache (Windows installed, static)
239+ uses : actions/cache/save@v4
240+ with :
241+ path : vcpkg/installed
242+ key : vcpkg-${{ runner.os }}-${{ matrix.arch }}-installed-static-${{ hashFiles('.github/workflows/ci.yml', 'platforms/config.sh') }}
243+
244+ - if : matrix.platform == 'win'
245+ name : Save vcpkg cache (Windows downloads, static)
246+ uses : actions/cache/save@v4
247+ with :
248+ path : vcpkg/downloads
249+ key : vcpkg-${{ runner.os }}-${{ matrix.arch }}-downloads-static-${{ hashFiles('.github/workflows/ci.yml', 'platforms/config.sh') }}
250+
251+ - if : matrix.platform == 'win'
252+ name : Save vcpkg cache (Windows buildtrees, static)
253+ uses : actions/cache/save@v4
254+ with :
255+ path : vcpkg/buildtrees
256+ key : vcpkg-${{ runner.os }}-${{ matrix.arch }}-buildtrees-static-${{ hashFiles('.github/workflows/ci.yml', 'platforms/config.sh') }}
257+
258+ - if : matrix.platform == 'win'
259+ name : Save vcpkg cache (Windows packages, static)
260+ uses : actions/cache/save@v4
261+ with :
262+ path : vcpkg/packages
263+ key : vcpkg-${{ runner.os }}-${{ matrix.arch }}-packages-static-${{ hashFiles('.github/workflows/ci.yml', 'platforms/config.sh') }}
264+
265+ - if : matrix.platform == 'win'
266+ name : Save vcpkg cache (Windows registry, static)
267+ uses : actions/cache/save@v4
268+ with :
269+ path : vcpkg/registry
270+ key : vcpkg-${{ runner.os }}-${{ matrix.arch }}-registry-static-${{ hashFiles('.github/workflows/ci.yml', 'platforms/config.sh') }}
271+
272+ - if : matrix.platform == 'win'
273+ name : Save vcpkg binary cache (Windows static)
274+ uses : actions/cache/save@v4
275+ with :
276+ path : vcpkg-binary-cache
277+ key : vcpkg-bin-${{ runner.os }}-${{ matrix.arch }}-static-${{ hashFiles('.github/workflows/ci.yml', 'platforms/config.sh') }}
93278
94279 - if : matrix.platform == 'win'
95280 name : Add msbuild (Windows)
0 commit comments