Skip to content

Commit 7ae5c97

Browse files
hcho3cclausstrivialfis
authored
[CI] Upgrade github workflows to use latest Conda setup action (dmlc#10320)
Co-authored-by: Christian Clauss <[email protected]> Co-authored-by: Jiaming Yuan <[email protected]>
1 parent e20ed8a commit 7ae5c97

File tree

6 files changed

+100
-59
lines changed

6 files changed

+100
-59
lines changed

.github/workflows/jvm_tests.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,20 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
os: [windows-latest, ubuntu-latest, macos-11]
19+
os: [windows-latest, ubuntu-latest, macos-13]
2020

2121
steps:
2222
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2323
with:
2424
submodules: 'true'
2525

26-
- uses: mamba-org/setup-micromamba@422500192359a097648154e8db4e39bdb6c6eed7 # v1.8.1
26+
- uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4
2727
with:
28-
micromamba-version: '1.5.6-0'
29-
environment-name: jvm_tests
30-
create-args: >-
31-
python=3.10
32-
awscli
33-
cache-downloads: true
34-
cache-environment: true
35-
init-shell: bash powershell
28+
miniforge-variant: Mambaforge
29+
miniforge-version: latest
30+
activate-environment: jvm_tests
31+
environment-file: tests/ci_build/conda_env/jvm_tests.yml
32+
use-mamba: true
3633

3734
- name: Cache Maven packages
3835
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
@@ -61,7 +58,7 @@ jobs:
6158
id: extract_branch
6259
if: |
6360
(github.ref == 'refs/heads/master' || contains(github.ref, 'refs/heads/release_')) &&
64-
(matrix.os == 'windows-latest' || matrix.os == 'macos-11')
61+
(matrix.os == 'windows-latest' || matrix.os == 'macos-13')
6562
6663
- name: Publish artifact xgboost4j.dll to S3
6764
run: |
@@ -85,7 +82,7 @@ jobs:
8582
python -m awscli s3 cp libxgboost4j_${{ github.sha }}.dylib s3://xgboost-nightly-builds/${{ steps.extract_branch.outputs.branch }}/libxgboost4j/ --acl public-read --region us-west-2
8683
if: |
8784
(github.ref == 'refs/heads/master' || contains(github.ref, 'refs/heads/release_')) &&
88-
matrix.os == 'macos-11'
85+
matrix.os == 'macos-13'
8986
env:
9087
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_IAM_S3_UPLOADER }}
9188
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_IAM_S3_UPLOADER }}

.github/workflows/main.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
strategy:
2222
fail-fast: false
2323
matrix:
24-
os: [macos-11]
24+
os: [macos-12]
2525
steps:
2626
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2727
with:
@@ -33,7 +33,7 @@ jobs:
3333
run: |
3434
mkdir build
3535
cd build
36-
cmake .. -DGOOGLE_TEST=ON -DUSE_OPENMP=ON -DUSE_DMLC_GTEST=ON -GNinja -DBUILD_DEPRECATED_CLI=ON
36+
cmake .. -DGOOGLE_TEST=ON -DUSE_OPENMP=ON -DUSE_DMLC_GTEST=ON -GNinja -DBUILD_DEPRECATED_CLI=ON -DUSE_SANITIZER=ON -DENABLED_SANITIZERS=address -DCMAKE_BUILD_TYPE=RelWithDebInfo
3737
ninja -v
3838
- name: Run gtest binary
3939
run: |
@@ -79,13 +79,13 @@ jobs:
7979
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
8080
with:
8181
submodules: 'true'
82-
- uses: mamba-org/provision-with-micromamba@3c96c0c27676490c63c18bc81f5c51895ac3e0e6 # v16
82+
- uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4
8383
with:
84-
cache-downloads: true
85-
cache-env: true
86-
environment-name: linux_sycl_test
84+
miniforge-variant: Mambaforge
85+
miniforge-version: latest
86+
activate-environment: linux_sycl_test
8787
environment-file: tests/ci_build/conda_env/linux_sycl_test.yml
88-
88+
use-mamba: true
8989
- name: Display Conda env
9090
run: |
9191
conda info
@@ -121,12 +121,13 @@ jobs:
121121
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
122122
with:
123123
submodules: 'true'
124-
- uses: mamba-org/provision-with-micromamba@3c96c0c27676490c63c18bc81f5c51895ac3e0e6 # v16
124+
- uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4
125125
with:
126-
cache-downloads: true
127-
cache-env: true
128-
environment-name: cpp_test
126+
miniforge-variant: Mambaforge
127+
miniforge-version: latest
128+
activate-environment: cpp_test
129129
environment-file: tests/ci_build/conda_env/cpp_test.yml
130+
use-mamba: true
130131
- name: Display Conda env
131132
run: |
132133
conda info

