Skip to content

Add workflows to lint project #1168

Add workflows to lint project

Add workflows to lint project #1168

Workflow file for this run

# Copyright (C) 2023 Roberto Rossini <roberros@uio.no>
# SPDX-License-Identifier: MIT
name: Run Codecov
on:
push:
branches: [main]
paths:
- ".github/codecov.yml"
- ".github/workflows/build-conan-deps.yml"
- ".github/workflows/cache-test-dataset.yml"
- ".github/workflows/codecov.yml"
- ".github/workflows/evict-gha-cache.yml"
- "cmake/**"
- "examples/**"
- "src/**"
- "test/integration/**"
- "test/units/**"
- "CMakeLists.txt"
- "conanfile.py"
pull_request:
paths:
- ".github/codecov.yml"
- ".github/workflows/build-conan-deps.yml"
- ".github/workflows/cache-test-dataset.yml"
- ".github/workflows/codecov.yml"
- ".github/workflows/evict-gha-cache.yml"
- "cmake/**"
- "examples/**"
- "src/**"
- "test/integration/**"
- "test/units/**"
- "CMakeLists.txt"
- "conanfile.py"
# 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:
cache-test-dataset:
name: Cache test dataset
uses: paulsengroup/hictk/.github/workflows/cache-test-dataset.yml@main
build-conan-deps:
name: Build Conan deps
uses: paulsengroup/hictk/.github/workflows/build-conan-deps.yml@main
with:
os: ubuntu-20.04
build-project:
name: Build project
needs: build-conan-deps
runs-on: ubuntu-latest
container:
image: ghcr.io/paulsengroup/ci-docker-images/ubuntu-24.04-cxx-gcc-14
options: "--user=root"
outputs:
ccache-old-cache-key: ${{ steps.cache-ccache.outputs.cache-matched-key }}
env:
CCACHE_DIR: "/opt/ccache-cache"
CCACHE_COMPILERCHECK: "content"
CCACHE_COMPRESSLEVEL: "1"
CCACHE_MAXSIZE: "500M"
CONAN_HOME: "/opt/conan/"
steps:
- uses: actions/checkout@v4
- name: Fix permissions
run: |
chown -R $(id -u):$(id -g) $PWD
- name: Generate cache key
id: cache-key
run: |
conanfile_hash="${{ hashFiles('conanfile.py') }}"
# This can be used by to always update a cache entry (useful e.g. for ccache)
current_date="$(date '+%s')"
ccache_key_prefix="codecov-ccache-$conanfile_hash"
echo "ccache-key=${ccache_key_prefix}-$GITHUB_REF-${current_date}" | tee -a "$GITHUB_OUTPUT"
echo "ccache-restore-key-1=$ccache_key_prefix-$GITHUB_REF" | tee -a "$GITHUB_OUTPUT"
echo "ccache-restore-key-2=$ccache_key_prefix" | tee -a "$GITHUB_OUTPUT"
- name: Restore Conan cache
uses: actions/cache/restore@v4
with:
key: ${{ needs.build-conan-deps.outputs.conan-key }}
path: ${{ env.CONAN_HOME }}/p
fail-on-cache-miss: true
- name: Restore CMake configs
uses: actions/cache/restore@v4
with:
key: ${{ needs.build-conan-deps.outputs.cmake-prefix-debug-key }}
path: /tmp/cmake-prefix-dbg.tar
fail-on-cache-miss: true
- name: Extract CMake configs
run: |
mkdir conan-env
tar -xf /tmp/cmake-prefix-dbg.tar -C conan-env/ --strip-components=1
- name: Configure project
run: |
cmake -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_PREFIX_PATH="$PWD/conan-env" \
-DENABLE_DEVELOPER_MODE=ON \
-DOPT_ENABLE_COVERAGE=ON \
-DOPT_ENABLE_SANITIZER_ADDRESS=OFF \
-DOPT_ENABLE_SANITIZER_UNDEFINED_BEHAVIOR=OFF \
-DOPT_ENABLE_CLANG_TIDY=OFF \
-DHICTK_BUILD_EXAMPLES=OFF \
-DHICTK_ENABLE_TESTING=ON \
-DHICTK_DOWNLOAD_TEST_DATASET=OFF \
-DHICTK_ENABLE_GIT_VERSION_TRACKING=OFF \
-S . \
-B build
- name: Restore Ccache folder
id: cache-ccache
uses: actions/cache/restore@v4
with:
key: ${{ steps.cache-key.outputs.ccache-restore-key-1 }}
restore-keys: ${{ steps.cache-key.outputs.ccache-restore-key-2 }}
path: ${{ env.CCACHE_DIR }}
- name: Reset Ccache stats
run: ccache --zero-stats
- name: Build project
run: cmake --build build -j $(nproc)
- name: Package build folder
run: tar --exclude='*.o' -cf - build/ | zstd -T0 -13 -o build.tar.zst
- name: Upload build folder
uses: actions/upload-artifact@v4
with:
name: "build-codecov"
path: build.tar.zst
if-no-files-found: error
retention-days: 1
- name: Print Ccache statistics (pre-cleanup)
run: |
ccache --show-stats \
--show-compression \
--verbose
- name: Cleanup Ccache folder
run: |
ccache --evict-older-than=14400s # 4h
ccache --recompress=19 --recompress-threads="$(nproc)"
ccache --cleanup
- name: Print Ccache statistics (post-cleanup)
run: |
ccache --show-stats \
--show-compression \
--verbose
- name: Save Ccache folder
uses: actions/cache/save@v4
with:
key: ${{ steps.cache-key.outputs.ccache-key }}
path: ${{ env.CCACHE_DIR }}
env:
ZSTD_CLEVEL: 1
clean-stale-cache:
needs: [build-project]
uses: paulsengroup/hictk/.github/workflows/evict-gha-cache.yml@main
name: Clean stale Ccache cache
permissions:
actions: write
if: needs.build-project.outputs.ccache-old-cache-key != ''
with:
cache-key: "${{ needs.build-project.outputs.ccache-old-cache-key }}"
run-unit-tests:
name: Run unit tests
needs: [cache-test-dataset, build-project]
runs-on: ubuntu-latest
container:
image: ghcr.io/paulsengroup/ci-docker-images/ubuntu-24.04-cxx-gcc-14
options: "--user=root"
env:
HICTK_CI: "1"
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Restore test dataset
uses: actions/cache/restore@v4
with:
key: ${{ needs.cache-test-dataset.outputs.cache-key }}
path: test/data/hictk_test_data.tar.zst
fail-on-cache-miss: true
- name: Download unit tests artifact
uses: actions/download-artifact@v4
with:
name: "build-codecov"
- name: Extract binaries and test dataset
run: |
tar -xf build.tar.zst
tar -xf test/data/hictk_test_data.tar.zst
- name: Add test user
run: useradd devel
- name: Fix permissions
run: |
chown -R devel:devel build/
- name: Setup dependencies
run: |
apt-get update
apt-get install -q -y --no-install-recommends \
gpg \
gpg-agent \
sudo \
tar
update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-14 100
- name: Run unit tests
run: |
sudo -u devel -E env "PATH=$PATH" \
ctest --test-dir build/ \
--schedule-random \
--output-on-failure \
--no-tests=error \
--timeout 240 \
-j $(nproc) |&
head -n 1000
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
flags: "tests | unittests"
fail_ci_if_error: true
plugin: gcov
os: linux
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
run-integration-tests:
name: Run integration tests
needs: [cache-test-dataset, build-project]
runs-on: ubuntu-latest
container:
image: ghcr.io/paulsengroup/ci-docker-images/ubuntu-24.04-cxx-gcc-14
options: "--user=root"
env:
HICTK_CI: "1"
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Restore test dataset
uses: actions/cache/restore@v4
with:
key: ${{ needs.cache-test-dataset.outputs.cache-key }}
path: test/data/hictk_test_data.tar.zst
fail-on-cache-miss: true
- name: Download binaries artifact
uses: actions/download-artifact@v4
with:
name: "build-codecov"
- name: Extract binaries and test dataset
run: |
tar -xf build.tar.zst
tar -xf test/data/hictk_test_data.tar.zst
- name: Install test suite
run: |
python3.12 -m venv venv --upgrade
venv/bin/pip install test/integration
- name: Add test user
run: useradd devel
- name: Fix permissions
run: |
chown -R devel:devel build/
- name: Setup dependencies
run: |
apt-get update
apt-get install -q -y --no-install-recommends \
gpg \
gpg-agent \
sudo \
tar
update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-14 100
- name: Test hictk balance
run: |
sudo -u devel -E env "PATH=$PATH" \
venv/bin/hictk_integration_suite \
build/src/hictk/hictk \
test/integration/config.toml \
--do-not-copy-binary \
--data-dir test/data \
--threads "$(nproc)" \
--result-file integration-test-report.balance.json \
--suites=balance
- name: Test hictk convert
run: |
sudo -u devel -E env "PATH=$PATH" \
venv/bin/hictk_integration_suite \
build/src/hictk/hictk \
test/integration/config.toml \
--do-not-copy-binary \
--data-dir test/data \
--threads "$(nproc)" \
--result-file integration-test-report.convert.json \
--suites=convert
- name: Test hictk dump
run: |
sudo -u devel -E env "PATH=$PATH" \
venv/bin/hictk_integration_suite \
build/src/hictk/hictk \
test/integration/config.toml \
--do-not-copy-binary \
--data-dir test/data \
--threads "$(nproc)" \
--result-file integration-test-report.dump.json \
--suites=dump
- name: Test hictk fix-mcool
run: |
sudo -u devel -E env "PATH=$PATH" \
venv/bin/hictk_integration_suite \
build/src/hictk/hictk \
test/integration/config.toml \
--do-not-copy-binary \
--data-dir test/data \
--threads "$(nproc)" \
--result-file integration-test-report.fix-mcool.json \
--suites=fix-mcool
- name: Test hictk load
run: |
sudo -u devel -E env "PATH=$PATH" \
venv/bin/hictk_integration_suite \
build/src/hictk/hictk \
test/integration/config.toml \
--do-not-copy-binary \
--data-dir test/data \
--threads "$(nproc)" \
--result-file integration-test-report.load.json \
--suites=load
- name: Test hictk merge
run: |
sudo -u devel -E env "PATH=$PATH" \
venv/bin/hictk_integration_suite \
build/src/hictk/hictk \
test/integration/config.toml \
--do-not-copy-binary \
--data-dir test/data \
--threads "$(nproc)" \
--result-file integration-test-report.merge.json \
--suites=merge
- name: Test hictk metadata
run: |
sudo -u devel -E env "PATH=$PATH" \
venv/bin/hictk_integration_suite \
build/src/hictk/hictk \
test/integration/config.toml \
--do-not-copy-binary \
--data-dir test/data \
--threads "$(nproc)" \
--result-file integration-test-report.metadata.json \
--suites=metadata
- name: Test hictk rename-chromosomes
run: |
sudo -u devel -E env "PATH=$PATH" \
venv/bin/hictk_integration_suite \
build/src/hictk/hictk \
test/integration/config.toml \
--do-not-copy-binary \
--data-dir test/data \
--threads "$(nproc)" \
--result-file integration-test-report.rename-chromosomes.json \
--suites=rename-chromosomes
- name: Test hictk validate
run: |
sudo -u devel -E env "PATH=$PATH" \
venv/bin/hictk_integration_suite \
build/src/hictk/hictk \
test/integration/config.toml \
--do-not-copy-binary \
--data-dir test/data \
--threads "$(nproc)" \
--result-file integration-test-report.validate.json \
--suites=validate
- name: Test hictk zoomify
run: |
sudo -u devel -E env "PATH=$PATH" \
venv/bin/hictk_integration_suite \
build/src/hictk/hictk \
test/integration/config.toml \
--do-not-copy-binary \
--data-dir test/data \
--threads "$(nproc)" \
--result-file integration-test-report.zoomify.json \
--suites=zoomify
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
flags: "tests | integration"
fail_ci_if_error: true
plugin: gcov
os: linux
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
codecov-status-check:
name: Status Check (Codecov)
if: ${{ always() }}
runs-on: ubuntu-latest
needs:
- build-project
- run-unit-tests
- run-integration-tests
steps:
- name: Collect job results
if: |
needs.build-project.result != 'success' ||
needs.run-unit-tests.result != 'success' ||
needs.run-integration-tests.result != 'success'
run: exit 1