Skip to content

Commit 1611da5

Browse files
authored
Merge pull request #2127 from shimat/fix/ci-cache-scope
Reduce pull request cache churn
2 parents d74b74a + f9dcb14 commit 1611da5

3 files changed

Lines changed: 81 additions & 69 deletions

File tree

.github/workflows/docker-test-ubuntu.yml

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,26 @@ name: Docker Test
33
on:
44
pull_request:
55
types: [synchronize, opened]
6+
paths:
7+
- '.dockerignore'
8+
- '.github/workflows/docker-test-ubuntu.yml'
9+
- 'cmake/**'
10+
- 'global.json'
11+
- 'opencv'
12+
- 'opencv_contrib'
13+
- 'packaging/docker/ubuntu24-dotnet10-opencv5.0.0/**'
14+
- 'packaging/docker/ubuntu24-dotnet10-opencv5.0.0-slim/**'
15+
- 'src/**'
16+
- 'test/**'
17+
- 'vcpkg.json'
618
push:
719
branches:
820
- main
921

22+
concurrency:
23+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
24+
cancel-in-progress: true
25+
1026
env:
1127
DEBIAN_FRONTEND: noninteractive
1228
OPENCV_VERSION: 5.0.0
@@ -34,11 +50,9 @@ jobs:
3450
OPENCV_VERSION=${{ env.OPENCV_VERSION }}
3551
outputs: type=cacheonly
3652
cache-from: |
37-
type=gha,scope=full-test-native-${{ github.ref_name }}
3853
type=gha,scope=full-test-native-main
39-
type=gha,scope=full-${{ github.ref_name }}
4054
type=gha,scope=full-main
41-
cache-to: type=gha,mode=min,scope=full-test-native-${{ github.ref_name }}
55+
cache-to: ${{ github.ref == 'refs/heads/main' && 'type=gha,mode=min,scope=full-test-native-main' || '' }}
4256

4357
- name: Test .NET class libraries (full)
4458
uses: docker/build-push-action@v7
@@ -50,11 +64,9 @@ jobs:
5064
OPENCV_VERSION=${{ env.OPENCV_VERSION }}
5165
outputs: type=cacheonly
5266
cache-from: |
53-
type=gha,scope=full-test-dotnet-${{ github.ref_name }}
5467
type=gha,scope=full-test-dotnet-main
55-
type=gha,scope=full-${{ github.ref_name }}
5668
type=gha,scope=full-main
57-
cache-to: type=gha,mode=min,scope=full-test-dotnet-${{ github.ref_name }}
69+
cache-to: ${{ github.ref == 'refs/heads/main' && 'type=gha,mode=min,scope=full-test-dotnet-main' || '' }}
5870

5971
- name: Build with Docker (full)
6072
uses: docker/build-push-action@v7
@@ -64,10 +76,8 @@ jobs:
6476
build-args: |
6577
OPENCV_VERSION=${{ env.OPENCV_VERSION }}
6678
outputs: type=docker,name=shimat/ubuntu24-dotnet10-opencv5.0.0:latest
67-
cache-from: |
68-
type=gha,scope=full-${{ github.ref_name }}
69-
type=gha,scope=full-main
70-
cache-to: type=gha,mode=min,scope=full-${{ github.ref_name }}
79+
cache-from: type=gha,scope=full-main
80+
cache-to: ${{ github.ref == 'refs/heads/main' && 'type=gha,mode=min,scope=full-main' || '' }}
7181

7282
build_slim:
7383
name: Docker (slim)
@@ -89,11 +99,9 @@ jobs:
8999
OPENCV_VERSION=${{ env.OPENCV_VERSION }}
90100
outputs: type=cacheonly
91101
cache-from: |
92-
type=gha,scope=slim-test-native-${{ github.ref_name }}
93102
type=gha,scope=slim-test-native-main
94-
type=gha,scope=slim-${{ github.ref_name }}
95103
type=gha,scope=slim-main
96-
cache-to: type=gha,mode=min,scope=slim-test-native-${{ github.ref_name }}
104+
cache-to: ${{ github.ref == 'refs/heads/main' && 'type=gha,mode=min,scope=slim-test-native-main' || '' }}
97105

