Skip to content

Commit

Permalink
Add CI on GitHub Actions (#4)
Browse files Browse the repository at this point in the history
This patch adds CI (C++ unit tests and pre-commit hooks) to GitHub Actions.
  • Loading branch information
ybubnov authored Sep 22, 2024
1 parent 0372213 commit a60a9c6
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: [ybubnov]
53 changes: 53 additions & 0 deletions .github/workflows/cxx_unit_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CXX Unit Test

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
unit-tests:
runs-on: ubuntu-22.04
container:
image: ubuntu:22.04

steps:
- name: Checkout source code
id: checkout
uses: actions/checkout@v4

- name: Configure apt to disable recommendations installation
id: configure_apt
run: |
echo 'APT::Install-Recommends "false";' >> /etc/apt/apt.conf
echo 'APT::Install-Suggests "false";' >> /etc/apt/apt.conf
- name: Install third-party libraries and tools
id: install_packages
run: |
apt-get update
apt-get install -y cmake build-essential libboost-test-dev libfmt-dev wget unzip
apt-get install -y python3-pip python3-numpy
- name: Install python libraries
id: install_torch
run: pip3 install 'torch>=2.2.0+cpu' --index-url https://download.pytorch.org/whl/cpu

- name: Find PyTorch cmake prefix path
id: find_torch
run: >
echo "cmake_prefix_path=$(python3 -c 'import torch; print(torch.utils.cmake_prefix_path)')"
>> $GITHUB_OUTPUT
- name: Configure CMake
run: >
cmake
-DCMAKE_PREFIX_PATH=${{steps.find_torch.outputs.cmake_prefix_path}}
-B ${{github.workspace}}/build
- name: Build CXX library
run: cmake --build ${{github.workspace}}/build

- name: Run unit-tests
run: make -C ${{github.workspace}}/build test ARGS="--verbose" BOOST_TEST_LOG_LEVEL="test_suite"
20 changes: 20 additions & 0 deletions .github/workflows/pre_commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Pre-Commit

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit
run: pre-commit run --all-files --show-diff-on-failure --color=always

0 comments on commit a60a9c6

Please sign in to comment.