mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 15:10:22 -05:00
311 lines
11 KiB
YAML
311 lines
11 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 * * *'
|
|
|
|
concurrency:
|
|
group: build-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ${{ matrix.config.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
build_type: [Release]
|
|
config:
|
|
- {
|
|
name: "Windows Latest MSVC",
|
|
os: windows-2022,
|
|
cc: "cl",
|
|
cxx: "cl",
|
|
build-python-module: false,
|
|
execute-unit-tests: true,
|
|
execute-pytests: false,
|
|
unity-build: true,
|
|
publish-to-pypi: false,
|
|
vcpkg-bootstrap: bootstrap-vcpkg.bat,
|
|
qt-version: 6.6.3,
|
|
ri-unit-test-path: "ResInsight-tests",
|
|
}
|
|
- {
|
|
name: "Ubuntu 24.04 gcc",
|
|
os: ubuntu-24.04,
|
|
cc: "gcc",
|
|
cxx: "g++",
|
|
build-python-module: true,
|
|
execute-unit-tests: true,
|
|
execute-pytests: true,
|
|
unity-build: false,
|
|
publish-to-pypi: true,
|
|
vcpkg-bootstrap: bootstrap-vcpkg.sh,
|
|
qt-version: 6.7.0,
|
|
ri-unit-test-path: "ResInsight-tests",
|
|
}
|
|
- {
|
|
name: "Ubuntu 24.04 clang-19",
|
|
os: ubuntu-24.04,
|
|
cc: "clang-19",
|
|
cxx: "clang++-19",
|
|
build-python-module: true,
|
|
execute-unit-tests: true,
|
|
execute-pytests: false,
|
|
unity-build: false,
|
|
publish-to-pypi: false,
|
|
vcpkg-bootstrap: bootstrap-vcpkg.sh,
|
|
qt-version: 6.7.0,
|
|
ri-unit-test-path: "ResInsight-tests",
|
|
}
|
|
env:
|
|
BUILD_TYPE: Release
|
|
BUILDCACHE_DIR: ${{ github.workspace }}/buildcache_dir
|
|
BUILDCACHE_ACCURACY: SLOPPY
|
|
USERNAME: magnesj
|
|
VCPKG_EXE: ${{ github.workspace }}/ThirdParty/vcpkg/vcpkg${{ matrix.config.os == 'windows-2022' && '.exe' || '' }}
|
|
FEED_URL: https://nuget.pkg.github.com/ceetronsolutions/index.json
|
|
VCPKG_BINARY_SOURCES: "clear;nuget,https://nuget.pkg.github.com/ceetronsolutions/index.json,readwrite"
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: true
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.11"
|
|
- name: Display Python version
|
|
run: python -c "import sys; print(sys.version)"
|
|
|
|
- name: Get Python executable path
|
|
shell: bash
|
|
id: python-path
|
|
run: echo "PYTHON_EXECUTABLE=$(python -c 'import sys; import pathlib; print (pathlib.PurePath(sys.executable).as_posix())')" >> $GITHUB_OUTPUT
|
|
|
|
- name: Print Python path
|
|
run: echo "${{ steps.python-path.outputs.PYTHON_EXECUTABLE }}"
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r GrpcInterface/Python/build-requirements.txt
|
|
|
|
- name: Use MSVC (Windows)
|
|
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 "windows.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_url "https://gitlab.com/bits-n-bites/buildcache/-/releases/permalink/latest/downloads/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: Get current time
|
|
uses: josStorer/get-current-time@v2
|
|
id: current-time
|
|
with:
|
|
format: YYYY-MM-DD
|
|
|
|
- name: Print time stamp
|
|
run: echo "timestamp ${{ steps.current-time.outputs.formattedTime }}"
|
|
|
|
- name: Cache Buildcache
|
|
id: cache-buildcache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ${{ env.BUILDCACHE_DIR }}
|
|
key: ${{ matrix.config.os }}-${{ matrix.config.cc }}-cache-v03-${{ steps.current-time.outputs.formattedTime }}
|
|
- 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: Set apt mirror
|
|
# see https://github.com/actions/runner-images/issues/7048
|
|
if: contains( matrix.config.os, 'ubuntu')
|
|
run: |
|
|
# make sure there is a `\t` between URL and `priority:*` attributes
|
|
printf 'http://azure.archive.ubuntu.com/ubuntu priority:1\n' | sudo tee /etc/apt/mirrors.txt
|
|
curl http://mirrors.ubuntu.com/mirrors.txt | sudo tee --append /etc/apt/mirrors.txt
|
|
sudo sed -i 's/http:\/\/azure.archive.ubuntu.com\/ubuntu\//mirror+file:\/etc\/apt\/mirrors.txt/' /etc/apt/sources.list
|
|
|
|
- name: Install Linux dependencies
|
|
if: contains( matrix.config.os, 'ubuntu')
|
|
run: |
|
|
sudo apt-get update --option="APT::Acquire::Retries=3"
|
|
sudo apt-get install --option="APT::Acquire::Retries=3" libxkbcommon-x11-0 libgl1-mesa-dev mesa-common-dev libglfw3-dev libglu1-mesa-dev libhdf5-dev
|
|
sudo apt install mono-complete
|
|
|
|
- name: Install clang-19
|
|
if: contains( matrix.config.cc, 'clang')
|
|
run: |
|
|
sudo apt-get upgrade
|
|
wget https://apt.llvm.org/llvm.sh
|
|
sudo chmod +x llvm.sh
|
|
sudo ./llvm.sh 19 all
|
|
|
|
- name: Install Qt
|
|
uses: jurplel/install-qt-action@v4
|
|
with:
|
|
version: ${{ matrix.config.qt-version }}
|
|
dir: "${{ github.workspace }}/Qt/"
|
|
cache: true
|
|
setup-python: false
|
|
modules: "qtnetworkauth qtcharts"
|
|
|
|
- name: vcpkg bootstrap
|
|
run: |
|
|
ThirdParty/vcpkg/${{ matrix.config.vcpkg-bootstrap }}
|
|
|
|
- name: Configure NuGet for binary caching (Linux)
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
mono `${{ env.VCPKG_EXE }} fetch nuget | tail -n 1` \
|
|
sources add \
|
|
-Source "${{ env.FEED_URL }}" \
|
|
-StorePasswordInClearText \
|
|
-Name GitHubPackages \
|
|
-UserName "${{ env.USERNAME }}" \
|
|
-Password "${{ secrets.GH_PACKAGES_TOKEN }}"
|
|
mono `${{ env.VCPKG_EXE }} fetch nuget | tail -n 1` \
|
|
setapikey "${{ secrets.GH_PACKAGES_TOKEN }}" \
|
|
-Source "${{ env.FEED_URL }}"
|
|
|
|
- name: Configure NuGet for binary caching (Windows)
|
|
if: runner.os == 'Windows'
|
|
shell: pwsh
|
|
run: |
|
|
.$(${{ env.VCPKG_EXE }} fetch nuget) `
|
|
sources add `
|
|
-Source "${{ env.FEED_URL }}" `
|
|
-StorePasswordInClearText `
|
|
-Name GitHubPackages `
|
|
-UserName "${{ env.USERNAME }}" `
|
|
-Password "${{ secrets.GH_PACKAGES_TOKEN }}"
|
|
.$(${{ env.VCPKG_EXE }} fetch nuget) `
|
|
setapikey "${{ secrets.GH_PACKAGES_TOKEN }}" `
|
|
-Source "${{ env.FEED_URL }}"
|
|
|
|
- name: Configure
|
|
shell: bash
|
|
env:
|
|
CC: ${{ matrix.config.cc }}
|
|
CXX: ${{ matrix.config.cxx }}
|
|
run: >
|
|
cmake -S . -B cmakebuild
|
|
-DVCPKG_BUILD_TYPE=release
|
|
-DCMAKE_INSTALL_PREFIX=cmakebuild/install
|
|
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
|
|
-DRESINSIGHT_QT5_BUNDLE_LIBRARIES=true
|
|
-DRESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS=true
|
|
-DRESINSIGHT_TREAT_WARNINGS_AS_ERRORS=true
|
|
-DRESINSIGHT_ENABLE_PRECOMPILED_HEADERS=false
|
|
-DRESINSIGHT_ENABLE_UNITY_BUILD=${{ matrix.config.unity-build }}
|
|
-DRESINSIGHT_ENABLE_GRPC=${{ matrix.config.build-python-module }}
|
|
-DRESINSIGHT_GRPC_PYTHON_EXECUTABLE=${{ steps.python-path.outputs.PYTHON_EXECUTABLE }}
|
|
-DRESINSIGHT_GRPC_DOWNLOAD_PYTHON_MODULE=true
|
|
-DRESINSIGHT_ENABLE_HDF5=false
|
|
-DRESINSIGHT_BUILD_LIBS_FROM_SOURCE=false
|
|
-DCMAKE_TOOLCHAIN_FILE=ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake
|
|
-G Ninja
|
|
|
|
- name: Build
|
|
run: |
|
|
cmake --build cmakebuild --target install
|
|
|
|
- name: Stats for buildcache
|
|
run: ${{ github.workspace }}/buildcache/bin/buildcache -s
|
|
|
|
- name: Run Unit Tests
|
|
if: matrix.config.execute-unit-tests
|
|
shell: bash
|
|
run: |
|
|
echo "Content of unit test folder "
|
|
ls cmakebuild/${{ matrix.config.ri-unit-test-path }}
|
|
cmakebuild/${{ matrix.config.ri-unit-test-path }}
|
|
|
|
- name: (Python) Check types using mypy
|
|
if: matrix.config.build-python-module
|
|
shell: bash
|
|
run: |
|
|
${{ steps.python-path.outputs.PYTHON_EXECUTABLE }} -m pip install mypy types-protobuf
|
|
cd GrpcInterface/Python/rips
|
|
${{ steps.python-path.outputs.PYTHON_EXECUTABLE }} -m mypy --python-version 3.11 *.py generated/generated_classes.py
|
|
|
|
- name: Run pytest
|
|
if: matrix.config.execute-pytests
|
|
env:
|
|
RESINSIGHT_EXECUTABLE: ${{ runner.workspace }}/ResInsight/cmakebuild/ResInsight
|
|
run: |
|
|
cd GrpcInterface/Python
|
|
python setup.py sdist
|
|
cd rips
|
|
${{ steps.python-path.outputs.PYTHON_EXECUTABLE }} -m pytest --console
|
|
|
|
- name: Upload python distribution folder
|
|
if: matrix.config.publish-to-pypi
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: python-distribution
|
|
path: GrpcInterface/Python/dist
|
|
retention-days: 5
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ResInsight-${{ matrix.config.name }}
|
|
path: ${{ runner.workspace }}/ResInsight/cmakebuild/install
|
|
retention-days: 5
|
|
|
|
pypi-publish:
|
|
name: Upload release to PyPI
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
environment:
|
|
name: pypi
|
|
url: https://pypi.org/p/rips
|
|
permissions:
|
|
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
|
|
|
# If this is a tagged release
|
|
if: startsWith(github.ref, 'refs/tags') && github.base_ref == 'refs/heads/main'
|
|
steps:
|
|
- name: Download python distribution folder
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: python-distribution
|
|
path: dist
|
|
|
|
- name: Display structure of downloaded files
|
|
run: ls -R
|
|
|
|
- name: Publish Python package to pypi
|
|
# https://docs.pypi.org/trusted-publishers/adding-a-publisher/
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
# uncomment the two lines below to publish to test PyPi
|
|
# with:
|
|
# repository-url: https://test.pypi.org/legacy/ |