98106
- name: Build with Docker (slim)
99107
uses: docker/build-push-action@v7
@@ -103,7 +111,5 @@ jobs:
103111
build-args: |
104112
OPENCV_VERSION=${{ env.OPENCV_VERSION }}
105113
outputs: type=docker,name=shimat/ubuntu24-dotnet10-opencv5.0.0-slim:latest
106-
cache-from: |
107-
type=gha,scope=slim-${{ github.ref_name }}
108-
type=gha,scope=slim-main
109-
cache-to: type=gha,mode=min,scope=slim-${{ github.ref_name }}
114+
cache-from: type=gha,scope=slim-main
115+
cache-to: ${{ github.ref == 'refs/heads/main' && 'type=gha,mode=min,scope=slim-main' || '' }}

.github/workflows/macos.yml

Lines changed: 30 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,27 @@ on:
55

66
pull_request:
77
types: [synchronize, opened, reopened]
8+
paths:
9+
- '.gitmodules'
10+
- '.github/actions/test-rtsp-macos/**'
11+
- '.github/workflows/macos.yml'
12+
- 'cmake/**'
13+
- 'global.json'
14+
- 'opencv'
15+
- 'opencv_contrib'
16+
- 'packaging/nuget/**'
17+
- 'src/**'
18+
- 'test/**'
19+
- 'vcpkg.json'
820

921
push:
1022
branches:
1123
- main
1224

25+
concurrency:
26+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
27+
cancel-in-progress: true
28+
1329
env:
1430
OPENCV_VERSION: 5.0.0
1531
CACHE_VERSION: "1"
@@ -55,7 +71,7 @@ jobs:
5571
uses: actions/cache/restore@v6
5672
with:
5773
path: ${{ github.workspace }}/vcpkg_installed
58-
key: vcpkg-x64-osx-static-${{ hashFiles('vcpkg.json') }}-${{ hashFiles('cmake/triplets/x64-osx-static.cmake') }}-${{ hashFiles('cmake/vcpkg-overlay-ports/libaec/**') }}
74+
key: vcpkg-x64-osx-static-${{ hashFiles('vcpkg.json') }}-${{ hashFiles('cmake/triplets/x64-osx-static.cmake') }}-${{ hashFiles('cmake/vcpkg-overlay-ports/**') }}
5975

6076
- name: Install packages via vcpkg
6177
if: steps.vcpkg-cache.outputs.cache-hit != 'true'
@@ -66,11 +82,11 @@ jobs:
6682
--overlay-ports=${GITHUB_WORKSPACE}/cmake/vcpkg-overlay-ports
6783
6884
- name: Save vcpkg package cache
69-
if: steps.vcpkg-cache.outputs.cache-hit != 'true'
85+
if: github.ref == 'refs/heads/main' && steps.vcpkg-cache.outputs.cache-hit != 'true'
7086
uses: actions/cache/save@v6
7187
with:
7288
path: ${{ github.workspace }}/vcpkg_installed
73-
key: vcpkg-x64-osx-static-${{ hashFiles('vcpkg.json') }}-${{ hashFiles('cmake/triplets/x64-osx-static.cmake') }}-${{ hashFiles('cmake/vcpkg-overlay-ports/libaec/**') }}
89+
key: vcpkg-x64-osx-static-${{ hashFiles('vcpkg.json') }}-${{ hashFiles('cmake/triplets/x64-osx-static.cmake') }}-${{ hashFiles('cmake/vcpkg-overlay-ports/**') }}
7490

7591
# -- OpenCV cache --------------------------------------------------------
7692
- name: Capture OpenCV revisions
@@ -84,19 +100,14 @@ jobs:
84100
uses: actions/cache/restore@v6
85101
with:
86102
path: ${{ github.workspace }}/opencv_artifacts
87-
key: opencv-${{ env.OPENCV_VERSION }}-macos-x64-v${{ env.CACHE_VERSION }}-${{ steps.opencv-revs.outputs.opencv }}-${{ steps.opencv-revs.outputs.contrib }}-${{ hashFiles('.github/workflows/macos.yml', 'vcpkg.json', 'cmake/opencv_build_options.cmake', 'cmake/triplets/x64-osx-static.cmake') }}
103+
key: opencv-${{ env.OPENCV_VERSION }}-macos-x64-v${{ env.CACHE_VERSION }}-${{ steps.opencv-revs.outputs.opencv }}-${{ steps.opencv-revs.outputs.contrib }}-${{ hashFiles('vcpkg.json', 'cmake/opencv_build_options.cmake', 'cmake/opencv_build_options_macos.cmake', 'cmake/triplets/x64-osx-static.cmake', 'cmake/vcpkg-overlay-ports/**') }}
88104