.github/workflows/python_tests.yml

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ jobs:
2424
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2525
with:
2626
submodules: 'true'
27-
- uses: mamba-org/provision-with-micromamba@3c96c0c27676490c63c18bc81f5c51895ac3e0e6 # v16
27+
- uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4
2828
with:
29-
cache-downloads: true
30-
cache-env: true
31-
environment-name: python_lint
29+
miniforge-variant: Mambaforge
30+
miniforge-version: latest
31+
activate-environment: python_lint
3232
environment-file: tests/ci_build/conda_env/python_lint.yml
33+
use-mamba: true
3334
- name: Display Conda env
3435
run: |
3536
conda info
@@ -55,12 +56,13 @@ jobs:
5556
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
5657
with:
5758
submodules: 'true'
58-
- uses: mamba-org/provision-with-micromamba@3c96c0c27676490c63c18bc81f5c51895ac3e0e6 # v16
59+
- uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4
5960
with:
60-
cache-downloads: true
61-
cache-env: true
62-
environment-name: sdist_test
61+
miniforge-variant: Mambaforge
62+
miniforge-version: latest
63+
activate-environment: sdist_test
6364
environment-file: tests/ci_build/conda_env/sdist_test.yml
65+
use-mamba: true
6466
- name: Display Conda env
6567
run: |
6668
conda info
@@ -81,14 +83,14 @@ jobs:
8183
name: Test installing XGBoost Python source package on ${{ matrix.os }}
8284
strategy:
8385
matrix:
84-
os: [macos-11, windows-latest]
86+
os: [macos-13, windows-latest]
8587
python-version: ["3.8"]
8688
steps:
8789
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
8890
with:
8991
submodules: 'true'
9092
- name: Install osx system dependencies
91-
if: matrix.os == 'macos-11'
93+
if: matrix.os == 'macos-13'
9294
run: |
9395
brew install ninja libomp
9496
- uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4
@@ -119,19 +121,20 @@ jobs:
119121
strategy:
120122
matrix:
121123
config:
122-
- {os: macos-11}
124+
- {os: macos-13}
123125

124126
steps:
125127
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
126128
with:
127129
submodules: 'true'
128130

129-
- uses: mamba-org/provision-with-micromamba@3c96c0c27676490c63c18bc81f5c51895ac3e0e6 # v16
131+
- uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4
130132
with:
131-
cache-downloads: true
132-
cache-env: true
133-
environment-name: macos_test
133+
miniforge-variant: Mambaforge
134+
miniforge-version: latest
135+
activate-environment: macos_cpu_test
134136
environment-file: tests/ci_build/conda_env/macos_cpu_test.yml
137+
use-mamba: true
135138

136139
- name: Display Conda env
137140
run: |
@@ -222,12 +225,13 @@ jobs:
222225
with:
223226
submodules: 'true'
224227

225-
- uses: mamba-org/provision-with-micromamba@3c96c0c27676490c63c18bc81f5c51895ac3e0e6 # v16
228+
- uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4
226229
with:
227-
cache-downloads: true
228-
cache-env: true
229-
environment-name: linux_cpu_test
230+
miniforge-variant: Mambaforge
231+
miniforge-version: latest
232+
activate-environment: linux_cpu_test
230233
environment-file: tests/ci_build/conda_env/linux_cpu_test.yml
234+
use-mamba: true
231235

232236
- name: Display Conda env
233237
run: |
@@ -274,12 +278,13 @@ jobs:
274278
with:
275279
submodules: 'true'
276280

277-
- uses: mamba-org/provision-with-micromamba@3c96c0c27676490c63c18bc81f5c51895ac3e0e6 # v16
281+
- uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4
278282
with:
279-
cache-downloads: true
280-
cache-env: true
281-
environment-name: linux_sycl_test
283+
miniforge-variant: Mambaforge
284+
miniforge-version: latest
285+
activate-environment: linux_sycl_test
282286
environment-file: tests/ci_build/conda_env/linux_sycl_test.yml
287+
use-mamba: true
283288

