Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto detect CPU cores in CI #125

Merged
merged 4 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- {
name: 'Windows - MSVC',
artifact: 'windows-msvc.tar.xz',
os: ["self-hosted","windows","x64","vs2022"],
os: ['self-hosted', 'windows', 'x64', 'vs2022'],
cc: 'cl',
cxx: 'cl',
build-type: 'Release',
Expand All @@ -36,10 +36,12 @@ jobs:
}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: ilammy/msvc-dev-cmd@v1
- uses: SimenB/github-actions-cpu-cores@v1
id: cpu-cores

# Tell Conan to look for or create its build folder (.conan) in the repository's root directory
# This is partly done to make the directory easily accessible to Docker builds
Expand All @@ -55,14 +57,14 @@ jobs:
- name: Conan Set build directory (Windows)
if: runner.os == 'Windows'
run: |
echo "CONAN_USER_HOME=$env:GITHUB_WORKSPACE" >> $env:GITHUB_ENV
echo "CONAN_USER_HOME=d:\" >> $env:GITHUB_ENV
echo "CONAN_USER_HOME_SHORT=None" >> $env:GITHUB_ENV

# The -v{num} is a cache key buster because we were starting to use the same cache keys from previous tests
# Unfortunately github actions doesn't let you delete old caches so we have to work around it like this
- name: Conan Check cache
id: conan-cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ env.CONAN_USER_HOME }}/.conan
key: conan-${{ matrix.config.name }}-${{ hashFiles('cmake/AddConanDependencies.cmake') }}-v1
Expand All @@ -81,17 +83,16 @@ jobs:
- name: Install Windows dependencies
if: runner.os == 'Windows'
run: |
choco install -y conan
choco install -y conan --version 1.57.0
echo "C:/Program Files/conan/conan" >> $env:GITHUB_PATH

# Note: CMAKE_BUILD_TYPE is only used by Linux. It is ignored for Windows.
# Note: CMAKE_CONFIGURATION_TYPES is used by Windows to generate a single configuration for Release since we don't need Debug, RelWithDebugInfo, and MinSizeRel on CI. It is ignored for Linux.
- name: Configure
run: cmake -B build -D CMAKE_C_COMPILER=${{ matrix.config.cc }} -D CMAKE_CXX_COMPILER=${{ matrix.config.cxx }} -D CMAKE_BUILD_TYPE=${{ matrix.config.build-type }} -D CMAKE_CONFIGURATION_TYPES=${{ matrix.config.build-type }} -G "${{ matrix.config.generator }}"

# Note: GitHub Actions only has 2 cores
- name: Build
run: cmake --build build --config ${{ matrix.config.build-type }} --parallel 2
run: cmake --build build --config ${{ matrix.config.build-type }} --parallel ${{ steps.cpu-cores.outputs.count }}

- name: Check Formatting
run: cmake --build build --target clang-format-check-all --config ${{ matrix.config.build-type }}
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ endif()

# Generate ThirdParty.json
execute_process(COMMAND "${Python3_EXECUTABLE}" "${SCRIPTS_DIRECTORY}/generate_third_party_license_json.py" --build-dir
"${PROJECT_BINARY_DIR}" --project-dir "${PROJECT_SOURCE_DIR}" --skip "doctest")
"${PROJECT_BINARY_DIR}" --project-dir "${PROJECT_SOURCE_DIR}" --skip "doctest,strawberryperl")

# When calling find_package with `CMAKE_FIND_PACKAGE_PREFER_CONFIG` it adds
# a `<PACKAGE>_DIR` variable to the CMake cache, polluting the CMake GUI.
Expand Down
6 changes: 3 additions & 3 deletions ThirdParty.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"license": [
"curl"
],
"version": "7.80.0",
"version": "7.86.0",
"url": "https://curl.se"
},
{
Expand All @@ -36,7 +36,7 @@
"license": [
"BSD-3-Clause"
],
"version": "2.10.0",
"version": "2.10.1",
"url": "https://github.com/pybind/pybind11"
},
{
Expand All @@ -45,7 +45,7 @@
"Unlicense",
"MIT"
],
"version": "cci.20210910",
"version": "cci.20220909",
"url": "https://github.com/nothings/stb"
},
{
Expand Down
21 changes: 15 additions & 6 deletions cmake/AddConanDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,25 @@

include(ConfigureConan)

set(REQUIRES
"cpr/1.9.0@#168b3dcd0f24fc690873881d11ac1e66"
"doctest/2.4.9@#ea6440e3cd544c9a25bf3a96bcf16f48"
"openssl/1.1.1s@#c6838ae653d103956aec228f7642c45a"
"pybind11/2.10.1@#561736204506dad955276aaab438aab4"
"stb/cci.20220909@#1c47474f095ef8cd9e4959558525b827"
"zlib/1.2.13@#13c96f538b52e1600c40b88994de240f"
"libcurl/7.86.0@#88506b3234d553b90af1ceefc3dd1652"
"nasm/2.15.05@#5627ba08c9983f8b077dd0f581bc3e98")

if(WIN32)
set(REQUIRES ${REQUIRES} "strawberryperl/5.32.1.1@#8f83d05a60363a422f9033e52d106b47")
endif()

# cmake-format: off
configure_conan(
PROJECT_BUILD_DIRECTORY
"${PROJECT_BINARY_DIR}"
REQUIRES
cpr/1.9.0
doctest/2.4.9
openssl/1.1.1s
pybind11/2.10.0
stb/cci.20210910
zlib/1.2.13
${REQUIRES}
)
# cmake-format: on
15 changes: 15 additions & 0 deletions cmake/ConfigureConan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ macro(configure_conan)
file(WRITE "${CONAN_SETTINGS_FILE}" "${new_settings_text}")
endif()

# Add "revisions_enabled = 1" to ~/.conan/conan.conf
# This is needed in order for the Dependency Graph build target to work
set(CONAN_CONF_FILE "${CONAN_DIRECTORY}/conan.conf")
set(ADD_REVISIONS_ENABLED "[general]\nrevisions_enabled = 1")
file(READ "${CONAN_CONF_FILE}" conf_text)
string(FIND ${conf_text} "${ADD_REVISIONS_ENABLED}" position)
if(position EQUAL "-1")
string(
REPLACE "[general]"
${ADD_REVISIONS_ENABLED}
new_conf_text
${conf_text})
file(WRITE "${CONAN_CONF_FILE}" "${new_conf_text}")
endif()

conan_cmake_configure(
REQUIRES
${_REQUIRES}
Expand Down