89105
- name: Configure OpenCV
90106
if: steps.opencv-cache.outputs.cache-hit != 'true'
91107
run: |
92-
# Disable the ASM language so OpenCV 5's vendored MLAS turns off and DNN
93-
# falls back to its built-in SGEMM. The MLAS FP16/GQA path references
94-
# MlasHGemmSupported(), which OpenCV 5.0.0 declares and calls but never
95-
# defines, breaking the extern link (same fix as windows.yml / linux-arm64.yml).
96-
# Image codecs come from vcpkg here, so no other ASM language is needed.
97108
cmake \
98109
-G Ninja \
99-
-C cmake/opencv_build_options.cmake \
110+
-C cmake/opencv_build_options_macos.cmake \
100111
-S opencv \
101112
-B opencv/build \
102113
-D OPENCV_EXTRA_MODULES_PATH=${GITHUB_WORKSPACE}/opencv_contrib/modules \
@@ -105,20 +116,6 @@ jobs:
105116
-D VCPKG_TARGET_TRIPLET=x64-osx-static \
106117
-D VCPKG_INSTALLED_DIR=${GITHUB_WORKSPACE}/vcpkg_installed \
107118
-D CMAKE_OSX_ARCHITECTURES=x86_64 \
108-
-D CMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
109-
-D BUILD_JPEG=OFF \
110-
-D BUILD_PNG=OFF \
111-
-D BUILD_TIFF=OFF \
112-
-D BUILD_WEBP=OFF \
113-
-D BUILD_ZLIB=ON \
114-
-D WITH_TBB=OFF \
115-
-D WITH_OPENEXR=OFF \
116-
-D WITH_JASPER=OFF \
117-
-D WITH_OPENGL=OFF \
118-
-D WITH_VA=OFF \
119-
-D WITH_VA_INTEL=OFF \
120-
-D OPENCV_FFMPEG_SKIP_BUILD_CHECK=ON \
121-
-D CMAKE_ASM_COMPILER="" \
122119
2>&1 | tee /tmp/opencv-configure.log
123120
124121
- name: Verify OpenCV cmake features
@@ -149,11 +146,11 @@ jobs:
149146
du -sh ${GITHUB_WORKSPACE}/opencv_artifacts/*/
150147
151148
- name: Save OpenCV cache
152-
if: steps.opencv-cache.outputs.cache-hit != 'true'
149+
if: github.ref == 'refs/heads/main' && steps.opencv-cache.outputs.cache-hit != 'true'
153150
uses: actions/cache/save@v6
154151
with:
155152
path: ${{ github.workspace }}/opencv_artifacts
156-
key: opencv-${{ env.OPENCV_VERSION }}-macos-x64-v${{ env.CACHE_VERSION }}-${{ steps.opencv-revs.outputs.opencv }}-${{ steps.opencv-revs.outputs.contrib }}-${{ hashFiles('.github/workflows/macos.yml', 'vcpkg.json', 'cmake/opencv_build_options.cmake', 'cmake/triplets/x64-osx-static.cmake') }}
153+
key: opencv-${{ env.OPENCV_VERSION }}-macos-x64-v${{ env.CACHE_VERSION }}-${{ steps.opencv-revs.outputs.opencv }}-${{ steps.opencv-revs.outputs.contrib }}-${{ hashFiles('vcpkg.json', 'cmake/opencv_build_options.cmake', 'cmake/opencv_build_options_macos.cmake', 'cmake/triplets/x64-osx-static.cmake', 'cmake/vcpkg-overlay-ports/**') }}
157154

158155
# -- OpenCvSharpExtern ---------------------------------------------------
159156
- name: Build OpenCvSharpExtern
@@ -216,7 +213,7 @@ jobs:
216213
uses: actions/cache/restore@v6
217214
with:
218215
path: ${{ github.workspace }}/vcpkg_installed
219-
key: vcpkg-arm64-osx-static-${{ hashFiles('vcpkg.json') }}-${{ hashFiles('cmake/triplets/arm64-osx-static.cmake') }}-${{ hashFiles('cmake/vcpkg-overlay-ports/libaec/**') }}
216+
key: vcpkg-arm64-osx-static-${{ hashFiles('vcpkg.json') }}-${{ hashFiles('cmake/triplets/arm64-osx-static.cmake') }}-${{ hashFiles('cmake/vcpkg-overlay-ports/**') }}
220217

221218
- name: Install packages via vcpkg
222219
if: steps.vcpkg-cache.outputs.cache-hit != 'true'
@@ -227,11 +224,11 @@ jobs:
227224
--overlay-ports=${GITHUB_WORKSPACE}/cmake/vcpkg-overlay-ports
228225
229226
- name: Save vcpkg package cache
230-
if: steps.vcpkg-cache.outputs.cache-hit != 'true'
227+
if: github.ref == 'refs/heads/main' && steps.vcpkg-cache.outputs.cache-hit != 'true'
231228
uses: actions/cache/save@v6
232229
with:
233230
path: ${{ github.workspace }}/vcpkg_installed
234-
key: vcpkg-arm64-osx-static-${{ hashFiles('vcpkg.json') }}-${{ hashFiles('cmake/triplets/arm64-osx-static.cmake') }}-${{ hashFiles('cmake/vcpkg-overlay-ports/libaec/**') }}
231+
key: vcpkg-arm64-osx-static-${{ hashFiles('vcpkg.json') }}-${{ hashFiles('cmake/triplets/arm64-osx-static.cmake') }}-${{ hashFiles('cmake/vcpkg-overlay-ports/**') }}
235232

236233
# -- OpenCV cache --------------------------------------------------------
237234
- name: Capture OpenCV revisions
@@ -245,19 +242,14 @@ jobs:
245242
uses: actions/cache/restore@v6
246243
with:
247244
path: ${{ github.workspace }}/opencv_artifacts
248-
key: opencv-${{ env.OPENCV_VERSION }}-macos-arm64-v${{ env.CACHE_VERSION }}-${{ steps.opencv-revs.outputs.opencv }}-${{ steps.opencv-revs.outputs.contrib }}-${{ hashFiles('.github/workflows/macos.yml', 'vcpkg.json', 'cmake/opencv_build_options.cmake', 'cmake/triplets/arm64-osx-static.cmake') }}
245+
key: opencv-${{ env.OPENCV_VERSION }}-macos-arm64-v${{ env.CACHE_VERSION }}-${{ steps.opencv-revs.outputs.opencv }}-${{ steps.opencv-revs.outputs.contrib }}-${{ hashFiles('vcpkg.json', 'cmake/opencv_build_options.cmake', 'cmake/opencv_build_options_macos.cmake', 'cmake/triplets/arm64-osx-static.cmake', 'cmake/vcpkg-overlay-ports/**') }}
249246

250247
- name: Configure OpenCV
251248
if: steps.opencv-cache.outputs.cache-hit != 'true'
252249
run: |
253-
# Disable the ASM language so OpenCV 5's vendored MLAS turns off and DNN
254-
# falls back to its built-in SGEMM. The MLAS FP16/GQA path references
255-
# MlasHGemmSupported(), which OpenCV 5.0.0 declares and calls but never
256-
# defines, breaking the extern link (same fix as windows.yml / linux-arm64.yml).
257-
# Image codecs come from vcpkg here, so no other ASM language is needed.
258250
cmake \
259251
-G Ninja \
260-
-C cmake/opencv_build_options.cmake \
252+
-C cmake/opencv_build_options_macos.cmake \
261253
-S opencv \
262254
-B opencv/build \
263255
-D OPENCV_EXTRA_MODULES_PATH=${GITHUB_WORKSPACE}/opencv_contrib/modules \
@@ -266,20 +258,6 @@ jobs:
266258
-D VCPKG_TARGET_TRIPLET=arm64-osx-static \
267259
-D VCPKG_INSTALLED_DIR=${GITHUB_WORKSPACE}/vcpkg_installed \
268260
-D CMAKE_OSX_ARCHITECTURES=arm64 \
269-
-D CMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
270-
-D BUILD_JPEG=OFF \
271-
-D BUILD_PNG=OFF \
272-
-D BUILD_TIFF=OFF \
273-
-D BUILD_WEBP=OFF \
274-
-D BUILD_ZLIB=ON \
275-
-D WITH_TBB=OFF \
276-
-D WITH_OPENEXR=OFF \
277-
-D WITH_JASPER=OFF \
278-
-D WITH_OPENGL=OFF \
279-
-D WITH_VA=OFF \
280-
-D WITH_VA_INTEL=OFF \
281-
-D OPENCV_FFMPEG_SKIP_BUILD_CHECK=ON \
282-
-D CMAKE_ASM_COMPILER="" \
283261
2>&1 | tee /tmp/opencv-configure.log
284262
285263
- name: Verify OpenCV cmake features
@@ -310,11 +288,11 @@ jobs:
310288
du -sh ${GITHUB_WORKSPACE}/opencv_artifacts/*/
311289
312290
- name: Save OpenCV cache
313-
if: steps.opencv-cache.outputs.cache-hit != 'true'
291+
if: github.ref == 'refs/heads/main' && steps.opencv-cache.outputs.cache-hit != 'true'
314292
uses: actions/cache/save@v6
315293
with:
316294
path: ${{ github.workspace }}/opencv_artifacts
317-
key: opencv-${{ env.OPENCV_VERSION }}-macos-arm64-v${{ env.CACHE_VERSION }}-${{ steps.opencv-revs.outputs.opencv }}-${{ steps.opencv-revs.outputs.contrib }}-${{ hashFiles('.github/workflows/macos.yml', 'vcpkg.json', 'cmake/opencv_build_options.cmake', 'cmake/triplets/arm64-osx-static.cmake') }}
295+
key: opencv-${{ env.OPENCV_VERSION }}-macos-arm64-v${{ env.CACHE_VERSION }}-${{ steps.opencv-revs.outputs.opencv }}-${{ steps.opencv-revs.outputs.contrib }}-${{ hashFiles('vcpkg.json', 'cmake/opencv_build_options.cmake', 'cmake/opencv_build_options_macos.cmake', 'cmake/triplets/arm64-osx-static.cmake', 'cmake/vcpkg-overlay-ports/**') }}
318296

