Run fuzzy tests #245
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) 2023 Roberto Rossini (roberros@uio.no) | |
# SPDX-License-Identifier: MIT | |
name: Run fuzzy tests | |
on: | |
push: | |
branches: [ main ] | |
paths: | |
- ".github/workflows/fuzzy-testing.yml" | |
- "cmake/**" | |
- "src/**" | |
- "test/scripts/fuzzy_test.py" | |
- "test/scripts/link_h5_dataset.py" | |
- "CMakeLists.txt" | |
- "conanfile.txt" | |
tags: | |
- 'v*.*.*' | |
pull_request: | |
paths: | |
- ".github/workflows/fuzzy-testing.yml" | |
- "test/scripts/fuzzy_test.py" | |
- "test/scripts/link_h5_dataset.py" | |
schedule: | |
# Run weekly | |
- cron: '15 3 * * 0' | |
workflow_dispatch: | |
inputs: | |
duration: | |
description: 'Test duration in seconds' | |
required: true | |
default: '600' | |
type: string | |
resolution: | |
description: 'Matrix resolution to use for testing' | |
required: true | |
default: '10000' | |
type: string | |
# https://stackoverflow.com/a/72408109 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
build-project: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# The .mcool file was generated by using hic2cool followed by cooler balance for all resolutions | |
# We can't use the version shared by 4DNucleome because the .hic and .mcool files they publish | |
# differ slightly | |
- { | |
title: '.cool', | |
balance: 'NONE', | |
url: 'https://www.dropbox.com/s/wq3k09rrpc8smmm/4DNFIPC7P27B.mcool?dl=1', | |
sha256: '7ead807936afbd02c4a0da93d86dd54de489cc07e87400a691c8e917111749de', | |
ref-url: 'https://www.dropbox.com/s/wq3k09rrpc8smmm/4DNFIPC7P27B.mcool?dl=1', | |
ref-sha256: '7ead807936afbd02c4a0da93d86dd54de489cc07e87400a691c8e917111749de' | |
} | |
- { | |
title: '.cool', | |
balance: 'weight', | |
url: 'https://www.dropbox.com/s/wq3k09rrpc8smmm/4DNFIPC7P27B.mcool?dl=1', | |
sha256: '7ead807936afbd02c4a0da93d86dd54de489cc07e87400a691c8e917111749de', | |
ref-url: 'https://www.dropbox.com/s/wq3k09rrpc8smmm/4DNFIPC7P27B.mcool?dl=1', | |
ref-sha256: '7ead807936afbd02c4a0da93d86dd54de489cc07e87400a691c8e917111749de' | |
} | |
- { | |
title: '.hic', | |
balance: 'NONE', | |
url: 'https://www.dropbox.com/s/gkzxt5ae82dvlrg/4DNFIPC7P27B.hic?dl=1', | |
sha256: 'b1ba1c942693a5b6e494de7f8da097a1435598a9bb951219929b5a84cb2a6b42', | |
ref-url: 'https://www.dropbox.com/s/wq3k09rrpc8smmm/4DNFIPC7P27B.mcool?dl=1', | |
ref-sha256: '7ead807936afbd02c4a0da93d86dd54de489cc07e87400a691c8e917111749de', | |
} | |
- { | |
title: '.hic', | |
balance: 'KR', | |
url: 'https://www.dropbox.com/s/gkzxt5ae82dvlrg/4DNFIPC7P27B.hic?dl=1', | |
sha256: 'b1ba1c942693a5b6e494de7f8da097a1435598a9bb951219929b5a84cb2a6b42', | |
ref-url: 'https://www.dropbox.com/s/wq3k09rrpc8smmm/4DNFIPC7P27B.mcool?dl=1', | |
ref-sha256: '7ead807936afbd02c4a0da93d86dd54de489cc07e87400a691c8e917111749de' | |
} | |
container: | |
image: ghcr.io/paulsengroup/ci-docker-images/ubuntu-22.04-cxx-clang-16 | |
options: "--user=root" | |
env: | |
CONAN_HOME: '/root/.conan2' | |
steps: | |
- name: Clone hictk | |
uses: actions/checkout@v4 | |
- name: Clone hictkpy | |
uses: actions/checkout@v4 | |
with: | |
repository: paulsengroup/hictkpy | |
ref: main | |
path: hictkpy | |
- name: Patch hictkpy | |
working-directory: hictkpy | |
if: github.event_name != 'schedule' | |
run: | | |
sed -i 's|URL.*\.tar\.xz"|GIT_REPOSITORY https://github.com/paulsengroup/hictk.git|' CMakeLists.txt | |
sed -i 's|URL_HASH.*|GIT_TAG ${{ github.event.after }}|' CMakeLists.txt | |
grep 'GIT_TAG' CMakeLists.txt | |
- name: Patch hictkpy (schedule) | |
working-directory: hictkpy | |
if: github.event_name == 'schedule' | |
run: | | |
sed -i 's|URL.*\.tar\.xz"|GIT_REPOSITORY https://github.com/paulsengroup/hictk.git|' CMakeLists.txt | |
sed -i 's|URL_HASH.*|GIT_TAG main|' CMakeLists.txt | |
- name: Fix permissions | |
run: | | |
chown -R $(id -u):$(id -g) $PWD | |
- name: Generate cache key | |
id: cache-key | |
working-directory: hictkpy | |
run: | | |
hash="${{ hashFiles('conanfile.txt') }}" | |
echo "key=fuzzy-testing-$hash" >> $GITHUB_OUTPUT | |
- name: Install Python | |
run: | | |
apt-get update | |
apt-get install -y python3.11 python3.11-dev | |
- name: Restore Conan cache | |
id: cache-conan | |
uses: actions/cache/restore@v3 | |
with: | |
key: conan-${{ steps.cache-key.outputs.key }} | |
path: ${{ env.CONAN_HOME }} | |
- 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: Install build dependencies | |
run: | | |
conan install . \ | |
--build=missing \ | |
-pr:b="$CONAN_DEFAULT_PROFILE_PATH" \ | |
-pr:h="$CONAN_DEFAULT_PROFILE_PATH" \ | |
-s build_type=Release \ | |
-s compiler.libcxx=libstdc++11 \ | |
-s compiler.cppstd=17 \ | |
-o '*/*:shared=True' \ | |
--output-folder=build | |
conan install hictkpy \ | |
--build=missing \ | |
-pr:b="$CONAN_DEFAULT_PROFILE_PATH" \ | |
-pr:h="$CONAN_DEFAULT_PROFILE_PATH" \ | |
-s build_type=Release \ | |
-s compiler.libcxx=libstdc++11 \ | |
-s compiler.cppstd=17 \ | |
-o '*/*:shared=True' \ | |
--output-folder=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: Install Python bindings | |
working-directory: hictkpy | |
run: | | |
pip install --upgrade pip setuptools wheel pybind11 | |
env CC=clang-16 \ | |
CXX=clang++-16 \ | |
CMAKE_ARGS="-DCMAKE_PREFIX_PATH=$PWD/../build" \ | |
HICTKPY_SETUP_SKIP_CONAN=1 \ | |
pip install . -v | |
- name: Save Conan cache | |
uses: actions/cache/save@v3 | |
if: steps.cache-conan.outputs.cache-hit != 'true' | |
with: | |
key: conan-${{ steps.cache-key.outputs.key }} | |
path: ${{ env.CONAN_HOME }} | |
- name: Install test dependencies | |
run: | | |
apt-get update | |
apt-get install -y curl zstd | |
pip install --no-cache-dir 'cooler>=0.9.2' | |
- name: Detect CI type | |
id: ci-type | |
run: | | |
if git log --format=%B -n 1 ${{ github.event.after }} | grep -qF '[ci full]'; then | |
echo "type=full" >> $GITHUB_OUTPUT | |
else | |
echo "type=short" >> $GITHUB_OUTPUT | |
fi | |
- name: Prepare for test | |
id: test-params | |
env: | |
PYTHONHASHSEED: 0 | |
run: | | |
seed="$(python3 -c 'import random; print(random.randint(0, 2**32))')" | |
duration=600 | |
if [[ ${{ github.event_name }} == 'workflow_dispatch' ]]; then | |
duration='${{ inputs.duration }}' | |
elif [[ ${{ steps.ci-type.outputs.type }} == 'full' ]]; then | |
duration=3600 | |
fi | |
resolution=10000 | |
if [[ ${{ github.event_name }} == 'workflow_dispatch' ]]; then | |
resolution='${{ inputs.resolution }}' | |
fi | |
2>&1 echo "Seed: ${seed}" | |
2>&1 echo "Duration: ${duration}" | |
2>&1 echo "Resolution: ${resolution}" | |
echo "seed=$seed" >> $GITHUB_OUTPUT | |
echo "duration=$duration" >> $GITHUB_OUTPUT | |
echo "resolution=$resolution" >> $GITHUB_OUTPUT | |
- name: Clone hictk | |
uses: actions/checkout@v4 | |
with: | |
path: hictk | |
- name: Fix permissions | |
run: | | |
chown -R $(id -u):$(id -g) $PWD | |
- name: Download test datasets | |
working-directory: hictk | |
run: | | |
resolution="${{ steps.test-params.outputs.resolution }}" | |
echo "${{ matrix.ref-sha256 }} reference.mcool" | tee checksums.sha256 | |
curl -L "${{ matrix.ref-url }}" -o reference.mcool | |
sha256sum -c checksums.sha256 | |
cooler cp "reference.mcool::/resolutions/$resolution" reference.cool | |
rm reference.mcool | |
if [[ ${{ matrix.ref-sha256 }} == ${{ matrix.sha256 }} ]]; then | |
ln -s reference.cool test.matrix | |
else | |
echo "${{ matrix.sha256 }} test.matrix" | tee checksums.sha256 | |
curl -L "${{ matrix.url }}" -o test.matrix | |
sha256sum -c checksums.sha256 | |
if [[ ${{ matrix.title }} == .cool ]]; then | |
cooler cp "test.matrix::/resolutions/$resolution" test.matrix.tmp | |
mv test.matrix.tmp test.matrix | |
fi | |
fi | |
- name: Run test | |
working-directory: hictk | |
run: | | |
test/scripts/fuzzy_test.py \ | |
--seed '${{ steps.test-params.outputs.seed }}' \ | |
--duration '${{ steps.test-params.outputs.duration }}' \ | |
--balance ${{ matrix.balance }} \ | |
test.matrix \ | |
reference.cool | |
fuzzy-testing-status-check: | |
name: Status Check (fuzzy-testing) | |
if: ${{ always() }} | |
runs-on: ubuntu-latest | |
needs: | |
- build-project | |
steps: | |
- name: Collect job results | |
if: needs.build-project.result != 'success' | |
run: exit 1 |