284289
- name: Display Conda env
285290
run: |

.github/workflows/python_wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2929
with:
3030
submodules: 'true'
31-
- uses: conda-incubator/[email protected]
31+
- uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4
3232
with:
3333
miniforge-variant: Mambaforge
3434
miniforge-version: latest

src/collective/tracker.cc

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <algorithm> // for sort
2020
#include <chrono> // for seconds, ms
2121
#include <cstdint> // for int32_t
22+
#include <memory> // for unique_ptr
2223
#include <string> // for string
2324
#include <utility> // for move, forward
2425

@@ -376,20 +377,51 @@ Result RabitTracker::Bootstrap(std::vector<WorkerProxy>* p_workers) {
376377
if (!rc.OK()) {
377378
return rc;
378379
}
379-
auto host = gethostbyname(out->c_str());
380380

381-
// get ip address from host
382-
std::string ip;
383-
rc = INetNToP(host, &ip);
384-
if (!rc.OK()) {
385-
return rc;
381+
addrinfo hints;
382+
addrinfo* servinfo;
383+
384+
std::memset(&hints, 0, sizeof(hints));
385+
hints.ai_family = AF_UNSPEC;
386+
hints.ai_socktype = SOCK_STREAM;
387+
hints.ai_flags = AI_PASSIVE;
388+
389+
std::int32_t errc{0};
390+
std::unique_ptr<addrinfo*, std::function<void(addrinfo**)>> guard{&servinfo, [](addrinfo** ptr) {
391+
freeaddrinfo(*ptr);
392+
}};
393+
if ((errc = getaddrinfo(nullptr, "0", &hints, &servinfo)) != 0) {
394+
return Fail("Failed to get address info:" + std::string{gai_strerror(errc)});
386395
}
387396

388-
if (!(ip.size() >= 4 && ip.substr(0, 4) == "127.")) {
389-
// return if this is a public IP address.
390-
// not entirely accurate, we have other reserved IPs
391-
*out = ip;
392-
return Success();
397+
// https://beej.us/guide/bgnet/html/#getaddrinfoprepare-to-launch
398+
std::vector<SockAddress> addresses;
399+
for (addrinfo* p = servinfo; p != nullptr; p = p->ai_next) {
400+
// Get the pointer to the address itself, different fields in IPv4 and IPv6:
401+
if (p->ai_family == AF_INET) { // IPv4
402+
struct sockaddr_in* ipv4 = reinterpret_cast<sockaddr_in*>(p->ai_addr);
403+
addresses.emplace_back(SockAddrV4{*ipv4});
404+
auto ip = addresses.back().V4().Addr();
405+
// Priortize V4.
406+
// Return if this is a public IP address. Not accurate, we have other reserved IPs
407+
if (ip.size() > 4 && ip.substr(0, 4) != "127." && ip != SockAddrV4::InaddrAny().Addr()) {
408+
*out = ip;
409+
return Success();
410+
}
411+
} else {
412+
struct sockaddr_in6* ipv6 = reinterpret_cast<sockaddr_in6*>(p->ai_addr);
413+
addresses.emplace_back(SockAddrV6{*ipv6});
414+
}
415+
}
416+
// If not v4 address is found, we try v6
417+
for (auto const& addr : addresses) {
418+
if (addr.IsV6()) {
419+
auto ip = addr.V6().Addr();
420+
if (ip != SockAddrV6::InaddrAny().Addr() && ip != SockAddrV6::Loopback().Addr()) {
421+
*out = ip;
422+
return Success();
423+
}
424+
}
393425
}
394426

395427
// Create an UDP socket to prob the public IP address, it's fine even if it's
@@ -413,7 +445,7 @@ Result RabitTracker::Bootstrap(std::vector<WorkerProxy>* p_workers) {
413445
if (getsockname(sock, reinterpret_cast<struct sockaddr*>(&addr), &len) == -1) {
414446
return Fail("Failed to get sock name.");
415447
}
416-
ip = inet_ntoa(addr.sin_addr);
448+
std::string ip = inet_ntoa(addr.sin_addr);
417449

418450
err = system::CloseSocket(sock);
419451
if (err != 0) {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: jvm_tests
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- python=3.10
6+
- awscli

0 commit comments

Comments
 (0)