Unverified Commit a8baffa6 authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[ci] move C++ test jobs to GitHub Actions (#7033)



* [ci] move C++ tests to GitHub Actions

* skip more CI

* fix env variables

* fix some small things

* fix software setup

* add sudo

* UBUNTU_BASE_CONTAINER (spelling)

* fix condition on manylinux image

* restore other CI

* remove if-else from python_package

* define BUILD_ARTIFACTSTAGINGDIRECTORY for cpp jobs

* Apply suggestions from code review
Co-authored-by: default avatarNikita Titov <nekit94-08@mail.ru>

---------
Co-authored-by: default avatarNikita Titov <nekit94-08@mail.ru>
parent 061f59a9
name: C++
on:
push:
branches:
- master
pull_request:
branches:
- master
# automatically cancel in-progress builds if another commit is pushed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
# tell scripts where to put artifacts
# (this variable name is left over from when jobs ran on Azure DevOps)
BUILD_ARTIFACTSTAGINGDIRECTORY: '${{ github.workspace }}/artifacts'
# where repo sources are cloned to
BUILD_DIRECTORY: '${{ github.workspace }}'
# in CMake-driven builds, parallelize compilation
CMAKE_BUILD_PARALLEL_LEVEL: 4
jobs:
test:
name: ${{ matrix.task }} (${{ matrix.os-display-name || matrix.os }}, ${{ matrix.compiler }})
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
#############
# C++ tests #
#############
- os: ubuntu-latest
task: cpp-tests
compiler: clang-17
method: with-sanitizers
container: 'ubuntu:22.04'
os-display-name: 'ubuntu22.04'
- os: macos-13
task: cpp-tests
compiler: clang
method: with-sanitizers
sanitizers: "address;undefined"
container: null
- os: windows-2022
task: cpp-tests
compiler: msvc
container: null
###########
# if-else #
###########
# These test CLI-generated C++ inference code.
#
# They need Python because they're written with pytest, but they
# do not need the LightGBM Python package
- os: ubuntu-latest
task: if-else
compiler: clang-17
container: 'ubuntu:22.04'
os-display-name: 'ubuntu22.04'
python_version: '3.13'
setup-conda: 'true'
- os: macos-13
task: if-else
compiler: clang
python_version: '3.10'
container: null
- os: ubuntu-latest
task: if-else
compiler: gcc
python_version: '3.11'
container: 'lightgbm.azurecr.io/vsts-agent:manylinux_2_28_x86_64'
os-display-name: 'manylinux_2_28'
steps:
- name: Install packages used by third-party actions
if: matrix.container == 'ubuntu:22.04'
shell: bash
run: |
apt-get update -y
apt-get install --no-install-recommends -y \
dirmngr \
gpg \
gpg-agent \
software-properties-common \
sudo
# install newest version of git
# ref:
# - https://unix.stackexchange.com/a/170831/550004
# - https://git-scm.com/download/linux
add-apt-repository ppa:git-core/ppa -y
apt-get update -y
apt-get install --no-install-recommends -y \
git
- name: Trust git cloning LightGBM
if: startsWith(matrix.os, 'ubuntu')
run: |
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 5
persist-credentials: false
submodules: true
- name: Setup and run tests on Linux and macOS
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')
shell: bash
run: |
export COMPILER="${{ matrix.compiler }}"
export CONDA="${HOME}/miniforge"
export METHOD="${{ matrix.method }}"
export PATH=${CONDA}/bin:${PATH}
export PYTHON_VERSION="${{ matrix.python_version }}"
export SANITIZERS="${{ matrix.sanitizers }}"
export SETUP_CONDA="${{ matrix.setup-conda }}"
export TASK="${{ matrix.task }}"
if [[ "${{ matrix.os }}" =~ ^macos ]]; then
export OS_NAME="macos"
elif [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
export OS_NAME="linux"
fi
if [[ "${{ matrix.container }}" == "ubuntu:22.04" ]]; then
export DEBIAN_FRONTEND=noninteractive
export IN_UBUNTU_BASE_CONTAINER="true"
fi
$GITHUB_WORKSPACE/.ci/setup.sh
$GITHUB_WORKSPACE/.ci/test.sh
- name: Setup and run tests on Windows
if: startsWith(matrix.os, 'windows')
shell: pwsh -command ". {0}"
run: |
$env:BUILD_SOURCESDIRECTORY = $env:BUILD_DIRECTORY
$env:TASK = "${{ matrix.task }}"
& "$env:GITHUB_WORKSPACE/.ci/test-windows.ps1"
all-cpp-jobs-successful:
if: always()
runs-on: ubuntu-latest
needs:
- test
steps:
- name: Note that all tests succeeded
uses: re-actors/alls-green@v1.2.2
with:
jobs: ${{ toJSON(needs) }}
......@@ -86,9 +86,6 @@ jobs:
- os: macos-13
task: bdist
python_version: '3.9'
- os: macos-13
task: if-else
python_version: '3.10'
- os: macos-14
task: bdist
method: wheel
......
......@@ -103,8 +103,6 @@ jobs:
bdist:
TASK: bdist
PYTHON_VERSION: '3.10'
inference:
TASK: if-else
mpi_source:
TASK: mpi
METHOD: source
......@@ -168,8 +166,6 @@ jobs:
bdist:
TASK: bdist
PYTHON_VERSION: '3.11'
inference:
TASK: if-else
mpi_source:
TASK: mpi
METHOD: source
......@@ -193,9 +189,6 @@ jobs:
TASK: gpu
METHOD: wheel
PYTHON_VERSION: '3.10'
cpp_tests:
TASK: cpp-tests
METHOD: with-sanitizers
steps:
- script: |
echo "##vso[task.setvariable variable=BUILD_DIRECTORY]$BUILD_SOURCESDIRECTORY"
......@@ -245,10 +238,6 @@ jobs:
TASK: bdist
swig:
TASK: swig
cpp_tests:
TASK: cpp-tests
METHOD: with-sanitizers
SANITIZERS: "address;undefined"
steps:
- script: |
echo "##vso[task.setvariable variable=BUILD_DIRECTORY]$BUILD_SOURCESDIRECTORY"
......@@ -299,8 +288,6 @@ jobs:
TASK: bdist
swig:
TASK: swig
cpp_tests:
TASK: cpp-tests
steps:
- powershell: |
Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment