mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-08 07:03:25 -06:00
358c11264a
Simplify GitHub Action and support windows-2022
226 lines
8.3 KiB
YAML
226 lines
8.3 KiB
YAML
name: ResInsight Build With Cache
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
schedule:
|
|
# Every day at 1am to make sure we have a build cache for the current date
|
|
# build cache is
|
|
- cron: '0 1 * * * '
|
|
env:
|
|
BUILD_TYPE: Release
|
|
BUILDCACHE_VERSION: 0.24.4
|
|
BUILDCACHE_DIR: ${{ github.workspace }}/buildcache_dir
|
|
BUILDCACHE_ACCURACY: SLOPPY
|
|
|
|
jobs:
|
|
ResInsight-x64-buildcache:
|
|
runs-on: ${{ matrix.config.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
config:
|
|
- {
|
|
name: "Windows Latest MSVC",
|
|
os: windows-latest,
|
|
cc: "cl", cxx: "cl",
|
|
vcpkg-response-file: vcpkg_x64-windows.txt,
|
|
vcpkg-triplet: x64-windows,
|
|
build-python-module: true,
|
|
execute-unit-tests: true
|
|
}
|
|
- {
|
|
name: "Ubuntu Latest gcc",
|
|
os: ubuntu-latest,
|
|
cc: "gcc", cxx: "g++",
|
|
vcpkg-response-file: vcpkg_x64-linux.txt,
|
|
vcpkg-triplet: x64-linux,
|
|
build-python-module: true,
|
|
execute-unit-tests: true
|
|
}
|
|
- {
|
|
name: "Ubuntu Latest clang",
|
|
os: ubuntu-latest,
|
|
cc: "clang", cxx: "clang++",
|
|
vcpkg-response-file: vcpkg_x64-linux.txt,
|
|
vcpkg-triplet: x64-linux,
|
|
build-python-module: true,
|
|
execute-unit-tests: true
|
|
}
|
|
- {
|
|
name: "Mac OS",
|
|
os: macos-latest,
|
|
cc: "clang", cxx: "clang++",
|
|
vcpkg-response-file: vcpkg_x64-osx.txt,
|
|
vcpkg-triplet: x64-osx,
|
|
build-python-module: false,
|
|
execute-unit-tests: false
|
|
}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
with:
|
|
submodules: true
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v2
|
|
with:
|
|
python-version: '3.8'
|
|
- name: Display Python version
|
|
run: python -c "import sys; print(sys.version)"
|
|
|
|
- name: Use CMake
|
|
uses: lukka/get-cmake@latest
|
|
|
|
- name: Use MSVC (Windows)
|
|
if: matrix.config.os == 'windows-latest'
|
|
uses: ilammy/msvc-dev-cmd@v1
|
|
|
|
- name: Download buildcache
|
|
id: buildcache-download
|
|
shell: cmake -P {0}
|
|
run: |
|
|
if ("${{ runner.os }}" STREQUAL "Windows")
|
|
set(buildcache_suffix "win-msvc.zip")
|
|
elseif ("${{ runner.os }}" STREQUAL "macOS")
|
|
set(buildcache_suffix "macos.zip")
|
|
elseif ("${{ runner.os }}" STREQUAL "Linux")
|
|
set(buildcache_suffix "linux.tar.gz")
|
|
endif()
|
|
|
|
set(buildcache_version $ENV{BUILDCACHE_VERSION})
|
|
set(buildcache_url "https://github.com/mbitsnbites/buildcache/releases/download/v${buildcache_version}/buildcache-${buildcache_suffix}")
|
|
file(DOWNLOAD "${buildcache_url}" ./buildcache.zip)
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./buildcache.zip)
|
|
|
|
if (NOT "${{ runner.os }}" STREQUAL "Windows")
|
|
execute_process(
|
|
COMMAND chmod +x buildcache/bin/buildcache
|
|
)
|
|
endif()
|
|
|
|
- name: Prepare cache timestamp
|
|
id: cache_timestamp_string
|
|
shell: cmake -P {0}
|
|
run: |
|
|
string(TIMESTAMP current_date "%Y-%m-%d" UTC)
|
|
message("::set-output name=timestamp::${current_date}")
|
|
- name: Cache Buildcache
|
|
id: cache-buildcache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ${{ env.BUILDCACHE_DIR }}
|
|
key: ${{ matrix.config.os }}-${{ matrix.config.cc }}-cache-v02-${{ steps.cache_timestamp_string.outputs.timestamp }}
|
|
- name: Create Folder for buildcache
|
|
run: New-Item ${{ env.BUILDCACHE_DIR }} -ItemType "directory" -Force
|
|
shell: pwsh
|
|
- name: Add buildcache to system path
|
|
run: echo "${{github.workspace}}/buildcache/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
|
|
shell: pwsh
|
|
|
|
- name: Cache Qt
|
|
id: cache-qt
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ${{ github.workspace }}/Qt/
|
|
key: ${{ matrix.config.os }}-QtCache-v03
|
|
- name: Install Qt
|
|
uses: jurplel/install-qt-action@v2
|
|
with:
|
|
version: 5.9.9
|
|
modules: qtscript qtcharts
|
|
dir: '${{ github.workspace }}/Qt/'
|
|
cached: ${{ steps.cache-qt.outputs.cache-hit }}
|
|
- name: Install Linux dependencies
|
|
if: "contains( matrix.config.os, 'ubuntu')"
|
|
run: sudo apt-get install libxkbcommon-x11-0 libgl1-mesa-dev mesa-common-dev libglfw3-dev libglu1-mesa-dev libhdf5-dev
|
|
- name: Get Python executable path
|
|
id: python-path
|
|
run: echo "::set-output name=PYTHON_EXECUTABLE::$(python -c 'import sys; import pathlib; print (pathlib.PurePath(sys.executable).as_posix())')"
|
|
- name: Print Python path
|
|
run: echo ${{ steps.python-path.outputs.PYTHON_EXECUTABLE }}
|
|
|
|
- name: Set vcpkg's response file path used as part of cache's key.
|
|
uses: lukka/set-shell-env@master
|
|
with:
|
|
VCPKGRESPONSEFILE: ${{ github.workspace }}/${{ matrix.config.vcpkg-response-file }}
|
|
- name: Restore from cache and install vcpkg
|
|
uses: lukka/run-vcpkg@v7
|
|
id: runvcpkg
|
|
with:
|
|
vcpkgArguments: '@${{ github.workspace }}/${{ matrix.config.vcpkg-response-file }}'
|
|
vcpkgDirectory: '${{ github.workspace }}/ThirdParty/vcpkg'
|
|
# Ensure the cache key changes any time the content of the response file changes.
|
|
appendedCacheKey: ${{ hashFiles(env.VCPKGRESPONSEFILE) }}-cache-key-v2
|
|
|
|
- name: Cache dynamic version of OpenSSL (Linux)
|
|
if: "contains( matrix.config.os, 'ubuntu_disabled')"
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ${{ github.workspace }}/ThirdParty/vcpkg/installed/x64-linux-dynamic
|
|
key: ${{ matrix.config.os }}-vcpkg-x64-linux-dynamic_v05
|
|
|
|
- name: Install dynamic version of OpenSSL (Linux)
|
|
if: "contains( matrix.config.os, 'ubuntu')"
|
|
run: |
|
|
$VCPKG_ROOT/vcpkg install --overlay-triplets=${{ github.workspace }}/ThirdParty/vcpkg-custom-triplets --triplet x64-linux-dynamic openssl
|
|
|
|
- name: Configure
|
|
shell: cmake -P {0}
|
|
run: |
|
|
set(ENV{CC} ${{ matrix.config.cc }})
|
|
set(ENV{CXX} ${{ matrix.config.cxx }})
|
|
|
|
execute_process(
|
|
COMMAND cmake
|
|
-S .
|
|
-B cmakebuild
|
|
-D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE}
|
|
-D CMAKE_INSTALL_PREFIX=cmakebuild/install
|
|
-D RESINSIGHT_BUNDLE_OPENSSL=true
|
|
-D RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS=true
|
|
-D RESINSIGHT_TREAT_WARNINGS_AS_ERRORS=true
|
|
-D RESINSIGHT_ENABLE_GRPC=${{ matrix.config.build-python-module }}
|
|
-D RESINSIGHT_GRPC_PYTHON_EXECUTABLE=${{ steps.python-path.outputs.PYTHON_EXECUTABLE }}
|
|
-D RESINSIGHT_GRPC_DOWNLOAD_PYTHON_MODULE=true
|
|
-D CMAKE_TOOLCHAIN_FILE=ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake
|
|
-G Ninja
|
|
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] ")
|
|
execute_process(
|
|
COMMAND cmake --build cmakebuild --target install
|
|
RESULT_VARIABLE result
|
|
)
|
|
if (NOT result EQUAL 0)
|
|
message(FATAL_ERROR "Bad exit status")
|
|
endif()
|
|
|
|
- name: Stats for buildcache
|
|
run: ${{ github.workspace }}/buildcache/bin/buildcache -s
|
|
- name: Run Unit Tests
|
|
if: "matrix.config.execute-unit-tests == true"
|
|
shell: bash
|
|
run: |
|
|
cmakebuild/ApplicationExeCode/ResInsight --unittest
|
|
|
|
- name: Run pytest
|
|
if: "matrix.config.build-python-module == true"
|
|
env:
|
|
RESINSIGHT_EXECUTABLE: ${{ runner.workspace }}/ResInsight/cmakebuild/ApplicationExeCode/ResInsight
|
|
run: |
|
|
cd GrpcInterface/Python/rips
|
|
${{ steps.python-path.outputs.PYTHON_EXECUTABLE }} -m pytest --console
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v2
|
|
if: "matrix.config.name != 'Ubuntu Latest clang'"
|
|
with:
|
|
name: ResInsight-${{ matrix.config.name }}
|
|
path: ${{ runner.workspace }}/ResInsight/cmakebuild/install
|