Bump dependencies and switch to conanfile.py #320
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
# Copyright (C) 2022 Roberto Rossini ([email protected]) | |
# SPDX-License-Identifier: MIT | |
name: MacOS CI | |
on: | |
push: | |
branches: [ main ] | |
paths: | |
- ".github/workflows/macos-ci.yml" | |
- "cmake/**" | |
- "external/**" | |
- "src/**" | |
- "test/**" | |
- "!test/scripts/devel/**" | |
- "CMakeLists.txt" | |
- "conanfile.py" | |
tags: | |
- 'v*.*.*' | |
pull_request: | |
paths: | |
- ".github/workflows/macos-ci.yml" | |
- "cmake/**" | |
- "external/**" | |
- "src/**" | |
- "test/**" | |
- "!test/scripts/devel/**" | |
- "CMakeLists.txt" | |
- "conanfile.py" | |
# https://stackoverflow.com/a/72408109 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
env: | |
CCACHE_DIR: "${{ github.workspace }}/ccache-cache" | |
CCACHE_COMPRESSLEVEL: "13" | |
CCACHE_MAXSIZE: "200M" | |
CONAN_HOME: "${{ github.workspace }}/.conan2" | |
HOMEBREW_NO_AUTO_UPDATE: "1" | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
matrix-factory: | |
name: Generate job matrix | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-result.outputs.result }} | |
steps: | |
- uses: actions/github-script@v6 | |
id: set-result | |
with: | |
script: | | |
// Documentation | |
// https://docs.github.com/en/actions/learn-github-actions/contexts#fromjson | |
// https://github.com/actions/runner/issues/982#issuecomment-809360765 | |
var includes = [] | |
includes.push({ compiler_name: 'apple-clang', compiler_version: '13.0', os: 'macos-11', conan: '2.0.*', cmake: '3.26.*', build_type: 'Release', developer_mode: 'OFF' }) | |
includes.push({ compiler_name: 'apple-clang', compiler_version: '14.0', os: 'macos-12', conan: '2.0.*', cmake: '3.26.*', build_type: 'Release', developer_mode: 'OFF' }) | |
includes.push({ compiler_name: 'apple-clang', compiler_version: '14.0', os: 'macos-13', conan: '2.0.*', cmake: '3.26.*', build_type: 'Release', developer_mode: 'OFF' }) | |
includes.push({ compiler_name: 'apple-clang', compiler_version: '14.0', os: 'macos-13', conan: '2.0.*', cmake: '3.26.*', build_type: 'Debug', developer_mode: 'OFF' }) | |
return { include: includes } | |
cache-test-datasets: | |
uses: paulsengroup/modle/.github/workflows/cache-test-datasets.yml@main | |
build-project: | |
name: Build project | |
needs: matrix-factory | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJSON(needs.matrix-factory.outputs.matrix) }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Generate requirements.txt for pip | |
run: | | |
echo 'conan==${{ matrix.conan }}' > requirements.txt | |
echo 'cmake==${{ matrix.cmake }}' >> requirements.txt | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
cache: 'pip' | |
- name: Install build deps | |
run: | | |
pip install -r requirements.txt | |
brew install ccache | |
- name: Detect number available CPUs | |
run: | | |
ncpus=$(python -c 'import multiprocessing as mp; print(mp.cpu_count())') | |
echo "CMAKE_BUILD_PARALLEL_LEVEL=$ncpus" >> $GITHUB_ENV | |
- name: Generate cache key | |
id: cache-key | |
run: | | |
set -u | |
os="${{ matrix.os }}" | |
compiler="${{ matrix.compiler_name }}" | |
build_type="${{ matrix.build_type }}" | |
conanfile_hash="${{ hashFiles('conanfile.py') }}" | |
workflow_hash="${{ hashFiles('.github/workflows/macos-ci.yml') }}" | |
combined_hash="${{ hashFiles('conanfile.py', '.github/workflows/macos-ci.yml') }}" | |
# This can be used by to always update a cache entry (useful e.g. for ccache) | |
current_date="$(date '+%s')" | |
conan_key_prefix="conan-$os-$compiler-$conanfile_hash-$build_type" | |
ccache_key_prefix="ccache-$os-$compiler-$conanfile_hash-$build_type" | |
echo "conan-key=$conan_key_prefix" >> $GITHUB_OUTPUT | |
echo "conan-restore-key=$conan_key_prefix" >> $GITHUB_OUTPUT | |
echo "ccache-key=${ccache_key_prefix}-${current_date}" >> $GITHUB_OUTPUT | |
echo "ccache-restore-key=$ccache_key_prefix" >> $GITHUB_OUTPUT | |
- name: Cache Conan packages | |
id: cache-conan | |
uses: actions/cache@v3 | |
with: | |
key: ${{ steps.cache-key.outputs.conan-key }} | |
restore-keys: ${{ steps.cache-key.outputs.conan-restore-key }} | |
path: ${{ env.CONAN_HOME }} | |
- name: Configure Conan | |
if: steps.cache-conan.outputs.cache-hit != 'true' | |
run: conan profile detect --force | |
- name: Clean Conan cache (pre-build) | |
if: steps.cache-conan.outputs.cache-hit != 'true' | |
run: | | |
conan cache clean "*" --build | |
conan cache clean "*" --download | |
conan cache clean "*" --source | |
conan remove --confirm "*" | |
- name: Build conanfile.py | |
run: | | |
conan install conanfile.py \ | |
--build=missing \ | |
-pr default \ | |
-s build_type=${{ matrix.build_type }} \ | |
-s compiler.libcxx=libc++ \ | |
-s compiler.cppstd=17 \ | |
--output-folder="${{ github.workspace }}/build" | |
- name: Clean Conan cache (post-build) | |
if: steps.cache-conan.outputs.cache-hit != 'true' | |
run: | | |
conan cache clean "*" --build | |
conan cache clean "*" --download | |
conan cache clean "*" --source | |
- name: Configure project | |
run: | | |
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ | |
-DCMAKE_PREFIX_PATH="${{ github.workspace }}/build" \ | |
-DMODLE_ENABLE_TESTING=ON \ | |
-DMODLE_DOWNLOAD_TEST_DATASET=OFF \ | |
-DENABLE_DEVELOPER_MODE=${{ matrix.developer_mode }} \ | |
-DOPT_ENABLE_CLANG_TIDY=OFF \ | |
-DOPT_ENABLE_CPPCHECK=OFF \ | |
-DCMAKE_INSTALL_PREFIX=dest \ | |
-S "${{ github.workspace }}" \ | |
-B "${{ github.workspace }}/build" | |
- name: Cache Ccache folder | |
uses: actions/cache@v3 | |
with: | |
key: ${{ steps.cache-key.outputs.ccache-key }} | |
restore-keys: ${{ steps.cache-key.outputs.ccache-restore-key }} | |
path: ${{ env.CCACHE_DIR }} | |
- name: Build test units | |
run: | | |
cmake --build build -t test_main | |
- name: Package unit tests | |
run: | | |
gtar -cf - build/ | zstd -T0 -13 -o unit-tests.tar.zst | |
- name: Build modle and modle_tools | |
run: cmake --build build | |
- name: Package binaries | |
run: | | |
cmake --install build | |
gtar -cf - -C dest/ bin | | |
zstd -T0 -13 -o binaries.tar.zst | |
- name: Upload unit tests | |
uses: actions/upload-artifact@v3 | |
with: | |
name: unit-tests-${{ matrix.os }}-${{ matrix.compiler_name }}-${{ matrix.compiler_version }}-${{ matrix.build_type }} | |
path: unit-tests.tar.zst | |
if-no-files-found: error | |
retention-days: 1 | |
- name: Upload binaries | |
uses: actions/upload-artifact@v3 | |
with: | |
name: binaries-${{ matrix.os }}-${{ matrix.compiler_name }}-${{ matrix.compiler_version }}-${{ matrix.build_type }} | |
path: binaries.tar.zst | |
if-no-files-found: error | |
retention-days: 1 | |
run-unit-tests: | |
name: Run unit tests | |
needs: [matrix-factory, cache-test-datasets, build-project] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJSON(needs.matrix-factory.outputs.matrix) }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Download unit tests artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: unit-tests-${{ matrix.os }}-${{ matrix.compiler_name }}-${{ matrix.compiler_version }}-${{ matrix.build_type }} | |
- name: Download test datasets | |
id: test-dataset | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ needs.cache-test-datasets.outputs.artifact-name }} | |
- name: Extract binaries and test dataset | |
run: | | |
zstd -dcf unit-tests.tar.zst | gtar -xf - | |
gtar -xf modle_test_data.tar.xz | |
- name: Generate requirements.txt for pip | |
run: echo 'cmake==${{ matrix.cmake }}' > requirements.txt | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
cache: 'pip' | |
- name: Install CMake | |
run: pip install -r requirements.txt | |
- name: Run unit tests | |
working-directory: ${{ github.workspace }}/build | |
run: | | |
ncpus=$(python -c 'import multiprocessing as mp; print(mp.cpu_count())') | |
export CTEST_PARALLEL_LEVEL="$ncpus" | |
ctest --test-dir . \ | |
--schedule-random \ | |
--output-on-failure \ | |
--no-tests=error \ | |
--timeout 300 | |
run-modle-integration-test: | |
name: Run modle integration tests | |
needs: [matrix-factory, cache-test-datasets, build-project] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJSON(needs.matrix-factory.outputs.matrix) }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Download binary artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: binaries-${{ matrix.os }}-${{ matrix.compiler_name }}-${{ matrix.compiler_version }}-${{ matrix.build_type }} | |
- name: Download test datasets | |
id: test-dataset | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ needs.cache-test-datasets.outputs.artifact-name }} | |
- name: Extract binaries and test dataset | |
run: | | |
zstd -dcf binaries.tar.zst | gtar -xf - | |
gtar -xf modle_test_data.tar.xz | |
- name: Generate requirements.txt for pip | |
run: | | |
echo 'cooler>=0.9.1' > requirements.txt | |
echo 'pyBigWig>=0.3.22' >> requirements.txt | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
cache: 'pip' | |
- name: Install test deps | |
run: pip install -r requirements.txt | |
- name: Inspect modle version | |
run: bin/modle --version | |
- name: Run modle integration test(s) | |
run: test/scripts/modle_integration_test.sh bin/modle | head -n 1000 | |
run-modle-tools-integration-test: | |
name: Run modle_tools integration tests | |
needs: [ matrix-factory, cache-test-datasets, build-project ] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJSON(needs.matrix-factory.outputs.matrix) }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Download binary artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: binaries-${{ matrix.os }}-${{ matrix.compiler_name }}-${{ matrix.compiler_version }}-${{ matrix.build_type }} | |
- name: Download test datasets | |
id: test-dataset | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ needs.cache-test-datasets.outputs.artifact-name }} | |
- name: Extract binaries and test dataset | |
run: | | |
zstd -dcf binaries.tar.zst | gtar -xf - | |
gtar -xf modle_test_data.tar.xz | |
- name: Generate requirements.txt for pip | |
run: | | |
echo 'cooler>=0.9.1' > requirements.txt | |
echo 'pyBigWig>=0.3.22' >> requirements.txt | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
cache: 'pip' | |
- name: Install test deps | |
run: pip install -r requirements.txt | |
- name: Inspect modle_tools version | |
run: bin/modle_tools --version | |
- name: Run modle_tools transform integration test(s) | |
run: test/scripts/modle_tools_transform_integration_test.sh bin/modle_tools | head -n 1000 | |
- name: Run modle_tools evaluate integration test(s) | |
run: test/scripts/modle_tools_eval_integration_test.sh bin/modle_tools | head -n 1000 | |
- name: Run modle_tools annotate-barriers integration test(s) | |
run: test/scripts/modle_tools_annotate_barriers_integration_test.sh bin/modle_tools | head -n 1000 | |
macos-ci-status-check: | |
name: Status Check (MacOS CI) | |
if: ${{ always() }} | |
runs-on: ubuntu-latest | |
needs: | |
- matrix-factory | |
- cache-test-datasets | |
- build-project | |
- run-unit-tests | |
- run-modle-integration-test | |
- run-modle-tools-integration-test | |
steps: | |
- name: Collect job results | |
if: | | |
needs.matrix-factory.result != 'success' || | |
needs.cache-test-datasets.result != 'success' || | |
needs.build-project.result != 'success' || | |
needs.run-unit-tests.result != 'success' || | |
needs.run-modle-integration-test.result != 'success' || | |
needs.run-modle-tools-integration-test.result != 'success' | |
run: exit 1 |