Place a system metadata stamp on readme chart #1710
Workflow file for this run
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
name: CPP tests | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
concurrency: | |
group: unit-test${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_number || github.ref }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash -l -eo pipefail {0} | |
jobs: | |
Cpp-tests: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
ffmpeg-version-for-tests: ['4.4.2', '5.1.2', '6.1.1', '7.0.1'] | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v3 | |
- name: Setup conda env | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
auto-update-conda: true | |
miniconda-version: "latest" | |
activate-environment: test | |
python-version: '3.12' | |
- name: Update pip | |
run: python -m pip install --upgrade pip | |
- name: Install dependencies | |
run: | | |
python -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu | |
- name: Install ffmpeg and pkg-config | |
run: | | |
conda install "ffmpeg=${{ matrix.ffmpeg-version-for-tests }}" pkg-config -c conda-forge | |
ffmpeg -version | |
- name: Build and run C++ tests | |
run: | | |
# Note: we're not setting BUILD_AGAINST_ALL_FFMPEG_FROM_S3 here, so | |
# we're building libtorchcodec against the installed FFmpeg version | |
# (from conda-forge) instead of building against our pre-built non-GPL | |
# FFmpeg libraries. | |
# The reason we need this is because the C++ tests decode x264 files. | |
# x264 support is not LGPL, os it is not supported by our | |
# pre-built non-GPL FFmpeg libraries. And if we were to build against | |
# those, this is also what the tests would be loading at run time, | |
# then failing when we try to decode x264. | |
# To remediate that, we build against the FFmpeg that we installed | |
# from conda-forge (which is able to decode x264), and that's also | |
# what gets loaded at run time. | |
# The Python tests are also decoding x264 files, and are built against | |
# our non-GPL FFmpeg. And yet they pass. This is because in Python | |
# we're able to distinguish between build-time (non-GPL FFmpeg) and | |
# run time (conda-forge FFmpeg). | |
build_tests_dir="${PWD}/build_tests" | |
mkdir $build_tests_dir | |
pushd $build_tests_dir | |
TORCH_PATH=$(python -c "import pathlib, torch; print(pathlib.Path(torch.__path__[0]))") | |
Torch_DIR="${TORCH_PATH}/share/cmake/Torch" | |
cmake .. -DTorch_DIR=$Torch_DIR -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DCMAKE_VERBOSE_MAKEFILE=ON | |
cmake --build . | |
ctest --output-on-failure | |
popd |