Skip to content

Commit 7f4206a

Browse files
committed
fix CI scripts
1 parent f453430 commit 7f4206a

File tree

2 files changed

+36
-38
lines changed

2 files changed

+36
-38
lines changed

.github/workflows/linters.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
- name: Install dependencies
4949
run: |
5050
sudo apt-get update -y
51-
sudo apt-get install -y libssl-dev cmake curl wget gnupg2 libcurl4-openssl-dev libprotobuf-dev libgrpc-dev gdb
51+
sudo apt-get install -y libssl-dev cmake curl wget gnupg2 libcurl4-openssl-dev libprotobuf-dev libgrpc-dev gdb protobuf-compiler
5252
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo gpg --dearmor --output /etc/apt/keyrings/llvm-snapshot.gpg
5353
sudo bash -c "echo 'deb [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] https://apt.llvm.org/noble/ llvm-toolchain-noble-${LLVM_VERSION} main' >> /etc/apt/sources.list"
5454
sudo apt-get update -y
@@ -75,7 +75,7 @@ jobs:
7575
- name: Install dependencies
7676
run: |
7777
sudo apt-get update -y
78-
sudo apt-get install -y libssl-dev cmake curl wget gnupg2 clang clang-tools cppcheck libcurl4-openssl-dev libprotobuf-dev libgrpc-dev gdb
78+
sudo apt-get install -y libssl-dev cmake curl wget gnupg2 clang clang-tools cppcheck libcurl4-openssl-dev libprotobuf-dev libgrpc-dev gdb protobuf-compiler
7979
- name: Run cppcheck
8080
run: ./bin/check-cppcheck
8181

@@ -88,7 +88,7 @@ jobs:
8888
- name: Install dependencies
8989
run: |
9090
sudo apt-get update -y
91-
sudo apt-get install -y libssl-dev cmake curl wget gnupg2 clang clang-tools clang-tidy libcurl4-openssl-dev libprotobuf-dev libgrpc-dev gdb
91+
sudo apt-get install -y libssl-dev cmake curl wget gnupg2 clang clang-tools clang-tidy libcurl4-openssl-dev libprotobuf-dev libgrpc-dev gdb protobuf-compiler
9292
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo gpg --dearmor --output /etc/apt/keyrings/llvm-snapshot.gpg
9393
sudo bash -c "echo 'deb [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] https://apt.llvm.org/noble/ llvm-toolchain-noble-${LLVM_VERSION} main' >> /etc/apt/sources.list"
9494
sudo apt-get update -y

bin/validate-test-labels

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,50 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
23

3-
require 'find'
4-
require 'set'
4+
require "find"
55

6-
ALLOWED_LABELS = [
7-
'unit',
8-
'integration',
9-
'benchmark',
10-
'transactions',
6+
ALLOWED_LABELS = %w[
7+
unit
8+
integration
9+
benchmark
10+
transactions
1111
].freeze
1212

13-
test_dir = File.expand_path('../test', __dir__)
13+
test_dir = File.expand_path("../test", __dir__)
1414
tests_missing_label = []
15-
invalid_labels = Set[]
15+
tests_missing_allowed_label = []
1616

1717
Find.find(test_dir) do |path|
18-
next unless File.file?(path)
19-
next unless File.basename(path).start_with?('test_')
20-
content = File.read(path)
21-
content.delete("\n").scan(/TEST_CASE\(("(.*?)")\)/) do |match|
22-
labels = match[0].scan(/\[(.*?)\]/)
23-
if labels.empty?
24-
tests_missing_label << "#{match[0]} (#{path})"
25-
else
26-
labels.flatten.each do |label|
27-
unless ALLOWED_LABELS.include?(label)
28-
invalid_labels << label
29-
end
30-
end
31-
end
18+
next unless File.file?(path)
19+
next unless File.basename(path).start_with?("test_")
20+
21+
content = File.read(path)
22+
content.delete("\n").scan(/TEST_CASE\(("(.*?)")\)/) do |match|
23+
test_name = "#{match[0]} (#{path})"
24+
labels = match[0].scan(/\[(.*?)\]/)
25+
if labels.empty?
26+
tests_missing_label << test_name
27+
elsif !labels.flatten.intersect?(ALLOWED_LABELS)
28+
tests_missing_allowed_label << test_name
3229
end
30+
end
3331
end
3432

3533
unless tests_missing_label.empty?
36-
puts "Tests missing label:"
37-
tests_missing_label.each do |test|
38-
puts " #{test}"
39-
end
34+
puts "Tests missing label:"
35+
tests_missing_label.each do |test|
36+
puts " #{test}"
37+
end
4038
end
4139

42-
unless invalid_labels.empty?
43-
puts "Invalid labels found:"
44-
invalid_labels.each do |label|
45-
puts " #{label}"
46-
end
40+
unless tests_missing_allowed_label.empty?
41+
puts "Tests have labels, but missing allowed ones:"
42+
tests_missing_allowed_label.each do |label|
43+
puts " #{label}"
44+
end
4745
end
4846

49-
unless tests_missing_label.empty? && invalid_labels.empty?
50-
puts "\nERROR: Missing or unexpected test labels found. This can result in tests not being run in CI."
51-
exit 1
47+
unless tests_missing_label.empty? && tests_missing_allowed_label.empty?
48+
puts "\nERROR: Missing or unexpected test labels found. This can result in tests not being run in CI."
49+
exit 1
5250
end

0 commit comments

Comments
 (0)