Skip to content

Commit 3f7db2b

Browse files
authored
[ci] [c++] update macOS x86_64 jobs to macOS-15, used std::tolower() for case changes (#7083)
* [ci] update macOS x86_64 jobs to macOS-15 * make Common::tolower() a regular function * try just removing inline * try using std::tolower() instead * use preferred pattern from cppreference docs
1 parent 765689b commit 3f7db2b

File tree

8 files changed

+29
-32
lines changed

8 files changed

+29
-32
lines changed

.ci/setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ if [[ $OS_NAME == "macos" ]]; then
1313
# Check https://github.com/actions/runner-images/tree/main/images/macos for available
1414
# versions of Xcode
1515
macos_ver=$(sw_vers --productVersion)
16-
if [[ "${macos_ver}" =~ 13. ]]; then
17-
xcode_path="/Applications/Xcode_14.3.app/Contents/Developer"
16+
if [[ "${macos_ver}" =~ 15. ]]; then
17+
xcode_path="/Applications/Xcode_16.0.app/Contents/Developer"
1818
else
1919
xcode_path="/Applications/Xcode_15.0.app/Contents/Developer"
2020
fi

.github/workflows/cpp.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
method: with-sanitizers
4242
container: 'ubuntu:22.04'
4343
os-display-name: 'ubuntu22.04'
44-
- os: macos-13
44+
- os: macos-15-intel
4545
task: cpp-tests
4646
compiler: clang
4747
method: with-sanitizers
@@ -65,7 +65,7 @@ jobs:
6565
os-display-name: 'ubuntu22.04'
6666
python_version: '3.13'
6767
setup-conda: 'true'
68-
- os: macos-13
68+
- os: macos-15-intel
6969
task: if-else
7070
compiler: clang
7171
python_version: '3.10'

.github/workflows/python_package.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,33 +78,33 @@ jobs:
7878
fail-fast: false
7979
matrix:
8080
include:
81-
- os: macos-13
81+
- os: macos-15-intel
8282
task: regular
8383
compiler: gcc
8484
python_version: '3.11'
85-
- os: macos-13
85+
- os: macos-15-intel
8686
task: sdist
8787
compiler: clang
8888
python_version: '3.10'
89-
- os: macos-13
89+
- os: macos-15-intel
9090
task: sdist
9191
compiler: gcc
9292
python_version: '3.12'
93-
- os: macos-13
93+
- os: macos-15-intel
9494
task: bdist
9595
compiler: gcc
9696
python_version: '3.9'
97-
- os: macos-13
97+
- os: macos-15-intel
9898
task: mpi
9999
compiler: gcc
100100
method: source
101101
python_version: '3.12'
102-
- os: macos-13
102+
- os: macos-15-intel
103103
task: mpi
104104
compiler: gcc
105105
method: pip
106106
python_version: '3.13'
107-
- os: macos-13
107+
- os: macos-15-intel
108108
task: mpi
109109
compiler: gcc
110110
method: wheel
@@ -113,7 +113,7 @@ jobs:
113113
# jobs that create #
114114
# release artifacts #
115115
#####################
116-
- os: macos-13
116+
- os: macos-15-intel
117117
task: bdist
118118
compiler: clang
119119
method: wheel
@@ -127,7 +127,7 @@ jobs:
127127
produces-artifacts: 'true'
128128
artifact-name: 'macosx-arm64-wheel'
129129
python_version: '3.11'
130-
- os: macos-13
130+
- os: macos-15-intel
131131
task: regular
132132
compiler: clang
133133
produces-artifacts: 'true'

.github/workflows/r_package.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ jobs:
7474
r_version: 4.3
7575
build_type: cmake
7676
container: 'ubuntu:22.04'
77-
- os: macos-13
77+
- os: macos-15-intel
7878
task: r-package
7979
compiler: gcc
8080
r_version: 4.3
8181
build_type: cmake
8282
container: null
83-
- os: macos-13
83+
- os: macos-15-intel
8484
task: r-package
8585
compiler: clang
8686
r_version: 4.3
@@ -119,7 +119,7 @@ jobs:
119119
container: 'ubuntu:22.04'
120120
produces-artifacts: 'true'
121121
artifact-name: r-cran-package
122-
- os: macos-13
122+
- os: macos-15-intel
123123
task: r-package
124124
compiler: clang
125125
r_version: 4.3

.github/workflows/swig.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
container: 'lightgbm.azurecr.io/vsts-agent:manylinux_2_28_x86_64'
4040
artifact-name: swig-linux-x86_64-jar
4141
os-display-name: 'manylinux_2_28'
42-
- os: macos-13
42+
- os: macos-15-intel
4343
compiler: clang
4444
container: null
4545
artifact-name: swig-macos-x86_64-jar

include/LightGBM/config.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include <string>
2525
#include <algorithm>
26+
#include <cctype>
2627
#include <memory>
2728
#include <unordered_map>
2829
#include <unordered_set>
@@ -1204,7 +1205,7 @@ inline bool Config::GetBool(
12041205
const std::string& name, bool* out) {
12051206
if (params.count(name) > 0 && !params.at(name).empty()) {
12061207
std::string value = params.at(name);
1207-
std::transform(value.begin(), value.end(), value.begin(), Common::tolower);
1208+
std::transform(value.begin(), value.end(), value.begin(), [](unsigned char c){ return std::tolower(c); });
12081209
if (value == std::string("false") || value == std::string("-")) {
12091210
*out = false;
12101211
} else if (value == std::string("true") || value == std::string("+")) {

include/LightGBM/utils/common.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <limits>
1313
#include <string>
1414
#include <algorithm>
15+
#include <cctype>
1516
#include <chrono>
1617
#include <cmath>
1718
#include <cstdint>
@@ -67,12 +68,6 @@ static void C_stringstream(std::stringstream &ss) {
6768
ss.imbue(std::locale::classic());
6869
}
6970

70-
inline static char tolower(char in) {
71-
if (in <= 'Z' && in >= 'A')
72-
return in - ('Z' - 'z');
73-
return in;
74-
}
75-
7671
inline static std::string Trim(std::string str) {
7772
if (str.empty()) {
7873
return str;
@@ -340,7 +335,7 @@ inline static const char* Atof(const char* p, double* out) {
340335
}
341336
if (cnt > 0) {
342337
std::string tmp_str(p, cnt);
343-
std::transform(tmp_str.begin(), tmp_str.end(), tmp_str.begin(), Common::tolower);
338+
std::transform(tmp_str.begin(), tmp_str.end(), tmp_str.begin(), [](unsigned char c){ return std::tolower(c); });
344339
if (tmp_str == std::string("na") || tmp_str == std::string("nan") ||
345340
tmp_str == std::string("null")) {
346341
*out = NAN;

src/io/config.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <LightGBM/utils/random.h>
1111

1212
#include <algorithm>
13+
#include <cctype>
1314
#include <limits>
1415
#include <string>
1516
#include <unordered_map>
@@ -104,7 +105,7 @@ std::unordered_map<std::string, std::string> Config::Str2Map(const char* paramet
104105
void GetBoostingType(const std::unordered_map<std::string, std::string>& params, std::string* boosting) {
105106
std::string value;
106107
if (Config::GetString(params, "boosting", &value)) {
107-
std::transform(value.begin(), value.end(), value.begin(), Common::tolower);
108+
std::transform(value.begin(), value.end(), value.begin(), [](unsigned char c){ return std::tolower(c); });
108109
if (value == std::string("gbdt") || value == std::string("gbrt")) {
109110
*boosting = "gbdt";
110111
} else if (value == std::string("dart")) {
@@ -122,7 +123,7 @@ void GetBoostingType(const std::unordered_map<std::string, std::string>& params,
122123
void GetDataSampleStrategy(const std::unordered_map<std::string, std::string>& params, std::string* strategy) {
123124
std::string value;
124125
if (Config::GetString(params, "data_sample_strategy", &value)) {
125-
std::transform(value.begin(), value.end(), value.begin(), Common::tolower);
126+
std::transform(value.begin(), value.end(), value.begin(), [](unsigned char c){ return std::tolower(c); });
126127
if (value == std::string("goss")) {
127128
*strategy = "goss";
128129
} else if (value == std::string("bagging")) {
@@ -149,15 +150,15 @@ void ParseMetrics(const std::string& value, std::vector<std::string>* out_metric
149150
void GetObjectiveType(const std::unordered_map<std::string, std::string>& params, std::string* objective) {
150151
std::string value;
151152
if (Config::GetString(params, "objective", &value)) {
152-
std::transform(value.begin(), value.end(), value.begin(), Common::tolower);
153+
std::transform(value.begin(), value.end(), value.begin(), [](unsigned char c){ return std::tolower(c); });
153154
*objective = ParseObjectiveAlias(value);
154155
}
155156
}
156157

157158
void GetMetricType(const std::unordered_map<std::string, std::string>& params, const std::string& objective, std::vector<std::string>* metric) {
158159
std::string value;
159160
if (Config::GetString(params, "metric", &value)) {
160-
std::transform(value.begin(), value.end(), value.begin(), Common::tolower);
161+
std::transform(value.begin(), value.end(), value.begin(), [](unsigned char c){ return std::tolower(c); });
161162
ParseMetrics(value, metric);
162163
}
163164
// add names of objective function if not providing metric
@@ -169,7 +170,7 @@ void GetMetricType(const std::unordered_map<std::string, std::string>& params, c
169170
void GetTaskType(const std::unordered_map<std::string, std::string>& params, TaskType* task) {
170171
std::string value;
171172
if (Config::GetString(params, "task", &value)) {
172-
std::transform(value.begin(), value.end(), value.begin(), Common::tolower);
173+
std::transform(value.begin(), value.end(), value.begin(), [](unsigned char c){ return std::tolower(c); });
173174
if (value == std::string("train") || value == std::string("training")) {
174175
*task = TaskType::kTrain;
175176
} else if (value == std::string("predict") || value == std::string("prediction")
@@ -190,7 +191,7 @@ void GetTaskType(const std::unordered_map<std::string, std::string>& params, Tas
190191
void GetDeviceType(const std::unordered_map<std::string, std::string>& params, std::string* device_type) {
191192
std::string value;
192193
if (Config::GetString(params, "device_type", &value)) {
193-
std::transform(value.begin(), value.end(), value.begin(), Common::tolower);
194+
std::transform(value.begin(), value.end(), value.begin(), [](unsigned char c){ return std::tolower(c); });
194195
if (value == std::string("cpu")) {
195196
*device_type = "cpu";
196197
} else if (value == std::string("gpu")) {
@@ -206,7 +207,7 @@ void GetDeviceType(const std::unordered_map<std::string, std::string>& params, s
206207
void GetTreeLearnerType(const std::unordered_map<std::string, std::string>& params, std::string* tree_learner) {
207208
std::string value;
208209
if (Config::GetString(params, "tree_learner", &value)) {
209-
std::transform(value.begin(), value.end(), value.begin(), Common::tolower);
210+
std::transform(value.begin(), value.end(), value.begin(), [](unsigned char c){ return std::tolower(c); });
210211
if (value == std::string("serial")) {
211212
*tree_learner = "serial";
212213
} else if (value == std::string("feature") || value == std::string("feature_parallel")) {

0 commit comments

Comments
 (0)