Update GitHub actions #2671
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CMake Windows | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: ${{ github.ref_name != 'master' }} | |
# Controls when the action will run. | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
types: [opened, synchronize, reopened] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
cmake_windows: | |
name: ${{ matrix.config.name }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
name: "Windows Latest MSVC", | |
artifact: "Windows-MSVC.tar.xz", | |
os: windows-latest, | |
build_type: "Release", | |
cc: "cl", | |
cxx: "cl", | |
build_testing: "OFF", | |
environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat", | |
} | |
- { | |
name: "Windows Latest MinGW", | |
artifact: "Windows-MinGW.tar.xz", | |
os: windows-latest, | |
build_type: "Release", | |
cc: "gcc", | |
cxx: "g++", | |
build_testing: "ON", | |
platform: mingw, | |
} | |
#- { | |
# name: "macOS Latest Clang", artifact: "macOS.tar.xz", | |
# os: macos-latest, | |
# build_type: "Release", cc: "clang", cxx: "clang++" | |
# } | |
steps: | |
- name: Update MinGW to 10.2 | |
if: ${{ matrix.config.platform == 'mingw' }} | |
run: | | |
for($i=0; ; $i++) { | |
choco upgrade mingw --version=10.2.0 --force | |
if (!$?) { | |
if ($i -le 3) { | |
continue | |
} | |
throw "choco upgrade mingw failed" | |
} | |
break | |
} | |
$gcc_version = &gcc -v 2>&1 | Out-String | |
$gcc_version | |
if ($gcc_version -NotMatch 'gcc version 10.2.0') { | |
throw "invalid gcc version detected" | |
} | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: "true" | |
- name: Download Ninja and CMake | |
id: cmake_and_ninja | |
shell: cmake -P {0} | |
run: | | |
set(ninja_version "1.9.0") | |
set(cmake_version "3.16.2") | |
message(STATUS "Using host CMake version: ${CMAKE_VERSION}") | |
if ("${{ runner.os }}" STREQUAL "Windows") | |
set(ninja_suffix "win.zip") | |
set(cmake_suffix "win64-x64.zip") | |
set(cmake_dir "cmake-${cmake_version}-win64-x64/bin") | |
elseif ("${{ runner.os }}" STREQUAL "Linux") | |
set(ninja_suffix "linux.zip") | |
set(cmake_suffix "Linux-x86_64.tar.gz") | |
set(cmake_dir "cmake-${cmake_version}-Linux-x86_64/bin") | |
elseif ("${{ runner.os }}" STREQUAL "macOS") | |
set(ninja_suffix "mac.zip") | |
set(cmake_suffix "Darwin-x86_64.tar.gz") | |
set(cmake_dir "cmake-${cmake_version}-Darwin-x86_64/CMake.app/Contents/bin") | |
endif() | |
set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}") | |
file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS) | |
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ninja.zip) | |
set(cmake_url "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-${cmake_suffix}") | |
file(DOWNLOAD "${cmake_url}" ./cmake.zip SHOW_PROGRESS) | |
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./cmake.zip) | |
# Save the path for other steps | |
file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${cmake_dir}" cmake_dir) | |
file(TO_CMAKE_PATH "$ENV{GITHUB_OUTPUT}" github_output) | |
file(APPEND ${github_output} "cmake_dir=${cmake_dir}") | |
if (NOT "${{ runner.os }}" STREQUAL "Windows") | |
execute_process( | |
COMMAND chmod +x ninja | |
COMMAND chmod +x ${cmake_dir}/cmake | |
COMMAND chmod +x ${cmake_dir}/test | |
) | |
endif() | |
- name: Configure | |
shell: cmake -P {0} | |
run: | | |
set(ENV{CC} ${{ matrix.config.cc }}) | |
set(ENV{CXX} ${{ matrix.config.cxx }}) | |
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") | |
message(STATUS "Set Windows environment") | |
execute_process( | |
COMMAND "${{ matrix.config.environment_script }}" && set | |
OUTPUT_FILE environment_script_output.txt | |
RESULT_VARIABLE result | |
) | |
if (NOT result EQUAL 0) | |
message(FATAL_ERROR "Bad exit status") | |
endif() | |
file(STRINGS environment_script_output.txt output_lines) | |
foreach(line IN LISTS output_lines) | |
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") | |
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") | |
endif() | |
endforeach() | |
endif() | |
file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/ninja" ninja_program) | |
message(STATUS "Create Ninja build system") | |
execute_process( | |
COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake | |
-S . | |
-B build | |
-D CMAKE_VERBOSE_MAKEFILE=ON | |
-D CMAKE_BUILD_TYPE=${{ matrix.config.build_type }} | |
-D BUILD_TESTING=${{ matrix.config.build_testing }} | |
-D OC_CLOUD_ENABLED=ON | |
-D OC_COLLECTIONS_IF_CREATE_ENABLED=ON | |
-D OC_RESOURCE_ACCESS_IN_RFOTM_ENABLED=ON | |
-D OC_DEBUG_ENABLED=ON | |
-G Ninja | |
-D CMAKE_MAKE_PROGRAM=${ninja_program} | |
RESULT_VARIABLE result | |
) | |
if (NOT result EQUAL 0) | |
message(FATAL_ERROR "Bad exit status") | |
endif() | |
- name: Build | |
shell: cmake -P {0} | |
run: | | |
set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ") | |
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") | |
file(STRINGS environment_script_output.txt output_lines) | |
foreach(line IN LISTS output_lines) | |
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") | |
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") | |
endif() | |
endforeach() | |
endif() | |
execute_process( | |
COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake --build build | |
RESULT_VARIABLE result | |
) | |
if (NOT result EQUAL 0) | |
message(FATAL_ERROR "Bad exit status") | |
endif() | |
- name: Test | |
if: ${{ matrix.config.build_testing == 'ON' }} | |
shell: cmake -P {0} | |
working-directory: build | |
run: | | |
set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ") | |
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") | |
file(STRINGS environment_script_output.txt output_lines) | |
foreach(line IN LISTS output_lines) | |
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") | |
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") | |
endif() | |
endforeach() | |
endif() | |
execute_process( | |
COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/ctest --verbose --label-regex "oc-unittest" | |
RESULT_VARIABLE result | |
) | |
if (NOT result EQUAL 0) | |
message(FATAL_ERROR "Bad exit status") | |
endif() |