Skip to content

Commit d5ec0bb

Browse files
authored
Refactor CI workflows and improve test configuration (#9010)
* Add Halide_BUILDING_IN_CI feature * On CI, only build simd_op_check tests for host target * Move "Check CMake file lists" to ubuntu-slim runner * Consolidate test sources; use multithreaded label for RUN_SERIAL * Correct multithreaded test groupings * Skip gpu_metal_completion_handler_error_check on Apple Silicon * Move clang-tidy to separate workflow and filter paths * Appease clang-format
1 parent 6694e5d commit d5ec0bb

43 files changed

Lines changed: 302 additions & 302 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Clang-Tidy
2+
on:
3+
pull_request:
4+
types: [ opened, synchronize, reopened ]
5+
paths:
6+
- '**.h'
7+
- '**.c'
8+
- '**.cpp'
9+
- 'run-clang-tidy.sh'
10+
- '**.clang-tidy'
11+
- '.github/workflows/presubmit-clang-tidy.yml'
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
15+
cancel-in-progress: true
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
check_clang_tidy:
22+
name: Check clang-tidy
23+
runs-on: macos-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
# We intentionally don't use VCPKG here so that we get some
28+
# notification that the ecosystem is moving on without us.
29+
- name: Install clang-tidy & dependencies
30+
run: brew install flatbuffers llvm@21 lld@21 pybind11 wabt
31+
32+
- name: Run clang-tidy
33+
run: ./run-clang-tidy.sh
34+
env:
35+
CLANG_TIDY_LLVM_INSTALL_DIR: /opt/homebrew/opt/llvm@21

.github/workflows/presubmit.yml

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,67 +4,55 @@ on:
44
# We don't want 'review_requested' (that's redundant to the ones below for our purposes)
55
pull_request:
66
types: [ opened, synchronize, reopened ]
7-
paths:
8-
- '**.h'
9-
- '**.c'
10-
- '**.cpp'
11-
- '**CMakeLists.txt'
12-
- '**.cmake'
13-
- 'run-clang-tidy.sh'
14-
- 'run-clang-format.sh'
15-
- '.github/workflows/**'
16-
- '**.clang-tidy'
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
1711

1812
permissions:
1913
contents: read
2014

2115
jobs:
2216
check_clang_format:
23-
name: Check clang-format and ruff
24-
runs-on: macos-14
17+
name: Check clang-format
18+
runs-on: ubuntu-slim
2519
steps:
2620
- uses: actions/checkout@v4
2721

2822
- name: Install clang-format
29-
run: brew install llvm@21
23+
run: |
24+
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
25+
echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-21 main" | sudo tee /etc/apt/sources.list.d/llvm.list
26+
sudo apt-get update
27+
sudo apt-get install -y clang-format-21
3028
3129
- name: Check clang-format
3230
run: ./run-clang-format.sh -c
3331
env:
34-
CLANG_FORMAT_LLVM_INSTALL_DIR: /opt/homebrew/opt/llvm@21
32+
CLANG_FORMAT_LLVM_INSTALL_DIR: /usr/lib/llvm-21
3533

36-
- uses: astral-sh/ruff-action@v3
37-
38-
check_clang_tidy:
39-
name: Check clang-tidy
40-
runs-on: macos-14
34+
check_ruff:
35+
name: Check ruff
36+
runs-on: ubuntu-slim
4137
steps:
4238
- uses: actions/checkout@v4
43-
44-
# We intentionally don't use VCPKG here so that we get some
45-
# notification that the ecosystem is moving on without us.
46-
- name: Install clang-tidy & dependencies
47-
run: brew install flatbuffers llvm@21 lld@21 pybind11 wabt
48-
49-
- name: Run clang-tidy
50-
run: ./run-clang-tidy.sh
51-
env:
52-
CLANG_TIDY_LLVM_INSTALL_DIR: /opt/homebrew/opt/llvm@21
39+
- uses: astral-sh/ruff-action@v3
5340

5441
check_cmake_file_lists:
5542
name: Check CMake file lists
56-
runs-on: ubuntu-22.04
43+
runs-on: ubuntu-slim
5744
steps:
5845
- uses: actions/checkout@v4
5946
- name: Run test sources check
6047
run: |
6148
check_dir() {
6249
local dir="$1"
50+
echo "Checking $dir"
6351
(
6452
cd "$dir" &&
6553
comm -23 \
6654
<(find . -maxdepth 1 -type f \( -name '*.c' -o -name '*.cpp' \) -printf '%f\n' | sort) \
67-
<(grep -P '^\s*#?\s*[A-Za-z0-9_.]+$' CMakeLists.txt | tr -d '# ' | sort) \
55+
<(grep -oP '\b[A-Za-z0-9_]+\.(?:cpp|c)\b' CMakeLists.txt | sort -u) \
6856
| tee missing_files &&
6957
[ ! -s missing_files ]
7058
)

.github/workflows/testing-arm-linux.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ name: ARM Linux
33
on:
44
pull_request:
55
types: [ opened, synchronize, reopened ]
6+
paths-ignore:
7+
- "doc/**"
8+
- "README.md"
9+
- "CODE_OF_CONDUCT.md"
10+
- "LICENSE.txt"
11+
- ".gitignore"
12+
- ".gitattributes"
13+
- ".gitmodules"
14+
- ".lldbinit"
15+
- ".github/**"
16+
- "!.github/workflows/testing-arm-linux.yml"
17+
- "packaging/**"
18+
- "Makefile"
19+
- "Makefile.inc"
620
workflow_dispatch:
721

822
concurrency:

.github/workflows/testing-linux.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ name: Linux
33
on:
44
pull_request:
55
types: [ opened, synchronize, reopened ]
6+
paths-ignore:
7+
- "doc/**"
8+
- "README.md"
9+
- "CODE_OF_CONDUCT.md"
10+
- "LICENSE.txt"
11+
- ".gitignore"
12+
- ".gitattributes"
13+
- ".gitmodules"
14+
- ".lldbinit"
15+
- ".github/**"
16+
- "!.github/workflows/testing-linux.yml"
17+
- "packaging/**"
18+
- "Makefile"
19+
- "Makefile.inc"
620
workflow_dispatch:
721

822
concurrency:

.github/workflows/testing-make.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ on:
2121
- "python_bindings/**"
2222

2323
- "pyproject.toml"
24-
- "uv.lock"
24+
# Don't ignore uv.lock as it influences dependency resolution
2525

2626
- "README.md"
2727
- "CODE_OF_CONDUCT.md"
@@ -30,11 +30,18 @@ on:
3030
- ".gitattributes"
3131
- ".gitmodules"
3232
- ".lldbinit"
33+
- "run-clang-format.sh"
34+
- "run-clang-tidy.sh"
35+
- "**.clang-tidy"
36+
- "**.py"
3337

3438
concurrency:
3539
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
3640
cancel-in-progress: true
3741

42+
permissions:
43+
contents: read
44+
3845
jobs:
3946
build_make:
4047
name: build on ${{ matrix.os }}

.github/workflows/testing-windows.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ name: Windows
33
on:
44
pull_request:
55
types: [ opened, synchronize, reopened ]
6+
paths-ignore:
7+
- "doc/**"
8+
- "README.md"
9+
- "CODE_OF_CONDUCT.md"
10+
- "LICENSE.txt"
11+
- ".gitignore"
12+
- ".gitattributes"
13+
- ".gitmodules"
14+
- ".lldbinit"
15+
- ".github/**"
16+
- "!.github/workflows/testing-windows.yml"
17+
- "packaging/**"
18+
- "Makefile"
19+
- "Makefile.inc"
620
workflow_dispatch:
721

822
concurrency:

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ find_package(PNG)
206206
##
207207
# Optional features. These settings are defined early so that subdirectories see a consistent view
208208

209+
Halide_feature(Halide_BUILDING_IN_CI "Enable if building in CI" OFF ADVANCED)
210+
209211
Halide_feature(Halide_ENABLE_EXCEPTIONS "Enable exceptions in Halide" ON)
210212
Halide_feature(Halide_ENABLE_RTTI "Enable RTTI in Halide" ON
211213
DEPENDS LLVM_ENABLE_RTTI)

CMakePresets.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
2424
"FETCHCONTENT_FULLY_DISCONNECTED": "ON",
2525
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/cmake/toolchain.${presetName}.cmake",
26-
"VCPKG_MANIFEST_FEATURES": "developer"
26+
"VCPKG_MANIFEST_FEATURES": "developer",
27+
"Halide_BUILDING_IN_CI": "ON"
2728
}
2829
},
2930
{

Makefile

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ TEST_CXX_FLAGS += -DLLVM_VERSION=$(LLVM_VERSION_TIMES_10)
281281
TEST_CXX_FLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
282282

283283
# In the tests, enable the debug() and internal_assert() macros
284-
TEST_CXX_FLAGS += -DHALIDE_KEEP_MACROS
284+
TEST_CXX_FLAGS += -DHALIDE_KEEP_MACROS=
285285

286286
# gcc 4.8 fires a bogus warning on old versions of png.h
287287
ifneq (,$(findstring g++,$(CXX_VERSION)))
@@ -1282,8 +1282,9 @@ GENERATOR_EXTERNAL_TESTS := $(shell ls $(ROOT_DIR)/test/generator/*test.cpp)
12821282
GENERATOR_EXTERNAL_TEST_GENERATOR := $(shell ls $(ROOT_DIR)/test/generator/*_generator.cpp)
12831283
TUTORIALS = $(filter-out %_generate.cpp, $(shell ls $(ROOT_DIR)/tutorial/*.cpp))
12841284
MULLAPUDI2016_TESTS = $(shell ls $(ROOT_DIR)/test/autoschedulers/mullapudi2016/*.cpp)
1285-
LI2018_TESTS = $(shell ls $(ROOT_DIR)/test/autoschedulers/li2018/test.cpp)
1286-
ADAMS2019_TESTS = $(shell ls $(ROOT_DIR)/test/autoschedulers/adams2019/test.cpp)
1285+
LI2018_TESTS = $(filter-out %_generator.cpp, $(shell ls $(ROOT_DIR)/test/autoschedulers/li2018/*.cpp))
1286+
ADAMS2019_TESTS = $(filter-out %_generator.cpp, $(shell ls $(ROOT_DIR)/test/autoschedulers/adams2019/*.cpp))
1287+
COMMON_AUTOSCHEDULER_TESTS = $(shell ls $(ROOT_DIR)/test/autoschedulers/common/*.cpp)
12871288

12881289
test_correctness: $(CORRECTNESS_TESTS:$(ROOT_DIR)/test/correctness/%.cpp=quiet_correctness_%) $(CORRECTNESS_TESTS:$(ROOT_DIR)/test/correctness/%.c=quiet_correctness_%)
12891290
test_performance: $(PERFORMANCE_TESTS:$(ROOT_DIR)/test/performance/%.cpp=performance_%)
@@ -1293,7 +1294,7 @@ test_runtime: $(RUNTIME_TESTS:$(ROOT_DIR)/test/runtime/%.cpp=runtime_%)
12931294
test_tutorial: $(TUTORIALS:$(ROOT_DIR)/tutorial/%.cpp=tutorial_%)
12941295
test_valgrind: $(CORRECTNESS_TESTS:$(ROOT_DIR)/test/correctness/%.cpp=valgrind_%)
12951296
test_avx512: $(CORRECTNESS_TESTS:$(ROOT_DIR)/test/correctness/%.cpp=avx512_%)
1296-
test_autoschedulers: test_mullapudi2016 test_li2018 test_adams2019
1297+
test_autoschedulers: test_mullapudi2016 test_li2018 test_adams2019 test_common_autoscheduler
12971298
test_auto_schedule: test_autoschedulers
12981299

12991300
.PHONY: test_correctness_multi_gpu
@@ -1389,7 +1390,8 @@ build_tests: $(CORRECTNESS_TESTS:$(ROOT_DIR)/test/correctness/%.cpp=$(BIN_DIR)/c
13891390
$(GENERATOR_EXTERNAL_TESTS:$(ROOT_DIR)/test/generator/%_jittest.cpp=$(BIN_DIR)/generator_jit_%) \
13901391
$(MULLAPUDI2016_TESTS:$(ROOT_DIR)/test/autoschedulers/mullapudi2016/%.cpp=$(BIN_DIR)/mullapudi2016_%) \
13911392
$(LI2018_TESTS:$(ROOT_DIR)/test/autoschedulers/li2018/%.cpp=$(BIN_DIR)/li2018_%) \
1392-
$(ADAMS2019_TESTS:$(ROOT_DIR)/test/autoschedulers/adams2019/%.cpp=$(BIN_DIR)/adams2019_%)
1393+
$(ADAMS2019_TESTS:$(ROOT_DIR)/test/autoschedulers/adams2019/%.cpp=$(BIN_DIR)/adams2019_%) \
1394+
$(COMMON_AUTOSCHEDULER_TESTS:$(ROOT_DIR)/test/autoschedulers/common/%.cpp=$(BIN_DIR)/common_autoscheduler_%)
13931395

13941396
clean_generator:
13951397
rm -rf $(BIN_DIR)/*.generator
@@ -1499,9 +1501,15 @@ $(BIN_DIR)/mullapudi2016_%: $(ROOT_DIR)/test/autoschedulers/mullapudi2016/%.cpp
14991501
$(BIN_DIR)/li2018_%: $(ROOT_DIR)/test/autoschedulers/li2018/%.cpp $(TEST_DEPS)
15001502
$(CXX) $(TEST_CXX_FLAGS) $(OPTIMIZE_FOR_BUILD_TIME) $< -I$(INCLUDE_DIR) $(TEST_LD_FLAGS) -o $@
15011503

1504+
$(BIN_DIR)/adams2019_test_function_dag: $(ROOT_DIR)/test/autoschedulers/adams2019/test_function_dag.cpp $(SRC_DIR)/autoschedulers/adams2019/FunctionDAG.cpp $(SRC_DIR)/autoschedulers/common/ASLog.cpp $(TEST_DEPS)
1505+
$(CXX) $(TEST_CXX_FLAGS) $(OPTIMIZE_FOR_BUILD_TIME) $< $(SRC_DIR)/autoschedulers/adams2019/FunctionDAG.cpp $(SRC_DIR)/autoschedulers/common/ASLog.cpp -I$(INCLUDE_DIR) -I$(SRC_DIR)/autoschedulers/adams2019 -I$(SRC_DIR)/autoschedulers/common $(TEST_LD_FLAGS) -o $@
1506+
15021507
$(BIN_DIR)/adams2019_%: $(ROOT_DIR)/test/autoschedulers/adams2019/%.cpp $(TEST_DEPS)
15031508
$(CXX) $(TEST_CXX_FLAGS) $(OPTIMIZE_FOR_BUILD_TIME) $< -I$(INCLUDE_DIR) $(TEST_LD_FLAGS) -o $@
15041509

1510+
$(BIN_DIR)/common_autoscheduler_%: $(ROOT_DIR)/test/autoschedulers/common/%.cpp $(TEST_DEPS)
1511+
$(CXX) $(TEST_CXX_FLAGS) $(OPTIMIZE_FOR_BUILD_TIME) $< -I$(INCLUDE_DIR) -I$(SRC_DIR)/autoschedulers/common $(TEST_LD_FLAGS) -o $@
1512+
15051513
# TODO(srj): this doesn't auto-delete, why not?
15061514
.INTERMEDIATE: $(BIN_DIR)/%.generator
15071515

@@ -2141,6 +2149,18 @@ adams2019_test: $(BIN_DIR)/adams2019_test $(BIN_ADAMS2019) $(SRC_DIR)/autoschedu
21412149
cd $(TMP_DIR) ; $(CURDIR)/$< $(realpath $(BIN_ADAMS2019)) $(realpath $(SRC_DIR)/autoschedulers/adams2019/baseline.weights)
21422150
@-echo
21432151

2152+
adams2019_test_function_dag: $(BIN_DIR)/adams2019_test_function_dag
2153+
@-mkdir -p $(TMP_DIR)
2154+
cd $(TMP_DIR) ; $(CURDIR)/$<
2155+
@-echo
2156+
2157+
test_common_autoscheduler: $(COMMON_AUTOSCHEDULER_TESTS:$(ROOT_DIR)/test/autoschedulers/common/%.cpp=common_autoscheduler_%)
2158+
2159+
common_autoscheduler_%: $(BIN_DIR)/common_autoscheduler_%
2160+
@-mkdir -p $(TMP_DIR)
2161+
cd $(TMP_DIR) ; $(CURDIR)/$<
2162+
@-echo
2163+
21442164
time_compilation_test_%: $(BIN_DIR)/test_%
21452165
$(TIME_COMPILATION) compile_times_correctness.csv make -f $(THIS_MAKEFILE) $(@:time_compilation_test_%=test_%)
21462166

@@ -2165,7 +2185,6 @@ TEST_APPS=\
21652185
local_laplacian \
21662186
max_filter \
21672187
nl_means \
2168-
onnx \
21692188
resize \
21702189
resnet_50 \
21712190
stencil_chain \

apps/onnx/Makefile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ PROTOC := $(shell which protoc)
1212

1313
ifdef PROTOC
1414

15+
PROTOC_PREFIX := $(dir $(PROTOC))..
16+
PROTOBUF_PKG_CONFIG := PKG_CONFIG_PATH=$(PROTOC_PREFIX)/lib/pkgconfig pkg-config protobuf-lite
17+
1518
CXXFLAGS += -DGOOGLE_PROTOBUF_NO_RTTI -Wno-sign-compare -Wno-unused-but-set-variable
16-
CXXFLAGS += -I$(dir $(PROTOC))../include
17-
LDFLAGS += -L$(dir $(PROTOC))../lib
18-
LDFLAGS += $(shell pkg-config protobuf-lite --libs)
19+
CXXFLAGS += $(shell $(PROTOBUF_PKG_CONFIG) --cflags)
20+
LDFLAGS += $(shell $(PROTOBUF_PKG_CONFIG) --libs)
1921

2022
# Copy onnx.proto to $(BIN)
2123
$(BIN)/%/onnx/onnx.proto:
@@ -27,7 +29,7 @@ $(BIN)/%/onnx/onnx.proto:
2729
fi
2830

2931
# protoc generates two files
30-
$(BIN)/%/onnx/onnx.pb.cc: $(BIN)/%/onnx/onnx.proto
32+
$(BIN)/%/onnx/onnx.pb.cc: $(BIN)/%/onnx/onnx.proto $(PROTOC)
3133
@sed -i -e 's/package onnx;/package onnx;option optimize_for = LITE_RUNTIME;/g' $<
3234
@mkdir -p $(@D)
3335
$(PROTOC) --cpp_out=$(@D) --proto_path=$(dir $<) $<
@@ -100,15 +102,14 @@ PY_MODEL_EXT = model_cpp$(PY_EXT)
100102
PYCXXFLAGS = $(PYBIND11_CFLAGS) $(CXXFLAGS) -Wno-deprecated-register
101103

102104
# Python extension for HalideModel
103-
$(BIN)/%/$(PY_MODEL_EXT): model.cpp $(BIN)/%/oclib.a
105+
$(BIN)/%/$(PY_MODEL_EXT): model.cpp $(BIN)/%/oclib.a | $(BIN)/%/onnx/onnx_pb.h
104106
$(CXX) $(PYCXXFLAGS) -Wall -shared -fPIC -I$(BIN)/$* $^ $(LIBHALIDE_LDFLAGS) -o $@ $(LDFLAGS)
105107

106-
107108
model_test: $(BIN)/$(HL_TARGET)/$(PY_MODEL_EXT)
108-
PYTHONPATH="$(BIN)/$(HL_TARGET)/:$$PYTHONPATH" $(PYTHON) -m unittest model_test.py -v
109+
PYTHONPATH="$(BIN)/$(HL_TARGET)/:$$PYTHONPATH" DYLD_LIBRARY_PATH="$(PROTOC_PREFIX)/lib:$$DYLD_LIBRARY_PATH" $(PYTHON) -m unittest model_test.py -v
109110

110111
halide_as_onnx_backend_test: $(BIN)/$(HL_TARGET)/$(PY_MODEL_EXT)
111-
PYTHONPATH="$(BIN)/$(HL_TARGET)/:$$PYTHONPATH" $(PYTHON) -m unittest halide_as_onnx_backend_test.py -v
112+
PYTHONPATH="$(BIN)/$(HL_TARGET)/:$$PYTHONPATH" DYLD_LIBRARY_PATH="$(PROTOC_PREFIX)/lib:$$DYLD_LIBRARY_PATH" $(PYTHON) -m unittest halide_as_onnx_backend_test.py -v
112113

113114
# No Protoc
114115
else

0 commit comments

Comments
 (0)