319297
# -- OpenCvSharpExtern ---------------------------------------------------
320298
- name: Build OpenCvSharpExtern
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# CMake initial cache for macOS OpenCV builds.
2+
# Keep macOS-specific options here so the workflow can include every effective
3+
# build option in the OpenCV artifact cache key.
4+
5+
include("${CMAKE_CURRENT_LIST_DIR}/opencv_build_options.cmake")
6+
7+
set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0 CACHE STRING "" FORCE)
8+
9+
# Image codecs are provided by vcpkg on macOS.
10+
set(BUILD_JPEG OFF CACHE BOOL "" FORCE)
11+
set(BUILD_PNG OFF CACHE BOOL "" FORCE)
12+
set(BUILD_TIFF OFF CACHE BOOL "" FORCE)
13+
set(BUILD_WEBP OFF CACHE BOOL "" FORCE)
14+
set(BUILD_ZLIB ON CACHE BOOL "" FORCE)
15+
16+
set(WITH_TBB OFF CACHE BOOL "" FORCE)
17+
set(WITH_OPENEXR OFF CACHE BOOL "" FORCE)
18+
set(WITH_JASPER OFF CACHE BOOL "" FORCE)
19+
set(WITH_OPENGL OFF CACHE BOOL "" FORCE)
20+
set(WITH_VA OFF CACHE BOOL "" FORCE)
21+
set(WITH_VA_INTEL OFF CACHE BOOL "" FORCE)
22+
23+
set(OPENCV_FFMPEG_SKIP_BUILD_CHECK ON CACHE BOOL "" FORCE)
24+
25+
# Disable the ASM language so OpenCV 5's vendored MLAS turns off and DNN falls
26+
# back to its built-in SGEMM. The MLAS FP16/GQA path references
27+
# MlasHGemmSupported(), which OpenCV 5.0.0 declares and calls but never defines.
28+
set(CMAKE_ASM_COMPILER "" CACHE FILEPATH "" FORCE)

0 commit comments

Comments
 (0)